Monday, June 10, 2019

如何半自动安装python package

全自动: pip install xxx
半自动:一些python package 有setup.py xx install . 可以follow 这些instruction
如果没有write access 到site-package 这种系统路径,需要把package 安装到自己设定的路径下面去,具体参考网页https://docs.python.org/2.7/install/index.html#alternate-installation
举例来说,
python setup.py install --home=/home/ec2-user/workspaces/hoverboard-workspaces/lib

此时,需要把当前目录装在PYTHONPATH里面去,

vim ~/.bashrc
PYTHONPATH=~/one/location:$PYTHONPATH
PYTHONPATH=~/second/location:$PYTHONPATH
export PYTHONPATH
source ~/.bashrc
如果有其他依赖的话,还需要安装其他依赖package.





如果在断网的情况下pip install package, 为了避免平台问题(比如amazon hoverboard),需要先把package 所有依赖的源代码下载下来,然后再安装。具体见:
https://www.cnblogs.com/jay54520/p/8330994.html
https://www.jianshu.com/p/f8a3f3a07aff
https://blog.csdn.net/pierre_/article/details/54234151
http://imshuai.com/python-pip-install-package-offline-tensorflow/


如果感觉没有问题,比如wheel 文件适合当前平台的话,可以download 对应的whl文件,然后通过
pip install --user -v --no-index "${WHEELS_LOC}certifi-2018.11.29-py2.py3-none-any.whl"
进行安装




Thursday, December 27, 2018

tensorflow 炼丹trick

为什么loss 或者学习的参数  在summary 中会出现nan?
可能是由于梯度爆炸引起的。解决方法:1. gradient clip 2. batch nomalization 3, 降低学习率 4. 加入正则。
参考文献:
https://blog.csdn.net/qq_33485434/article/details/80733251
https://blog.csdn.net/qq_25737169/article/details/78847691
https://cloud.tencent.com/developer/article/1057071
https://blog.csdn.net/yinxingtianxia/article/details/78121037
https://www.jianshu.com/p/cc42a9a45a71
https://www.zhihu.com/question/49346370

如果你想查看ckpt中的网络结构和参数该怎么弄呢?这里提供2种方法。 一是用tensorflow官方源码中自带的inspect_checkpoint.py 给个例子如下: python /usr/local/lib/python2.7/dist-packages/tensorflow/python/tools/inspect_checkpoint.py --file_name=model.ckpt-158940 --tensor_name=unit_1_1/conv1/Weights 如果你只用了file_name这个参数,那么看到的就是整体网络结构。如果你2个参数都用了,那看到的就是具体那一层的值


Tuesday, December 25, 2018

LSTM and attention

LSTM:
references:
http://blog.gdf.name/lstm-with-tensorflow/
https://blog.csdn.net/Jason160918/article/details/78295423
https://blog.csdn.net/xuanyuansen/article/details/61913886
https://www.jianshu.com/p/b6130685d855

formula:


Attention formula:



Thursday, October 25, 2018

machine learning / deep learning 比较好的一些topic / trend


Topic:
  1. matrix factorization
  2. collaborative filtering 
  3. CTR预估
  4. one shot learning (单样本学习)+ 孪生网络
  5. 强化学习 RL
  6. 对抗生成网络 GAN
  7. GCN/GNN
  8. Meta-learning法。从先前的学习经验中提炼出基本的参数和结构配置。
  9. Transfer learning法。从先前的学习经验中提炼出可以重用的一些知识
  10. machine translation
  11. LSTM/GRU/GMU...
  12. Attention
  13. Transformer
  14. encoder-decoder
  15. factorization machine
  16. auto-encoder
  17. sequence to sequence
  18. copy net
  19. highway
  20. conventional/ recurrent / recursive neural network
  21. memory network/Neural Turing Machines
  22. Momentum

Method:
  1. DSSM
  2. Wide & Deep
  3. GAN各种变形
  4. FM各种变形
  5. GLU/GTU/GMU/GRU
  6. ResNet
  7. copynet
实验的trick:
  1. dropout
  2. L1/L2 正则
  3. batch norm 
  4. clip by norm/value
  5. learning rate decay
预处理语言模型:
word2vec, fasttext, glove, elmo, gpt, bert

Wednesday, September 19, 2018

tensorflow 理解

知乎上别人的专栏:https://www.zhihu.com/people/xi-xiang-yu-20/columns
dataset + estimator 以后把所有的输入部分转化成dataset 的模式。 estimator 是一个高层封装,可以调用一些基本方法。具体怎么用estimator,可以看 https://zhuanlan.zhihu.com/p/37586029