-
Couldn't load subscription status.
- Fork 5.9k
Closed
Labels
Description
-
标题:tensor holds the wrong type,desires to be int64_t 报错信息
-
版本、环境信息:
1)PaddlePaddle版本:PaddlePaddle2.2.2 -
问题描述:windows 10系统下,由于数据默认的类型会发生修改,导致出现使用softmax_with_cross_entropy出现tensor holds the wrong type,desires to be int64_t 报错。建议在所有使用cross_entropy的地方增加类型转换,包括paddlenlp.metrics.Perplexity()函数中。
-
但是在Linux环境中和AIstudio中运行正常。我重写了损失函数,添加
-
预测 = paddle.to_tensor(预测, dtype='float32') 标签 = paddle.to_tensor(标签, dtype='int64')
后损失函数运行即正常。