merge_params.py 501 字节
Newer Older
J
jiangjiajun 已提交
1 2 3 4 5 6 7
import paddle.fluid as fluid
import sys

model_dir = sys.argv[1]
new_model_dir = sys.argv[2]
exe = fluid.Executor(fluid.CPUPlace())
[inference_program, feed_target_names,
J
jiangjiajun 已提交
8 9
 fetch_targets] = fluid.io.load_inference_model(
     dirname=model_dir, executor=exe)
J
jiangjiajun 已提交
10 11

print(feed_target_names)
J
jiangjiajun 已提交
12 13 14 15 16 17 18
fluid.io.save_inference_model(
    dirname=new_model_dir,
    feeded_var_names=feed_target_names,
    target_vars=fetch_targets,
    executor=exe,
    main_program=inference_program,
    params_filename="__params__")