fluid mpi训练好的模型 离线预测时 报错Input Y(0)is not initialized
Created by: maosengshulei
为使您的问题得到快速解决,在建立Issue前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:
- 标题:简洁、精准描述您的问题,例如“最新预测库的API文档在哪儿 ”
- 版本、环境信息: 1)PaddlePaddle版本:请提供您的PaddlePaddle版本号(如1.1)或CommitID 2)CPU:预测若用CPU,请提供CPU型号,MKL/OpenBlas/MKLDNN/等数学库使用情况 3)GPU:预测若用GPU,请提供GPU型号、CUDA和CUDNN版本号 4)系统环境:请您描述系统类型、版本(如Mac OS 10.14),Python版本 -预测信息 1)C++预测:请您提供预测库安装包的版本信息,及其中的version.txt文件 2)CMake包含路径的完整命令 3)API信息(如调用请提供) 4)预测库来源:官网下载/特殊环境(如BCLOUD编译)
- 复现信息:如为报错,请给出复现环境、复现步骤
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
Thank you for contributing to PaddlePaddle. Before submitting the issue, you could search issue in the github in case that th If there is no solution,please make sure that this is an inference issue including the following details : System information -PaddlePaddle version (eg.1.1)or CommitID -CPU: including CPUMKL/OpenBlas/MKLDNN version -GPU: including CUDA/CUDNN version -OS Platform (eg.Mac OS 10.14) -Python version -Cmake orders -C++version.txt -API information To Reproduce Steps to reproduce the behavior Describe your current behavior Code to reproduce the issue Other info / logs
预测报错:
Traceback (most recent call last): File "dcn_infer.py", line 117, in <module> infer() File "dcn_infer.py", line 107, in infer fetch_list=[v.name for v in fetch_list]) File "/home/work/tools/paddle/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/executor.py", line 565, in run use_program_cache=use_program_cache) File "/home/work/tools/paddle/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/executor.py", line 642, in _run exe.run(program.desc, scope, 0, True, True, fetch_var_name) paddle.fluid.core.EnforceNotMet: Invoke operator mul error. Python Callstacks: File "/home/work/tools/paddle/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1654, in append_op attrs=kwargs.get("attrs", None)) File "/home/work/tools/paddle/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/home/work/tools/paddle/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/layers/nn.py", line 326, in fc "y_num_col_dims": 1}) File "/home/work/shulei/msd_dcn_v1/fluid_dcn.py", line 112, in DCN ctr_predict = fluid.layers.fc(input=ctr_fc,size=2, act="softmax", param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal(scale=1 / math.sqrt(ctr_fc.shape[1])))) File "dcn_infer.py", line 96, in infer ctr_predict, dura_predict ,words = DCN(args, feat_list.features) File "dcn_infer.py", line 117, in <module> infer() C++ Callstacks: Input Y(0)is not initialized at [/paddle/paddle/fluid/framework/operator.cc:1142]
预测部分代码: `args = parse_args()
place = fluid.CPUPlace()
inference_scope = fluid.core.Scope()
feat_list = dcn_reader.Msd_Feat_Builder(args.feat_list_path, args.bucket_statistic)
dataset = dcn_reader.MsdDataset(feat_list.features, args.data_path, args.mapping_path, args.seccate_map_path)
dataset.prepare_read()
test_reader = paddle.batch(dataset.infer(), batch_size=args.batch_size)
exe = fluid.Executor(place)
ctr_predict, dura_predict ,words = DCN(args, feat_list.features)
#[inference_program, feed_target_names, fetch_targets] = fluid.io.load_inference_model(executor=exe, dirname=args.model_path)
def if_exist(var):
return os.path.exists(os.path.join(args.model_path, var.name))
#[inference_program, feed_target_names, fetch_targets] = fluid.io.load_vars(executor=exe, dirname=args.model_path, predicate=if_exist)
fluid.io.load_vars(executor=exe, dirname=args.model_path, predicate=if_exist)
feeder = fluid.DataFeeder(feed_list=words, place=place)
fetch_list = [ctr_predict]
for batch_id, data in enumerate(test_reader()):
print data
predict = exe.run(feed=feeder.feed(data),
fetch_list=[v.name for v in fetch_list])
for i in range(len(data)):
print predict[0][i][1]
exe.close()`
模型部分代码:
`sparse_embed_seq = list(starmap(embedding_layer, zip(words[1 : 1 + sparse_input_length], sparse_attr_names, sparse_attr_size)))
concated = fluid.layers.concat(sparse_embed_seq + words[0:1] , axis=1)
last_deep_layer = deepnet(concated, args)
last_cross_layer = crossnet(concated, args)
top_fc_input = fluid.layers.concat([last_deep_layer, last_cross_layer], axis=1)
top_fc = fc_block(top_fc_input, np.fromstring(args.top_fc_block,dtype=int, sep="-").tolist())
ctr_fc = fluid.layers.fc(input=top_fc,size=128,act='relu',param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal(scale=1 / math.sqrt(top_fc.shape[1]))))
#duration_fc = fluid.layers.fc(input=top_fc,size=128,act='relu',param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal(scale=1 / math.sqrt(top_fc.shape[1]))))
ctr_predict = fluid.layers.fc(input=ctr_fc,size=2, act="softmax", param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal(scale=1 / math.sqrt(ctr_fc.shape[1]))))
dura_predict = fluid.layers.fc(input=ctr_fc,size=1, act=None, param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal(scale=1 / math.sqrt(ctr_fc.shape[1]))))`