RuntimeError: view size is not compatible with input tensor‘s size and stride
在运行pytorch程序中:
def forward(self, x):out = self.cnn(x)out = out.view(out.size()[0], -1)return self.fc(out)
python报错:
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
这是因为view()需要Tensor中的元素地址是连续的,但可能出现Tensor不连续的情况,所以先用 .contiguous() 将其在内存中变成连续分布:
out = out.contiguous().view(out.size()[0], -1)
这样就好了。
RuntimeError: view size is not compatible with input tensor‘s size and stride相关推荐
- 报错:RuntimeError: view size is not compatible with input tensor‘s size and stride (at least one dimen
报错:RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimen ...
- 深度学习:view size is not compatible with input tensor‘s size and stride (at least one dimension spans a
错误提示: view size is not compatible with input tensor's size and stride (at least one dimension spans ...
- 运行错误:view size is not compatible with input tensor‘s size and stride (at least
python运行报错: view size is not compatible with input tensor's size and stride (at least one dimension ...
- Python总结:RuntimeError: matplotlib does not support generators as input
QUESTION:RuntimeError: matplotlib does not support generators as input? ANSWER: 例子: 来源:stackoverflow ...
- 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 当把一个空的 ...
- cannot assign slice from input of different size
这个问题的提示挺明显的,就是维数不匹配,问题是怎么找到这个出问题的地方. 首先因为我使用的是numba 加速,编译之后运行的提示给的是cannot assign slice from input of ...
- pytorch(2)Tensor创建和获取tensor的size信息、torch.dtype、torch.device、torch.layout
获取tensor的size信息 >>> import torch >>> from torch.autograd import Variable >>& ...
- python size和count_groupby 的妙用(注意size和count)
Pandas的groupby()功能很强大,用好了可以方便的解决很多问题,在数据处理以及日常工作中经常能施展拳脚. 今天,我们一起来领略下groupby()的魅力吧. 首先,引入相关package: ...
- entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit
webpack打包提示文件体积过大导致 The following asset(s) exceed the recommended size limit (244 KiB). This can imp ...
最新文章
- React 父组件给子组件传值,子组件接收
- 5G NR — 基础知识
- java 多线程下载器_Java多线程的下载器(1)
- 小米手机系统服务组件是干什么的_怎么查看小米手机MIUI系统的基本功能-小米手机MIUI系统基础功能查询方法讲解...
- mysql连接报错:Unknown system variable ‘query_cache_size‘
- 关于游戏平衡性——王者荣耀英雄伤害数值参考
- Jafka源码粗略解读之二--关于JMX
- 初入WEBOTS半个月来的一点总结
- ASP.NET开发资源
- 动手学servlet(六) 过滤器和监听器
- [导入]每个开发人员现在应该下载的十种必备工具
- GBDT(MART) 迭代决策树入门教程
- 在html中定位属性怎么用,CSS元素定位的使用方法
- 安装Jaspersoft Studio
- AR+LBS街景实景红包PokemonGo游戏捉妖夺宝营销解决方案定制开发暨百度高德地图Unity插件SDK
- 单片机音频谱曲软件_51单片机蜂鸣器音乐简谱转换工具
- 台达plc使用c语言编程软件,台达PLC编程软件_台达PLC编程软件官方版下载[plc编程]-下载之家...
- 计算机如何共享桌面,怎么共享电脑屏幕?
- 干货 | 做外贸必须掌握的小知识
- 微信企业号和企业微信消息发送区别
热门文章
- vue中用table_element-ui中的 table 组件在vue中的使用
- redis lettuce 超时_Spring Cache 操作 Redis 实现数据缓存(上)
- mysql一键部署_一键部署----mysql5.6--jue
- python打开文本文档_带声明的Python –带打开的文件
- iOS UIDatePicker
- chrome自定义背景_Android Chrome自定义标签
- java ee是编程语言_什么是Java编程语言?
- linux的shell类型_Linux中有哪些不同类型的Shell?
- 小程序nginx做反向代理_NGINX作为节点或Angular应用程序的反向代理
- rxjava结合_RxJava结合最新,与最新发件人