加载model文件夹里面的训练模型参数时出错
Carl-Lei opened this issue · 4 comments
@lfz
我在测试时,加载您提供的模型'classifier_param':'./model/classifier.ckpt'时出错,错误提示是
checkpoint = torch.load('./model/classifier.ckpt')
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py", line 303, in load
return _load(f, map_location, pickle_module)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py", line 469, in _load
result = unpickler.load()
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 16: ordinal not in range(128)
请问,该怎么解决啊?谢谢!
If you use a python 3 and the latest PyTorch you can read the classifier by specifying additional encoding parameter that escapes Unicode bytes:
classifier_ckpt = torch.load('model/classifier.ckpt', encoding= 'unicode_escape')
More details on this you can find on PyTorch documentation page
.