使用torchsummary的时候,出现以下错误:

(涉及板块:

python 库整理:Timm(1)_UQI-LIUWJ的博客-CSDN博客

pytorch 笔记:torchsummary_UQI-LIUWJ的博客-CSDN博客

代码部分

import timm
model = timm.create_model('resnet18', pretrained=True)
model.to_device('cpu')
model.eval()
from torchsummary import summary
summary(model,(3,244,244))

错误:

RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

这是由于模型和summary一个是cpu版本一个是gpu版本

解决方法:(看最后一行)

方法1:

import timm
model = timm.create_model('resnet18', pretrained=True)
model.eval()
from torchsummary import summary
summary(model.cuda(),(3,244,244))

方法2:

import timm
model = timm.create_model('resnet18', pretrained=True)
model.eval()
from torchsummary import summary
summary(model,(3,244,244),device='cpu')

错误处理:RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be相关推荐

  1. Pytorch数据使用列表的卷积层时报错及解决-RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.Floa

    文章首发及后续更新:https://mwhls.top/3737.html,无图/无目录/格式错误/更多相关请至首发页查看. 新的更新内容请到mwhls.top查看. 欢迎提出任何疑问及批评,非常感谢 ...

  2. Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

    原因是没有把输入数据类型转为float类型 首先找到代码出错的位置,将该处的数据类型转为float类型: x = x.type(torch.FloatTensor)

  3. RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the

    运行时出现这个错误:RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) shou ...

  4. 【BUG解决】 RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)

    问题描述 RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be ...

  5. Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same(解决)

    问题描述 在使用pytorch训练经典的MNIST数据集时,运行时,出现了以下的问题: Input type (torch.FloatTensor) and weight type (torch.cu ...

  6. RuntimeError_ Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)

    两个解决方案 方案一:检查网络和数据是否都在GPU上 RuntimeError:输入类型(torch.FloatTensor)和权重类型(torch.cuda.FloatTensor)应该相同,或者输 ...

  7. RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.cuda.IntTensor

    问题: anchor_label = np.array(self.id_dict[int(anchor_id)])identity_loss = criterion_identity(predicte ...

  8. Pytorch出现RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)

    这个问题的主要原因是输入的数据类型与网络参数的类型不符. Input type为torch.cuda.FloatTensor(GPU数据类型), weight type(即net.parameters ...

  9. torch.cuda 相关函数

    import torch# torch版本 print('Pytorch version\t:', torch.__version__)# cuda 版本 print('CUDA version\t: ...

最新文章

  1. 集合啦,NLP数据增强技术!超全资源汇总
  2. 软件包有未满足的依赖关系
  3. 用脑机接口去“搜索一下”,是种什么体验? | CCF C³-03@搜狗
  4. 签名工具 signtool.exe 参数简介
  5. Python基础:一起来面向对象 (二) 之搜索引擎
  6. 百度大脑“乘风”新基建,“破浪”产业智能化落地
  7. 【Git】IDEA项目关联Git的解决方案
  8. Jquery一些常用的方法
  9. spring boot和spring cloud的区别_微服务实战系列(三)-cloud、boot及maven关系
  10. 排毒食物 红糖可补血美体排毒
  11. js实现搜索框智能提示上下移动效果
  12. JAVA方法重载优先级
  13. flask-uploads上传插件上传文件
  14. matlab波浪号怎么打,数学中字母上面波浪号 波浪号怎么打到上面
  15. 3-9 G: LZY的时间转化
  16. ubuntu下解决longene-qq 退出之后再登录出现登录失败的问题
  17. amoeba mysql mmm_MMM+Amoeba搭建MySQL高可用负载均衡群集
  18. 腾讯云对象储存-图片上传-删除图片
  19. 安全协议系列(一)----WEP详解
  20. 文档翻译器怎么用?如何完成整篇word文档翻译

热门文章

  1. PAT甲级1021 Deepest Root :[C++题解]树的最大深度、并查集、dfs求树的深度
  2. leetcode 454. 四数相加 II c语言
  3. css 倒三角_【译】改善 CSS 的 10 个最佳实践
  4. jpa遇到mysql表名大写怎么办_解决(springboot项目)mysql表名大写,造成jpa Table doesn't exist问题...
  5. hbase java 端口_HBase远程Java客户端尝试通过随机端口进行身份验证
  6. 如何判断基因组的重复区域_Nat Comm. | 15万人类基因组中多核苷酸变异(MNV)的起源及功能研究...
  7. timer计时器 java_java中基于timer计时器的图片播放
  8. 2.5e2.0是合法的c语言常量,二级考试C语言程序设计.ppt
  9. oracle的java路径,oracle学习----访问路径
  10. 下列数据类型中python不支持的是_ 下列选项中 ,Python 不支持的数据类型有 ( ) 。_学小易找答案...