文档学习中的代码报错:operator < lookup_table > error
Created by: skywalk163
环境: aistudio 高级版环境, paddlepaddle1.7 python3.7 出错代码位于:文档1.7-典型案例-自然语言处理-情感分析-构造训练器 代码部分: https://www.paddlepaddle.org.cn/documentation/docs/zh/user_guides/nlp_case/understand_sentiment/README.cn.html 按文档手册顺序执行到构造训练器这里: exe = fluid.Executor(place) prediction = inference_program(word_dict) [avg_cost, accuracy] = train_program(prediction)#训练程序 sgd_optimizer = optimizer_func()#训练优化函数 sgd_optimizer.minimize(avg_cost)
结果出现错误,报错信息是: --------------------------------------------------------------------------EnforceNotMet Traceback (most recent call last) in 4 5 exe = fluid.Executor(place) ----> 6 prediction = inference_program(word_dict) 7 [avg_cost, accuracy] = train_program(prediction)#训练程序 8 sgd_optimizer = optimizer_func()#训练优化函数 in inference_program(word_dict) 5 name="words", shape=[None], dtype="int64", lod_level=1) 6 dict_dim = len(word_dict) ----> 7 net = convolution_net(data, dict_dim, CLASS_DIM, EMB_DIM, HID_DIM) 8 # net = stacked_lstm_net(data, dict_dim, CLASS_DIM, EMB_DIM, HID_DIM, STACKED_NUM) 9 return net in convolution_net(data, input_dim, class_dim, emb_dim, hid_dim) 4 def convolution_net(data, input_dim, class_dim, emb_dim, hid_dim): 5 emb = fluid.layers.embedding( ----> 6 input=data, size=[input_dim, emb_dim], is_sparse=True) 7 conv_3 = fluid.nets.sequence_conv_pool( 8 input=emb, 中间省略部分。。。。。 Error Message Summary: Error: ShapeError: The last dimensions of the 'Ids' tensor must be 1. But received Ids's last dimensions = -1, Ids's shape = [-1]. [Hint: Expected ids_dims[ids_rank - 1] == 1, but received ids_dims[ids_rank - 1]:-1 != 1:1.] at (/paddle/paddle/fluid/operators/lookup_table_op.cc:51) [operator < lookup_table > error]
希望能得到解决,谢谢。 跟这个的报错一样,而且我的这个应该更好复现 https://github.com/PaddlePaddle/Paddle/issues/21221