fluid.load()接口加载失败
Created by: Haijunlv
在paddle1.8.3的情况下,训练完成后用fluid.save()保存出一个包含pdmodel, pdopt, pdparms三个文件的checkpoint。 用这个checkpoint恢复训练时如果自定义好网络结构,再fluid.load(xxx),加载成功 如果用pdmodel来反序列化出program,再加载fluid.load(xxxx), 则加载失败。 失败日志:
单测脚本:
import paddle.fluid as fluid
m_dir = 'export_model/'
def read_program(filepath):
prog = fluid.Program()
with open(filepath, 'rb') as fin:
prog = prog.parse_from_string(fin.read())
return prog
#train_prog = read_program(f'{m_dir}/train.program')
train_prog = read_program(f'{m_dir}/checkpoint/checkpoint.pdmodel')
exe = fluid.Executor(fluid.CPUPlace())
fluid.io.load(train_prog, f'{m_dir}/checkpoint/checkpoint', exe)