报错描述:
NotFoundError: Operator cross_entropy2 does not have kernel for data_type[int64_t]:data_layout[ANY_LAYOUT]:place[CUDAPlace(0)]:library_type[PLAIN].
[Hint: Expected kernel_iter != kernels.end(), but received kernel_iter == kernels.end().] at (/paddle/paddle/fluid/imperative/prepared_operator.cc:118)
[operator < cross_entropy2 > error]
数据格式:
The Data_id has loaded!
The Data_sets has loaded!
The Environment is CUDAPlace(0)!
Train start-------
Epoch: 1
[2, 1]
name generated_var_1, dtype: VarType.INT64 shape: [2, 1] lod: {}
dim: 2, 1
layout: NCHW
dtype: int64_t
data: [3 13]
[2, 1]
name tmp_32, dtype: VarType.INT64 shape: [2, 1] lod: {}
dim: 2, 1
layout: NCHW
dtype: int64_t
data: [45 23]
问题描述:
输入已经都是[N, 1]了,但是传入fluid.layers.cross_entropy(input=y_pred, label=y) ,还是会报错。
报错内容:
----> 1 train(2, batch_size=2, ags=True)
in train(epoches, batch_size, eval_iters, save_iters, ags)
57
58
---> 59 loss = fluid.layers.cross_entropy(input=y_pred, label=y) # 数据异常---无法开始训练
60 avg_loss = fluid.layers.mean(loss)
61
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/loss.py in cross_entropy(input, label, soft_label, ignore_index)
239 """
240 if not soft_label:
--> 241 return cross_entropy2(input, label, ignore_index)
242
243 if in_dygraph_mode():
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/loss.py in cross_entropy2(input, label, ignore_index)
260 if in_dygraph_mode():
261 loss, _, _ = core.ops.cross_entropy2(input, label, 'ignore_index',
--> 262 ignore_index)
263 return loss
264
NotFoundError: Operator cross_entropy2 does not have kernel for data_type[int64_t]:data_layout[ANY_LAYOUT]:place[CUDAPlace(0)]:library_type[PLAIN].
[Hint: Expected kernel_iter != kernels.end(), but received kernel_iter == kernels.end().] at (/paddle/paddle/fluid/imperative/prepared_operator.cc:118)
[operator < cross_entropy2 > error]
如果有哪位前辈遇到过这个问题,还希望前辈们指导一下,一直在这里过不去。。。。
赞
CE_Loss是要pred和label都为Float32类型吗
嗯嗯,谢谢。(现在搞好了)
类型怎么是int64?一般都用float32
检查下输入数据形状、类型。