使用torchsummary 中的 summary函数时,模型中有Embedding层的时候,会报错。原因是Embedding 需要整型的Tensor。

pip install 的torchsummary 不行,没有dtypes这个参数。
所以你下载这里提供的 torchsummary.py 放在你的代码一个目录里即可。

链接: https://pan.baidu.com/s/1HKUZi7Eps1KaA0KvPWfO6A
密码: vku4

这么使用即可:

from torchsummary import summary
summary(model, (1, 100, 8), dtypes=[torch.LongTensor], device='cpu')

RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got CUDAFloatT相关推荐

  1. RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got CUDAType

    RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda ...

  2. Expected tensor for argument #1 ‘indices‘ to have one of the following scalar types: Long, Int; but

    RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: L ...

  3. torchserve 错误:RuntimeError: Expected tensor for argument #1 ‘input’ to have the same device as tenso

    RuntimeError: Expected tensor for argument #1 'input' to have the same device as tensor for argument ...

  4. Expected tensor for argument #1 'input' to have the same device as tensor for argument #2 'weight';

    解决了题目所述问题. 报错完整信息为: RuntimeError: Expected tensor for argument #1 'input' to have the same device as ...

  5. RuntimeError: expected a Variable argument, but got torch.FloatTensor

    从字面的意思来看是 RuntimeError:期望有一个变量参数,但是得到了torch.FloatTensor 这个解决方法是升级pytorch的版本就可以了,我之前用的是pytorch0.3,现在升 ...

  6. Expected tensor for argument #1 ‘input‘ to have the same device as tensor for argument #2 ‘weight‘;

    这种情况出现的原因之一是创建网络的语句没有放进train函数里 比如主文件中有train(),test(),eval()......等各个函数,但是创建网络的语句:net=createnet()放在各 ...

  7. RuntimeError: Expected object of device type cuda but got device type cpu for argument pytorch数据位置

    RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target' i ...

  8. RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target'

    RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target' i ...

  9. RuntimeError: Expected object of backend CUDA but got backend CPU for argument

    RuntimeError: Expected object of backend CUDA but got backend CPU for argument #4 'mat1' 原因:变量没有加cud ...

最新文章

  1. apache优化管理
  2. 【设计模式】软件设计七大原则 ( 依赖倒置原则 | 代码示例 )
  3. Too many fragmentation in LMT?
  4. 一个农场有头母牛,现在母牛才一岁,要到四岁才能生小牛,四岁之后,每年生一头小牛,n年后有多少头小牛
  5. p2p-如何拯救k8s镜像分发的阿喀琉斯之踵?
  6. 蛋疼的strtok函数
  7. Sharding-JDBC(操作公共表)_Sharding-Sphere,Sharding-JDBC分布式_分库分表工作笔记013
  8. 项目管理综述(需要完善)
  9. Tornado部署时那些奇怪的错误
  10. Unity 3D下载安装教程
  11. UrlRewrite 的配置和使用总结
  12. oracle会计工作总结,EBS 创建会计科目 小结
  13. 数学建模python实现基础编程练习4
  14. 怎样用C语言sinx的曲线长度,Javascript 绘制 sin 曲线过程附图
  15. 产品定位的方法与案例,遵循 大而全不如小而精 理念
  16. OE分布式智能云生态
  17. 观察者模式(结合C#,Unity)
  18. Web前端期末大作业---响应式美女健身教练瑜伽馆网页设计(HTML+CSS+JavaScript+)实现
  19. 2022年重庆最新建筑施工焊工(建筑特种作业)模拟考试题库及答案解析
  20. 抖音短视频零基础能做到百万粉丝吗?国仁楠哥

热门文章

  1. 睿停车系统车场服务器,睿停车后台管理中心系统-用户手册-前台版本
  2. dubbo源码-服务发现
  3. git更新pull报错Pulling 1 repository Remote does not have refs/heads/rel5.1 available for fetch
  4. LOCK - 明确地锁定一个表
  5. 简单的跑马灯效果(轮播图)
  6. ContentLoadingProgressBar不显示问题
  7. redmine 和 gitolite 的整合
  8. [转]linux常用命令学习总结(超详细)
  9. 量化策略回测DCCV2
  10. 备受青睐的在线报表工具有哪些?在线报表怎么做?