_copy_param_info_from should be invoked with two program, with represent the same topology
Created by: Angus07
train_prog = fluid.default_main_program()
startup_prog = fluid.default_startup_program()
with fluid.program_guard(train_prog, startup_prog):
with fluid.unique_name.guard():
lm = LanguageModel(config, config.vocab_size)
src = layers.data(name="src",
shape=[-1, config.max_input_length + 2, 1],
dtype='int64')
label = layers.data(name="label", shape=[-1, 1], dtype='int64')
embedded = lm.embeder(src)
y = fluid.layers.cast(label, dtype='float32')
init_hidden = fluid.layers.expand(x=y, expand_times=[1, 700])
out1, out2 = lm.net(embedded, init_hidden=init_hidden)
forward_target = src[:, 1:, :]
forward_target.stop_gradient = True
backward_target = src[:, 1:, :]
backward_target.stop_gradient = True
loss = lm.loss(out1, out2, forward_target, backward_target, config.max_input_length + 2)
lm.optmize(loss)
reader = fluid.io.PyReader(feed_list=[src, label],
capacity=20,
iterable=True,
return_list=True)
eval_reader = fluid.io.PyReader(feed_list=[src, label],
capacity=20,
iterable=True,
return_list=True)
infer_program = train_prog.clone(for_test=True)
exe.run(startup_prog)
============ 代码如上,提示在infer_program = train_prog.clone(for_test=True)这句报错了,错误信息如标题。 我看了一下模型库的例子,好像结构是类似的,为什么会报这个错误呢?用法上有问题吗?