RuntimeError: 0D or 1D target tensor expected, multi-target not supported解决
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解决相关推荐
- 1D target tensor expected, multi-target not supported
pytorch 交叉熵损失计算时报错了: 1D target tensor expected, multi-target not supported if __name__ == '__main__' ...
- 解决pytorch CrossEntropyLoss报错RuntimeError: 1D target tensor expected, multi-target not supported
解决方法 CrossEntropyLoss(预测值,label)需要的输入维度是: 有batch时,预测值维度为2,size为[ batch_size, n ]时,label的维度是1,size为[ ...
- 成功解决:计算交叉熵lossFunction报错“1D target tensor expected, multi-target not supported”的解决办法
https://blog.csdn.net/weixin_43429591/article/details/107047895
- 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 当把一个空的 ...
- 使用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 ...
- 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 报错 ...
- 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() ...
- 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 ...
- [ShapeInferenceError] Mismatch between number of source and target dimensions. Source=1 Target=0
Pytorch转ONNX模型正常,但使用onnxruntime加载onnx模型,会输出错误: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ON ...
最新文章
- C++ cctype定义的函数 - 学习笔记(7)
- SQL Server 2005:你应该知道的13件事情
- Leaflet中加载Geoserver发布的WMS服务显示地图
- cad移动时捕捉不到基点_硬盘或移动硬盘认不到时,应该怎样进行故障的检测才正确...
- spring批量写入mysql数据库_MyBatis-spring和spring JDBC批量插入Mysql的效率比较
- 22年前,100万买入谷歌原始股,奥尼尔的股份如今市值多少?
- Zoom 5.1.2及旧版本在 Win7 上的 DLL 劫持漏洞分析
- ASP.NET 分页技术
- 商场无线网络方案设计
- 【解决】WPS 2019 Windows版如何更换序列号
- 修改html颜色代码,JavaScript实现更改网页背景与字体颜色的方法
- margin与padding的区别
- 美国达高特DAKOTA超声波测厚仪检测仪维修
- 辛普森复合求积公式matlab,MATLAB数值分析实验二(复合梯形、辛普森和龙贝格求积,以及二重积分计算等).doc...
- 计算机网络安全教程第三版课后答案
- 点击按钮获取listview网上数据
- 芯片丨美光最新财报电话会议透露了三个重要观点
- 计算机系统集成双代号网络图讲解,系统集成项目管理工程师双代号时标网络图知识解读...
- 神操作!树莓派上运行滴滴开源的Logi-KafkaManager,你见过没?
- 监控服务(新增)错误日志脚本并发送DingDing|邮件通知模板