问题描述: Windows10,anaconda,python3.6
相同的python代码,在linux运行时提示:
/usr/local/lib/python2.7/dist-packages/torch/serialization.py:255:UnicodeWarning: Unicode unequal comparison failed to convert both arguments toUnicode - interpreting them as being unequal
iforiginal_source != current_source:
/usr/local/lib/python2.7/dist-packages/torch/serialization.py:286:SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' haschanged. you can retrieve the original source code by accessing the object'ssource attribute or set `torch.nn.Module.dump_patches = True` and use the patchtool to revert the changes.
然后把Linux运行得到的 .t7文件放到Windows下运行,报错:
Traceback (most recent call last):
&n

相同Python代码在Linux运行时出现UnicodeWarning和SourceChangeWarning,导致.t7文件在Windows下加载报UnicodeDecodeError。问题根源在于Linux Python2.7默认编码为ASCII,而Windows Python3.6使用UTF-8。解决方法是在Linux环境下修改文件编码为UTF-8或在Python脚本中设置编码。
最低0.47元/天 解锁文章
5130

被折叠的 条评论
为什么被折叠?



