实现mutitask的多分类任务报错
Created by: caijie12138
为使您的问题得到快速解决,在建立Issues前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:
- 标题:简洁、精准概括您的问题,例如“Insufficient Memory xxx" ”
- 版本、环境信息: 1)PaddlePaddle版本:1.7.2 2)CPU: 3)GPU:TITAN Xp ;CUDA Version 10.0.130; #define CUDNN_MAJOR 7 #define CUDNN_MINOR 6 #define CUDNN_PATCHLEVEL 4 4)系统环境:Linux version 4.15.0-65-generic (buildd@lgw01-amd64-006) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) Python 3.7.3
- 训练信息 1)单机单卡 2)12196MiB 3)Operator信息
- 复现信息:如为报错,请给出复现环境、复现步骤
- 问题描述:我希望能实现一个multitask的多分类器 按照tutorial里的情感分析的例子来修改代码:
报错信息如下: Traceback (most recent call last): File "goal_planning.py", line 24, in main(args,word_dict,train_data[1:],dev_data[1:]) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 309, in main train(args, params_dirname, word_dict, train_data, test_data) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 162, in train prediction_type = inference_program_type(word_dict,main_program_type,star_program) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 81, in inference_program_type net = convolution_net_for_type(data, dict_dim, CLASS_TYPE_DIM, EMB_DIM, HID_DIM) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 34, in convolution_net_for_type emb = fluid.embedding(input=data, size=[input_dim, emb_dim], is_sparse=True) File "/home/jiabin/anaconda3/lib/python3.7/site-packages/paddle/fluid/input.py", line 256, in embedding 'padding_idx': padding_idx File "/home/jiabin/anaconda3/lib/python3.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/jiabin/anaconda3/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2525, in append_op attrs=kwargs.get("attrs", None)) File "/home/jiabin/anaconda3/lib/python3.7/site-packages/paddle/fluid/framework.py", line 1880, in init self.desc.infer_shape(self.block.desc) paddle.fluid.core_avx.EnforceNotMet:
C++ Call Stacks (More useful to developers):
0 std::string paddle::platform::GetTraceBackString<std::string const&>(std::string const&, char const*, int) 1 paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int) 2 paddle::operators::LookupTableV2Op::InferShape(paddle::framework::InferShapeContext*) const 3 paddle::framework::OpDesc::InferShape(paddle::framework::BlockDesc const&) const
Python Call Stacks (More useful to users):
File "/home/jiabin/anaconda3/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2525, in append_op attrs=kwargs.get("attrs", None)) File "/home/jiabin/anaconda3/lib/python3.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/jiabin/anaconda3/lib/python3.7/site-packages/paddle/fluid/input.py", line 256, in embedding 'padding_idx': padding_idx File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 34, in convolution_net_for_type emb = fluid.embedding(input=data, size=[input_dim, emb_dim], is_sparse=True) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 81, in inference_program_type net = convolution_net_for_type(data, dict_dim, CLASS_TYPE_DIM, EMB_DIM, HID_DIM) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 162, in train prediction_type = inference_program_type(word_dict,main_program_type,star_program) File "/home/jiabin/caijie/Dialog_recommendation/goal_multitask/train_cnn_classifier.py", line 309, in main train(args, params_dirname, word_dict, train_data, test_data) File "goal_planning.py", line 24, in main(args,word_dict,train_data[1:],dev_data[1:])
Error Message Summary:
Error: Input(Ids) of LookupTableV2Op should not be null. [Hint: Expected ctx->HasInput("Ids") == true, but received ctx->HasInput("Ids"):0 != true:1.] at (/paddle/paddle/fluid/operators/lookup_table_v2_op.cc:33) [operator < lookup_table_v2 > error]
代码片段: def inference_program_topic(word_dict, main_program, startup_program): dict_dim = len(word_dict) with fluid.program_guard(main_program, startup_program): data = fluid.data(name="words_topic", shape=[None], dtype="int64", lod_level=1) net = convolution_net_for_type(data, dict_dim, CLASS_TOPIC_DIM, EMB_DIM, HID_DIM) return net
def inference_program_type(word_dict,main_program, startup_program): dict_dim = len(word_dict) with fluid.program_guard(main_program, startup_program): data = fluid.data(name="words_type", shape=[None], dtype="int64", lod_level=1) net = convolution_net_for_type(data, dict_dim, CLASS_TYPE_DIM, EMB_DIM, HID_DIM) return net def train_program_topic(prediction,main_program, startup_program): with fluid.program_guard(main_program, startup_program): label = fluid.data(name="label_topic", shape=[None, 1], dtype="int64") cost = fluid.layers.cross_entropy(input=prediction, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=prediction, label=label) return [avg_cost, accuracy]
def train_program_type(prediction,main_program, startup_program): with fluid.program_guard(main_program, startup_program): label = fluid.data(name="label_type", shape=[None, 1], dtype="int64") cost = fluid.layers.cross_entropy(input=prediction, label=label) avg_cost = fluid.layers.mean(cost) accuracy = fluid.layers.accuracy(input=prediction, label=label) return [avg_cost, accuracy]
Thank you for contributing to PaddlePaddle. Before submitting the issue, you could search issue in the github in case that there was a similar issue submitted or resolved before. If there is no solution,please make sure that this is a training 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) -Other imformation: Distriuted training/informantion of operator/ Graphics card storage To Reproduce Steps to reproduce the behavior Describe your current behavior Code to reproduce the issue Other info / logs