*** FileNotFoundError: [Errno 2] No such file or directory: '~/DeepLearning/.../XXXXXnet.pth'
對應的代碼爲:
weight_path = '~/DeepLearning/......'
save_path = os.path.join(weight_path, save_filename)
錯誤原因:
這裏是python不是linux,~在Python裏不能直接代表主目錄,所以要用絕對路徑。
更改結果:
weight_path = '/home/username/DeepLearning/......'
save_path = os.path.join(weight_path, save_filename)
(Pdb) network.load_state_dict(torch.load(save_path))
(Pdb) exit()
解決