1.保存模型參數(gen-我本身的模型名字)python
torch.save(self.gen.state_dict(), os.path.join(self.gen_save_path, 'gen_%d.pth'%step))
2.加載模型參數spa
self.gen.load_state_dict(torch.load(os.path.join(self.gen_save_path, 'gen_%d.pth'%step),map_location='cpu'))
3.打印查看模型參數code
pthfile = r'./trained_models\64\models\gen_97000.pth' net = torch.load(pthfile,map_location='cpu') print(net)
打印結果:blog