```py
# 1. Directly Load a Pre-trained Model
# https://github.com/pytorch/vision/tree/master/torchvision/models
import torchvision.models as models
resnet50 = models.resnet50(pretrained=True)
# or
model = models.resnet50(pretrained=False)
# Maybe you want to modify the last fc layer?
resnet.fc = nn.Linear(2048, 2)
# 2. Load part of parameters of a pretrained model as init for self-defined similar-architecture model.
# resnet50 is a pretrain model
# self_defined indicates model you just define.
resnet50 = models.resnet50(pretrained=True)
self_defined = ...
pretrained_dict = resnet50.state_dict()
model_dict = self_defined.state_dict()
pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}
# update & load
model_dict.update(pretrained_dict)
model.load_state_dict(model_dict)
# 3. Save & Load routines.
# routine
# (recommended) saves and loads only the model parameters
torch.save(model.state_dict(), PATH)
model.load_state_dict(torch.load(PATH))
# routine 2
# saves and loads the entire model
torch.save(model, PATH)
model = torch.load(PATH)
```
- Welcome
- fzf使用
- git回滚
- 安装gollum使用github作为wiki端
- 使用github的issue
- linux的脚本
- git冲突解决
- sphinx生成python文档
- 使用aria2作为下载客户端
- tmux使用
- anaconda的虚拟环境构建
- git commit message
- tensorflow指定GPU,限制显存
- pycharm professional
- 好用的命令行工具
- lrzsz使用
- 使用iTerm2的profile免密登陆远程主机
- quicklook 插件
- docker基本使用
- jupyter notebook转html和pdf
- jupyter-notebook几个有用命令
- mongodb安装
- pytorch载入与训练模型
- git覆盖分支
- Jetson TX2资源
- GitHub上fork的repo和上游分支保持一致的方法
- vscode调试前端代码
- github hosts
- git添加远程仓库
- 其它语言好用的库/包
- git强制拉取和强制提交
- chrome扩展发布
- mac的CPP lib
- vscode远程