Pytorch way to preserve the two models

Pytorch way to preserve the two models

Black _7e1b attention
13 words read 5,907

Save only the model parameters

# 保存
torch.save(model.state_dict(), '\parameter.pkl')
# 加载
model = TheModelClass(...)
model.load_state_dict(torch.load('\parameter.pkl'))

Preserved model

# 保存
torch.save(model, '\model.pkl')
# 加载
model = torch.load('\model.pkl')
1 person thumbs up
"Small gifts around and Jane book to my attention."
Appreciate the support no one appreciates support what
Total assets 2 (about 0.20 yuan) wrote a total of 1058 words get 7 Like a total of three fans
attention
! [Insert Picture description here] (https://img-blog.csdnimg.cn/20200227095111901.jpg)
Published 258 original articles · won praise 7 · views 20000 +

Guess you like

Origin blog.csdn.net/kyle1314608/article/details/104530386