目录
- KL散度
- Github本地关联
- Github相关
- matplotlib绘图相关
- conda 相关
- tf2.0 与 cuda 10.1
- baseline
- Pytorch
- Python忽略warning的输出
- Python项目生成requirement.txt
- Python多线程相关
- Python包发布
- Linux Screen
- Linux nice
- Windows远程桌面分辨率
- Python打包python脚本为exe
KL散度
Kullback-Leibler Divergence Explained
https://www.countbayesie.com/blog/2017/5/9/kullback-leibler-divergence-explained
- 上文的中文翻译 https://www.jianshu.com/p/43318a3dc715
知乎如何通俗的解释交叉熵与相对熵?
Github本地关联
ssh-keygen -t rsa -C "[email protected]"
git remote -v
git remote add origin [email protected]:yourusername/yourreponame.git
Github相关
# 取回远程仓库的变化,并与本地分支合并
git pull [remote] [branch]
git pull origin master
git push -f origin master
git remote set-url origin new_url
git clone -b tf2 https://github.com/openai/baselines.git
…or create a new repository on the command line
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin [email protected]:yourusername/yourreponame.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin [email protected]:yourusername/yourreponame.git
git branch -M main
git push -u origin main
matplotlib绘图相关
Python3 数据科学(四):Matplotlib
https://wangxin1248.github.io/python/2018/11/python3-data-science-plt-01.html
有关Matplotlib的一些技巧
- 使用Matplotlib的一些奇淫技巧 https://yanceyzhangdl.github.io/2017/04/24/%E4%BD%BF%E7%94%A8Matplotlib%E7%9A%84%E4%B8%80%E4%BA%9B%E5%A5%87%E6%B7%AB%E6%8A%80%E5%B7%A7/
matplotlib 的动态绘图实现
python中plot实现即时数据动态显示方法
x轴尺度
plt.xscale('linear') #线性 plt.xscale('log') #对数 plt.xscale('symlog', linthreshy=0.05) #对称的对数 plt.xscale('logit') #logit
conda 相关
conda env list
conda info
conda list
conda create -n env_name python=3.7
conda env remove -n env_name
conda activate env_name
conda deactivate
conda config --show-sources #查看当前使用源
conda config --remove channels 源名称或链接 #删除指定源
conda config --add channels 源名称或链接 #添加指定源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
tf2.0 与 cuda 10.1
https://github.com/fo40225/tensorflow-windows-wheel
baseline
Saving the model
python -m baselines.run --alg=ppo2 --env=PongNoFrameskip-v4 --num_timesteps=2e7 --save_path=~/models/pong_20M_ppo2
- To load and visualize the model, we'll do the following - load the model, train it for 0 steps, and then visualize:
python -m baselines.run --alg=ppo2 --env=PongNoFrameskip-v4 --num_timesteps=0 --load_path=~/models/pong_20M_ppo2 --play
- Logging and vizualizing learning curves and other training metrics
python -m baselines.run --alg=deepq --env=PongNoFrameskip-v4 --log_path=./logs/Pong/ --num_timesteps=1e7
dqn tips
https://github.com/openai/baselines/blob/master/baselines/deepq/README.md
Loading and visualizing results
https://github.com/openai/baselines/blob/master/docs/viz/viz.ipynb
Pytorch
torch.squeeze() 这个函数主要对数据的维度进行压缩
torch.unsqueeze() 这个函数主要是对数据维度进行扩充
@ 真正意义上的矩阵乘法,类似torch.mm() torch.bmm() torch.matmul()
* 矩阵每个元素与对应位置相乘,类似torch.mul()
Python忽略warning的输出
import warnings
warnings.filterwarnings('ignore')
或
python -W ignore file.py
Python项目生成requirement.txt
pipreqs ./ --encoding=utf-8 --force
Python多线程相关
避免程序占满CPU
linux:
OMP_NUM_THREADS=1
export OMP_NUM_THREADS
pytorch:
torch.set_num_threads(int)
或
# 选择显卡
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #也可以多选
CUDA_VISIBLE_DEVICES=1,2 python train.py #还可以这样
# 只使用一个线程
os.environ["OMP_NUM_THREADS"] = "1"
Python包发布
python setup.py sdist bdist_wheel
twine upload dist/*
Linux Screen
https://www.ibm.com/developerworks/cn/linux/l-cn-screen/index.html
screen -S yourname -> 新建一个叫yourname的session
screen -ls -> 列出当前所有的session
screen -r yourname -> 回到yourname这个session
screen -d yourname -> 远程detach某个session
screen -d -r yourname -> 结束当前session并回到yourname这个session
Linux nice
Linux nice命令以更改过的优先序来执行程序,如果未指定程序,则会印出目前的排程优先序,内定的 adjustment 为 10,范围为 -20(最高优先序)到 19(最低优先序)。
使用权限:所有使用者。
nice [-n adjustment] [-adjustment] [--adjustment=adjustment] [--help] [--version] [command [arg...]]
-n adjustment, -adjustment, --adjustment=adjustment 皆为将该原有优先序的增加 adjustment
--help 显示求助讯息
--version 显示版本资讯
Windows远程桌面分辨率
mstsc.exe /w:2560 /h:1440
Python打包python脚本为exe
-F指定启动文件;-p添加相关.py脚本;--add-data 添加其它依赖文件
https://www.applenice.net/2020/03/09/PyInstaller-adding-data-files/
pyinstaller -F app.py -p core.py -p seri.py -p utils.py --add-data "templates;templates" --add-data "static;static"
版权属于:microyu (除特别说明外)
本文链接:https://blog.microyu.top/archives/10/
版权声明:本博客文章采用CC BY-NC-SA 4.0进行许可,请在转载时注明出处及本声明!
针不戳