当前位置:网站首页>Instructions for torch use
Instructions for torch use
2022-07-20 09:27:00 【Ruyi's small home】
1.torch.load_state_dict() Function Usage Summary
stay Pytorch After building a model in , Generally, pre training is needed to load the weight .torch.load_state_dict() The function is used to load the pre trained parameter weights into the new model , The operation mode is as follows :
sd_net = torchvision.models.resnte50(pretrained=False)
sd_net.load_state_dict(torch.load('*.pth'), strict=True)
The focus of this blog post is attribute strict; When strict=True, It is required that the key value of the pre training weight level should be completely consistent with the name of the weight level in the newly constructed model ; If the newly built model is partially fine tuned in the number of layers , The above code will report an error : say key No correspondence .
here , If we adopt strict=False Can perfectly solve this problem . That is to say , The key value of the matching layer in the training weight and the newly constructed network is used , If there is no, it will be initialized by default .
2.class torch.optim.lr_scheduler.CosineAnnealingLR
torch.optim.lr_scheduler.CosineAnnealingLR(optimizer,T_max,eta_min=0,last_epoch=-1)
T_max: Because the learning rate changes periodically , This parameter represents the 1/2, in other words , The initial learning rate is a, after 2*T_max After time , After a cycle of changes, the learning rate is still a.
eta_min: Represents the minimum variable learning rate , The default is 0
边栏推荐
猜你喜欢
随机推荐
Opencv image bit operation
r-cnn
深度学习在组织切片上的应用
Create and manage databases using SQL statements
论文解读《Protein subcellular localization based on deep image features and criterion learning strategy》
Ngnix详解(2)安装使用
opencv学习(4)之色彩转换 处理 图像绘制 随机数
【论文导读‘‘】Causal Protein-Signaling Networks Derived from Multiparameter Single-Cell Data
LSTM 股价预测pytorch
Light simulation applet
mysql45讲阅读笔记全局锁和表锁(六)
Détails de ngnix (2) pour l'installation et l'utilisation
Power learning (1) - power system test
r-cnn
膨胀卷积(空洞卷积)
[vscode advanced preliminary] vscode debug
【Mindspore学习】【多标签分类】是否有图像多标签分类样例
病理组织切片热图显示(浮于组织切片表面)
opencv引发的vector异常
opencv(1)之图像读取,显示,保存,色彩转换