File to load trained model

when i load trained mode(trained in GPU,python3.6) in another computer(only cpu,python 2.7),but the error show as follow.And i add the '#!/usr/bin/env python# --coding:utf-8 --‘at the top.’

so why the bug at line 388 when i load the trained model?
Traceback (most recent call last):
File “”, line 388, in
pre_train_model_mask = torch.load(model_dir_mask,map_location=lambda storage, loc: storage)
File “/usr/local/lib/python2.7/dist-packages/torch/”, line 303, in load
return _load(f, map_location, pickle_module)
File “/usr/local/lib/python2.7/dist-packages/torch/”, line 469, in _load
result = unpickler.load()
File “/home/chxx/predict/”, line 47
SyntaxError: Non-ASCII character ‘\xe7’ in file /home/chxx/predict/ on line 47, but no encoding declared; see for details

As it says, it has to do with encoding not PyTorch. Try adding below line (or other alternatives as mentioned in the given link):

# -*- coding: utf-8 -*-
1 Like