爽歪歪666
不以物喜,不以己悲,努力才是永恒的主题。

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)

打印结果:

 

 

posted on 2019-12-12 16:54  爽歪歪666  阅读(2486)  评论(0编辑  收藏  举报