1 | git init |
git origin理解
git origin
是远程主机
可以通过git remove -v
看到
git push origin master
的全部含义是把 本地的master分支推送到远程的master
git pull origin master
的全部含义同~
Cache 生成的对象
可持久化对象不如直接多线程dataloader。
想把处理好的对象直接保存下来,然后写了一个Cache
类
第一次会把对象保存到硬盘, 第二次会直接读取
1 | import os |
1 | class TrainDataBase(DataBase): |
然后测试结果是74.46734094619751s, 75.0271668434143s
本来多线程是不到1分钟。。。
去生成的文件瞅瞅,12G
因为Dataloader是多线程处理的,所以会快很多。
tqdm与tqdm_notebook
tqdm
用于terminaltqdm_notebook
用于jupyter
设计模式python总结
python重新加载模块
1 | %load_ext autoreload |
pytorch加载模型
加载预训练模型
1 | my_resnet = MyResNet(*args, **kwargs) |
1 | torch.save(my_resnet.state_dict(), "my_resnet.pth") |
1 | my_resnet = torch.load("my_resnet.pth") |
加载部分预训练模型
1 | pretrained_dict = model_zoo.load_url(model_urls['resnet152']) |
tar压缩可视化进度
1 | tar cf - ./images -P | pv -s $(du -sb ./images | awk '{print $1}') | gzip > /disk3/images.tar.gz |
vim块编辑
Put your cursor on the first # character, press CtrlV
(or CtrlQ for gVim), and go down until the last commented line and press x
, that will delete all the # characters vertically.
For commenting a block of text is almost the same:
First, go to the first line you want to comment, press CtrlV
. This will put the editor in the VISUAL BLOCK mode.
Then using the arrow key and select until the last line
Now press ShiftI
, which will put the editor in INSERT mode and then press #
. This will add a hash to the first line.
Then press Esc
(give it a second), and it will insert a # character on all other selected lines.
https://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim
jupyter黑白
1 | pip uninstall ipykernel |