判斷兩個權重文件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

浙公網安備 33010602011771號