1. 背景介绍

在训练语义分割模型时,出现以下错误:

RuntimeError: Sizes of tensors must match except in dimension 1. Got 61 and 60 in dimension 2

2. 错误产生原因

在模型中有以下操作:torch.cat(x, y)

当x, y的尺寸不一致时,就会出现以上错误。

进行单步调试,发现我的错误是因为图像山采样和下采样后,由于取整的方式不一样,导致的x、y的尺寸不一致。

3. 解决方法

方法1:在图像输入时,宽和高最好是32的整数倍,就不会出现取整的问题。

方法2:把x、y resize到相同的尺寸。

RuntimeError: Sizes of tensors must match except in dimension 1. Got 61 and 60 in dimension 2相关推荐

  1. RuntimeError: Sizes of tensors must match except in dimension 2. Got 5 and 4

    调试代码的时候,遇到***RuntimeError: Sizes of tensors must match except in dimension 2. Got 5 and 4*** 这个问题, 解 ...

  2. Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.

    使用Pytorch_Geometric(PyG)时构建DataLoader,从DataLoader获取样本Batch时报错:RuntimeError: Sizes of tensors must ma ...

  3. 记录解决RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 27 but got size

    问题描述 在做目标检测服务过程中,将yolov7模型通过flask打包成预测服务API,此次训练的图像输入大小是1280,输入预测图片是如果图像大于1280则预测成功,小于1280则报RuntimeE ...

  4. Sizes of tensors must match except in dimension 1. Got 61 and 60 in dimension 2

    1. 背景介绍       在训练编码解码网络模型时,出现以下错误: RuntimeError: Sizes of tensors must match except in dimension 1. ...

  5. 模型预测过程中报错 RuntimeError: Sizes of tensors must match except in dimension 1.

    具体报错如上所示 问题背景 用gradio库写了一个YOLOv7检测logo的demo,上传图片之后报错如上. 解决方法 一开始我以为是类别数不对应的问题,然而并不是. 实际上是一个非常粗心的错误,原 ...

  6. Sizes of tensors must match except in dimension 1. Expected size 24 but got size 25 for tensor numbe

    在做图像分割的时候遇到了错误,错误如下: File "D:/segmentation/Pytorch-UNet-master/train.py", line 193, in < ...

  7. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1.

    最近在修改模型不支持的算子后,由于对模型的效果产生了影响,所以需要进行微调训练,但是训练的时候报错了,如下: File "/home/xxxxxxx/EdgeNets/nn_layers/e ...

  8. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0—问题分析

    声明: 这里仅仅提供一个思路,暂时没有绝对正确通用的解决方案 作者:{ 墨理 } 感谢通过私信.评论交流,协力探讨解决问题的同学 UP .Penser 文章目录 探讨的 pytorch 报错信息如下 ...

  9. Pytorch踩坑: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

    报错信息: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 186 a ...

最新文章

  1. NC93设计LRU缓存结构
  2. Redis报错解决:RDB: 0 MB of memory used by copy-on-write
  3. 产品运营 | 如何通过数据评判你的 App 表现?
  4. 《逻辑与计算机设计基础(原书第5版)》——1.2 计算机系统设计的抽象层次...
  5. 大佬把Spring框架总结的「无比详细」,不信你学不会!
  6. git 怎么提交忽略文件夹_git 设置忽略文件提交的几种方式
  7. android fragment学习4-底部布局扩展TabLayout
  8. SPOJ 9939 Eliminate the Conflict
  9. Java团队+.NET团队==足球队+篮球队;我们能否同时培养好2个优秀的精英团队?
  10. Android Textview实现文字颜色渐变效果
  11. WPF 设置TextBox为空时,背景为文字提示。
  12. testbench实例 vhdl_VHDL的testbench的编写
  13. 英语口语常用1368词汇
  14. 一个程序猿小小的梦想-写在16年底的时候
  15. pytho sockt编程
  16. 迁移公众号和个人博客
  17. IDEA下载GIT分支代码
  18. golang panic recover return defer的逻辑顺序问题
  19. 使用Python实现将ppt文件批量转化为pdf
  20. 【转载】真实一个初中生黑客梦的道路

热门文章

  1. 【noip2005】篝火晚会
  2. MySQL使用大全和JDBC使用_五万字的详细笔记
  3. iOS开发基础:最新的APP打包上架流程
  4. tomcat7绿色版服务配置
  5. win 10 禁用键盘,下载vc
  6. Centos7 安装VLC播放器
  7. [2011JMAA]Remarks on the regularity criteria for generalized MHD equations
  8. 当docker pull mysql时,一直Waiting,很多等待,报:error pulling image configuration
  9. 地磁基本知识(二)地磁异常
  10. FFmpeg入门详解之124:Qt5 FFmpeg单路网络摄像头采集预览