loss_class = nn.NLLLoss()

loss_class_test = loss_class(class_prd,labels)

报错:RuntimeError: 0D or 1D target tensor expected, multi-target not supported

print class_prd.shape, labels.shape 发现分别为

torch.Size([64, 3]) #三分类问题

torch.Size([64, 1])

labels.shape维度应为[64]

解决:loss_class_test = loss_class(class_prd,labels.squeeze(dim=1))

RuntimeError: 0D or 1D target tensor expected, multi-target not supported解决相关推荐

  1. 1D target tensor expected, multi-target not supported

    pytorch 交叉熵损失计算时报错了: 1D target tensor expected, multi-target not supported if __name__ == '__main__' ...

  2. 解决pytorch CrossEntropyLoss报错RuntimeError: 1D target tensor expected, multi-target not supported

    解决方法 CrossEntropyLoss(预测值,label)需要的输入维度是: 有batch时,预测值维度为2,size为[ batch_size, n ]时,label的维度是1,size为[ ...

  3. 成功解决:计算交叉熵lossFunction报错“1D target tensor expected, multi-target not supported”的解决办法

    https://blog.csdn.net/weixin_43429591/article/details/107047895

  4. RuntimeError: non-empty 3D or 4D input tensor expected but got ndim: 4

    在使用pytorch训练模型时报,以下错误: RuntimeError: non-empty 3D or 4D input tensor expected but got ndim: 4 当把一个空的 ...

  5. 使用sklearn训练模型出现【DataConversionWarning: A column-vector y was passed when a 1d array was expected】

    问题 DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change t ...

  6. DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the

    使用scikit时报的错 参考链接: 报错代码 解决方案 参考链接: https://blog.csdn.net/weixin_39223665/article/details/81268741 报错 ...

  7. Bean named ‘Target‘ is expected to be of type ‘com.itheima.aop.Target‘ but was actually of type ‘com

    这是一个接口实现方法 package com.itheima.aop;public class Target implements TargetInterface{public void save() ...

  8. Target version not match, you can specify the target version in vueCompilerOptions.target in tsconfi

    Target version not match, you can specify the target version in vueCompilerOptions.target in tsconfi ...

  9. [ShapeInferenceError] Mismatch between number of source and target dimensions. Source=1 Target=0

    Pytorch转ONNX模型正常,但使用onnxruntime加载onnx模型,会输出错误: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ON ...

最新文章

  1. C++ cctype定义的函数 - 学习笔记(7)
  2. SQL Server 2005:你应该知道的13件事情
  3. Leaflet中加载Geoserver发布的WMS服务显示地图
  4. cad移动时捕捉不到基点_硬盘或移动硬盘认不到时,应该怎样进行故障的检测才正确...
  5. spring批量写入mysql数据库_MyBatis-spring和spring JDBC批量插入Mysql的效率比较
  6. 22年前,100万买入谷歌原始股,奥尼尔的股份如今市值多少?
  7. Zoom 5.1.2及旧版本在 Win7 上的 DLL 劫持漏洞分析
  8. ASP.NET 分页技术
  9. 商场无线网络方案设计
  10. 【解决】WPS 2019 Windows版如何更换序列号
  11. 修改html颜色代码,JavaScript实现更改网页背景与字体颜色的方法
  12. margin与padding的区别
  13. 美国达高特DAKOTA超声波测厚仪检测仪维修
  14. 辛普森复合求积公式matlab,MATLAB数值分析实验二(复合梯形、辛普森和龙贝格求积,以及二重积分计算等).doc...
  15. 计算机网络安全教程第三版课后答案
  16. 点击按钮获取listview网上数据
  17. 芯片丨美光最新财报电话会议透露了三个重要观点
  18. 计算机系统集成双代号网络图讲解,系统集成项目管理工程师双代号时标网络图知识解读...
  19. 神操作!树莓派上运行滴滴开源的Logi-KafkaManager,你见过没?
  20. 监控服务(新增)错误日志脚本并发送DingDing|邮件通知模板

热门文章

  1. 大疆安卓MSDK二次开发wifi调试
  2. 零基础学素描nbsp;高考素描头像未…
  3. Echarts简介与入门
  4. js包含字符串判断(js判断字符串包含某个字符串)
  5. AI征战奥林匹克,科技奥运未来可期
  6. 昆明学院计算机网络期末试题,昆明学院校园网的组建剖析.doc
  7. iOS 关闭点击状态栏UITableView 滚动到顶部
  8. java logging包_Java logging整理
  9. 有序分类和连续变量所对应的相关性
  10. Ubuntun20.04安装wifi驱动