计算CEloss时报错,不支持此数据类型
劫龍之叶伤 发布于2020-10 浏览:1014 回复:5
0
收藏

报错描述:

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]

如果有哪位前辈遇到过这个问题,还希望前辈们指导一下,一直在这里过不去。。。。

收藏
点赞
0
个赞
共5条回复 最后由七年期限回复于2020-11
#7七年期限回复于2020-11
#5 劫龍之叶伤回复
嗯嗯,谢谢。(现在搞好了)

0
#6残梦830回复于2020-11
#5 劫龍之叶伤回复
嗯嗯,谢谢。(现在搞好了)

CE_Loss是要pred和label都为Float32类型吗

0
#5劫龍之叶伤回复于2020-11
#4 189******30回复
类型怎么是int64?一般都用float32

嗯嗯,谢谢。(现在搞好了)

0
#4189******30回复于2020-11

类型怎么是int64?一般都用float32

0
#3189******30回复于2020-11

检查下输入数据形状、类型。

0
TOP
切换版块