Skip to content

关于windows下使用softmax_with_cross_entropy报错 #39828

@xu-peng-7

Description

@xu-peng-7
  • 标题: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')
    

后损失函数运行即正常。

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions