MindSpore报ValueError:`x rank` in `NLLLoss` should be int and must in [1, 2], but got `4` with type

本文档详细记录了在使用MindSpore 1.6.0版本时遇到的`ValueError: x rank` in `NLLLoss` should be int and must in [1, 2], but got `4`的问题。问题源于MindSpore当前仅支持(N,C)形状的NLLLoss,而不支持(N,C,d1,d2,...,dK)。解决方案包括用户自行封装,官方将在后续版本考虑此需求。同时,提供了错误定位的步骤和NLLLoss的参考资料。" 99679178,8746089,使用BeautifulSoup解析HTML:步骤与案例,"['前端开发', '网页解析', '数据抓取', 'Python工具', 'BeautifulSoup']
摘要由CSDN通过智能技术生成

1 报错描述

1.1 系统环境

Hardware Environment(Ascend/GPU/CPU): GPU
Software Environment:
– MindSpore version (source or binary): 1.6.0
– Python version (e.g., Python 3.7.5): 3.7.6
– OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic
– GCC/Compiler version (if compiled from source):

1.2 基本信息

1.2.1 脚本

根据标杆torch算子NLLLoss的用例,编写输入为(N, C, d1, d2)的用例,脚本如下:

 01 loss = nn.NLLLoss()
 02 input = torch.randn(5, 4, 8, 8)
 03 m = nn.LogSoftmax(dim=1)
 04 target = torch.empty(5, 8, 8, dtype=torch.long).random
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值