DSB2017 icon indicating copy to clipboard operation
DSB2017 copied to clipboard

加载model文件夹里面的训练模型参数时出错

Open Carl-Lei opened this issue 6 years ago • 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) 请问,该怎么解决啊?谢谢!

Carl-Lei avatar Aug 02 '18 01:08 Carl-Lei

你用的是python3?

BR. -飞跃

On Aug 2, 2018, at 09:26, Carl-Lei [email protected] wrote:

@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) 请问,该怎么解决啊?谢谢!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

zhaifly avatar Aug 02 '18 02:08 zhaifly

@zhaifly 是的,这个要怎么解决呢

Carl-Lei avatar Aug 02 '18 05:08 Carl-Lei

换python2

BR. -飞跃

On Aug 2, 2018, at 13:44, Carl-Lei [email protected] wrote:

@zhaifly 是的,这个要怎么解决呢

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

zhaifly avatar Aug 02 '18 07:08 zhaifly

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.

bohdanchap avatar Apr 11 '20 09:04 bohdanchap