IO 问题
Created by: zhao181
exe.run不能指定program参数, 指定就报错, 代码如下:
with fluid.program_guard(main_prog, startup_prog): data = fluid.layers.data(name="img", shape=[64, 784], append_batch_size=False) w= fluid.layers.create_parameter(shape=[784, 200], dtype='float32', name='fc_w') b= fluid.layers.create_parameter(shape=[200], dtype='float32', name='fc_b') hidden_w = fluid.layers.matmul(x=data, y=w) hidden_b = fluid.layers.elementwise_add(hidden_w, b) iteration=fluid.layers.create_global_var(shape=(1,), value=0,dtype="int64",persistable=True,name="iterations")
exe = fluid.Executor( fluid.CPUPlace()) exe.run(startup_prog)
reset_dict=fluid.io.load_program_state(model_path="./my_paddle_params/fc",) fluid.io.set_program_state(main_prog,reset_dict) var_list=fluid.io.get_program_parameter(main_prog)
results1=exe.run(fetch_list=var_list) new_program=fluid.Program() results2=exe.run(program=new_program,fetch_list=var_list) results3=exe.run(program=main_prog,fetch_list=var_list)
我将参数restore到main_program中了, 然后通过run查看参数将ndarray存储在result中, program设置为main_program, 但是结果会报错(result3那行);
如果将program设置为空(result1那行) 或者设置为一个新生成的program(result2那行), 则结果正确, 请问这是怎么回事啊? 请大神解答一下。