diff --git a/python/paddle/fluid/dygraph/checkpoint.py b/python/paddle/fluid/dygraph/checkpoint.py index 6bda09966949fbba7dc89343e8d60ea7e047dc8c..a51c431c515f23c5e0ec10de71ee8e65b83c492a 100644 --- a/python/paddle/fluid/dygraph/checkpoint.py +++ b/python/paddle/fluid/dygraph/checkpoint.py @@ -132,7 +132,7 @@ def load_dygraph(model_path, keep_name_table=False): with open(params_file_path, 'rb') as f: para_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') if not keep_name_table and "StructuredToParameterName@@" in para_dict: del para_dict["StructuredToParameterName@@"] @@ -141,6 +141,6 @@ def load_dygraph(model_path, keep_name_table=False): if os.path.exists(opti_file_path): with open(opti_file_path, 'rb') as f: opti_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') return para_dict, opti_dict diff --git a/python/paddle/fluid/io.py b/python/paddle/fluid/io.py index 7e65060829a4fb26877bf98aa8e9662455fecb90..792d0f7bf512c97a700b14be7c0113ac1e1b483b 100644 --- a/python/paddle/fluid/io.py +++ b/python/paddle/fluid/io.py @@ -1696,7 +1696,7 @@ def load(program, model_path, executor=None, var_list=None): executor._default_executor) with open(parameter_file_name, 'rb') as f: load_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') for v in parameter_list: assert v.name in load_dict, \ "Can not find [{}] in model file [{}]".format( @@ -1717,7 +1717,7 @@ def load(program, model_path, executor=None, var_list=None): with open(opt_file_name, 'rb') as f: load_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') for v in optimizer_var_list: assert v.name in load_dict, \ "Can not find [{}] in model file [{}]".format( @@ -1842,13 +1842,13 @@ def load_program_state(model_path, var_list=None): with open(parameter_file_name, 'rb') as f: para_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') opt_file_name = model_prefix + ".pdopt" if os.path.exists(opt_file_name): with open(opt_file_name, 'rb') as f: opti_dict = pickle.load(f) if six.PY2 else pickle.load( - f, encoding='bytes') + f, encoding='latin1') para_dict.update(opti_dict)