一文梳理pytorch保存和重载模型参数攻略
查看当前模型结构与参数值
print(model.state_dict)
# 输出定义的网络结构
print(model.state_dict())
# 输出所有参数名和参数值
输出如下:
<bound method Module.state_dict of Digit(
(conv1): Conv1d(2, 10, kernel_size=(5,), stride=(1,))
(conv3): Conv1d(5, 20, kernel_size=(3,), stride=(1,))
(fc6): Linear(in_features=2480, out_features=500, bias=True)
(drop8): Dropout(p=0.5, inplace=False)
(fc9): Linear(in_features=500, out_features=1, bias=True)
)>
OrderedDict([('conv1.weight', tensor([[[-0.2759, 0.1526, 0.2299, -0.2617, -0.0128],
[ 0.2975, -0.1635, -0.1661, 0.1830, 0.1413]],
[[ 0.0064, -0.1616, -0.2967, <