首页 > 其他 > 详细

pytorch_模型参数-保存,加载,打印

时间:2019-12-12 17:13:41      阅读:529      评论:0      收藏:0      [点我收藏+]

1.保存模型参数(gen-我自己的模型名字)

torch.save(self.gen.state_dict(), os.path.join(self.gen_save_path, ‘gen_%d.pth‘%step)) 

2.加载模型参数

self.gen.load_state_dict(torch.load(os.path.join(self.gen_save_path, ‘gen_%d.pth‘%step),map_location=‘cpu‘))

3.打印查看模型参数

    pthfile = r‘./trained_models\64\models\gen_97000.pth‘
    net = torch.load(pthfile,map_location=‘cpu‘)
    print(net)

打印结果:

技术分享图片

 

 

pytorch_模型参数-保存,加载,打印

原文:https://www.cnblogs.com/shuangcao/p/12030206.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!