目录

KL散度

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绘图相关

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

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"
©著作权归作者所有

仅有一条评论

发表评论