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)
打印结果: