判断两个权重文件pth是否相同
方法1: 先加载两个pth:
weights1 = torch.load("A.pth") weights2 = torch.load("A.pth")
查看keys: weights1.keys(),可能有state_dict, optimizer等,
通过字符串格式化,str(weights1['state_dict'])==str(weights2['state_dict']),即可逐项比较;
方法2: 比较md5sum A.pth和md5sum B.pth,返回的序列是否一致
参考:https://blog.csdn.net/weixin_40519680/article/details/129533896
人生苦短,何不用python