打印模型结构并保存到txt中
import torch
pthfile = r'E:/pycharm_code/unet-pytorch-main/unet-pytorch-main/logs/Epoch1-Total_Loss0.4523-Val_Loss0.0966.pth'
net = torch.load(pthfile, map_location='cpu')
# net = dict(net)
with open('test.txt', 'a') as file0:
print(net, file=file0)
本文来自博客园,作者:海_纳百川,转载请注明原文链接:https://www.cnblogs.com/chentiao/p/16673041.html,如有侵权联系删除