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

model_dir = sys.argv[1]
new_model_dir = sys.argv[2]
S
SunAhong1993 已提交
7 8
paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
J
jiangjiajun 已提交
9
[inference_program, feed_target_names,
S
SunAhong1993 已提交
10
 fetch_targets] = paddle.static.load_inference_model(
J
jiangjiajun 已提交
11
     dirname=model_dir, executor=exe)
J
jiangjiajun 已提交
12 13

print(feed_target_names)
S
SunAhong1993 已提交
14
paddle.static.save_inference_model(
J
jiangjiajun 已提交
15 16 17 18 19 20
    dirname=new_model_dir,
    feeded_var_names=feed_target_names,
    target_vars=fetch_targets,
    executor=exe,
    main_program=inference_program,
    params_filename="__params__")