报错:

RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton

解决:

img = Image.open(image_path)

改为

img = Image.open(image_path).convert('RGB')。

完成~

The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of相关推荐

  1. 报错解决——RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton

    问题描述 RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dim ...

  2. PyTorch 笔记(11)— Tensor内部存储结构(头信息区 Tensor,存储区 Storage)

    1. Tensor 内部存储结构 tensor 数据结构如下图所示,tensor 分为头信息区(Tensor)和存储区 (Storage),信息区主要保存着 Tensor 的形状(size).步长(s ...

  3. python中tensor与variable_NLP实战篇之tf2中tensor、variable、gradient、ops

    本文是基于tensorflow2.2.0版本,介绍了tf中变量.张量的概念,tf中梯度的计算方式和tensor相关的操作. 实战系列篇章中主要会分享,解决实际问题时的过程.遇到的问题或者使用的工具等等 ...

  4. The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0 维度不匹配

    在导入一个png文件的时候,发现报这个错,源码如下,经过查询找到了两种解决方案. from PIL import Image from torchvision import transforms fr ...

  5. PyTorch 笔记(03)— Tensor 数据类型分类(默认数据类型、CPU tensor、GPU tensor、CPU 和 GPU 之间的转换、数据类型之间转换)

    1. Tensor 数据类型 Tensor 有不同的数据类型,如下表所示,每种类型都有 CPU 和 GPU 版本(HalfTensor)除外,默认的 tensor 是数据类型是 FloatTensor ...

  6. python中size的用法.dim_【Numpy库学习笔记】Numpy中dim、shape和size的理解

    一.dim 理解: dim就是维数,比如数组会有一维数组,二维数组--.numpy的dim维数同理. 那如何判断numpy的维数,最简单的方法就是数一数"中括号"的数量.没有中括号 ...

  7. linux设备驱动之pci设备的I/O和内存

    ------------------------------------------ 本文系本站原创,欢迎转载! 转载请注明出处:http://ericxiao.cublog.cn/ -------- ...

  8. PyTorch 笔记(04)— Tensor 属性方法(获取元素个数numel/neleme、查看形状size()/shape、增减维度squeeze()/unsqueeze()、resize形状)

    1. 获取 Tensor 元素个数 获取 Tensor 的元素个数 ,a.numel() 等价 a.nelement() In [1]: import torch as t In [5]: a = t ...

  9. pytorch view(): argument 'size' (position 1) must be tuple of ints, not Tensor

    view(): argument 'size' (position 1) must be tuple of ints, not Tensor pytorch的view函数参数不能是tensor,解决方 ...

最新文章

  1. AI 迎来重要发展契机,开发者的机会在哪里?
  2. 细说Redis监控和告警
  3. __get__,__getattr__和__getattribute方法
  4. @keyframes—定义动画关键帧
  5. 李宏毅机器学习课程6~~~深度学习入门
  6. 开源当自强:我们不是“便宜货”
  7. 171. Excel Sheet Column Number (Easy)
  8. SQLplus 和mysql区别_mysql和oracle的区别有哪些
  9. 新仓库无线AP手持连接故障
  10. 华为2288服务器怎样查看硬盘,华为RH2288H V2磁盘系统测试_华为 FusionServer RH2288 V2_服务器评测与技术-中关村在线...
  11. photoshop基础视频教程 [4G]
  12. wind python接口手册_wind量化平台-用户手册(python).pdf
  13. 【Postman】使用Tests进行环境变量设置
  14. 我的第一篇博客--成长的第一站
  15. jQuery append( ) 方法
  16. Linux下开源打包工具fpm的安装与使用(超详细)
  17. js中动态给img标签添加onclick事件
  18. 微信APP支付的踩坑记录(一):prepay_id 与 prepayid
  19. 如何更改vs2013,vs2019等编译器的背景,更换壁纸
  20. 同一局域网下传输文件(Linux)

热门文章

  1. 物理层协议有哪四大特性
  2. pythonfillcolor_openpyxl 填充颜色(单元格)
  3. CentOS 安装 php
  4. Redis数据库学习笔记
  5. 关于未捕获异常的处理(WPF)
  6. vs2010创建和使用动态链接库(dll)
  7. 以太网,局域网,万维网
  8. TCP的定时器系列 — SYNACK定时器
  9. 5类6类7类网线对比_孩子们长高的黄金时期是从3月到5月,这阶段多吃6类食物长得快...
  10. mysqlslap详解--MySQL自带的性能压力测试工具(转)