can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
predict=predict.data.numpy() 这一行报错
意思是:如果想把CUDA tensor格式的数据改成numpy时
,需要先将其转换成cpu float-tensor随后再转到numpy格式。
numpy不能读取CUDA tensor 需要将它转化为 CPU tensor
将predict.data.numpy() 改为predict.data.cpu().numpy()即可
转 https://blog.csdn.net/qq_38410428/article/details/82973711
can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.的更多相关文章
- TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
报错原因:numpy不能读取CUDA tensor 需要将它转化为 CPU tensor. 所以如果想把CUDA tensor格式的数据改成numpy时,需要先将其转换成cpu float-tenso ...
- TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)
报错: TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a str ...
- has invalid type <class 'numpy.ndarray'>, must be a string or Tensor
转自: https://blog.csdn.net/jacke121/article/details/78833922 has invalid type <class 'numpy.ndarra ...
- pytorch tensor与numpy转换
从官网拷贝过来的,就是做个学习记录.版本 0.4 tensor to numpy a = torch.ones(5) print(a) 输出 tensor([1., 1., 1., 1., 1.]) ...
- pytorch_13_pytorch 中tensor,numpy,PIL的转换
PIL:使用Python自带图像处理库读取出来的图片格式numpy:使用Python-opencv库读取出来的图片格式tensor:pytorch中训练时所采取的向量格式 import torch i ...
- torch.Tensor和numpy.ndarray
1. torch.Tensor和numpy.ndarray相互转换 import torch import numpy as np # <class 'numpy.ndarray'> np ...
- typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...
如上贴出了:错误信息和错误代码. 这个问题困扰了自己两天,报错大概是说输入的数据和接受的格式不一样,不能作为tensor. 后来问了大神,原因出在tf.reshape(),因为网络训练时用placeh ...
- Pytorch中的variable, tensor与numpy相互转化的方法
1.将numpy矩阵转换为Tensor张量 sub_ts = torch.from_numpy(sub_img) #sub_img为numpy类型 2.将Tensor张量转化为numpy矩阵 sub_ ...
- 「Python」Convert map object to numpy array in python 3
转自Stackoverflow.备忘用. Question In Python 2 I could do the following: import numpy as np f = lambda x: ...
- CUDA[2] Hello,World
Section 0:Hello,World 这次我们亲自尝试一下如何用粗(CU)大(DA)写程序 CUDA最新版本是7.5,然而即使是最新版本也不兼容VS2015 ...推荐使用VS2012 进入VS ...
随机推荐
- sql常用记录
sqlserver 在已有值的列上自动增加 获取列最大的值 declare @Field int select @Field = ISNULL(Max(Field),0) from SupCsBill ...
- openwrt 配置虚拟wan口
一.刷固件:1.刷入 刷不死,百度上找教程:2.下载固件:https://downloads.openwrt.org/releases/17.01.6/targets/ramips/mt7620/ 按 ...
- SQL0818N/SQL0901N error when running db2advis
Skip to content Support DownloadsDocumentationForumsCasesMonitoringManage support account ...
- 如何在Debian10镜像中设置Nginx引擎模块
目前,我们较多的服务器WEB环境都是用的Nginx引擎,我们采用服务器的目的是可以获取到更多的资源,而且建站数量是不受限制的.我们可以根据自己需要配置Nginx,可以自定义特定域的设置,允许您在单个服 ...
- 安装centos7 报错no controller found踩坑
安装centos7.9时出现如上报错,特记录解决方法: 1.查看硬盘 出现如上报错时,耐心等待,等错误提醒不断滚动时,一会出现命令行输入界面,输入命令: [root@localhost ~]# ls ...
- select选项中的内容和其他输入框不对齐
有时候总会遇见莫名其妙的问题,如图中(为了清除的表示问题,我又用画图将偏离更夸张些).为了解决这个问题,只好取消样式优化,同时自己加小箭头.但是为什么会有这样的问题啊 /*取消iphone样式优化*/ ...
- java中对list集合进行分组
java中对list集合进行分组 Map<String, List<HealthImport>> excelIdCardNull = importList.stream() . ...
- FIFO 串口接收处理机制
与安富莱电子的串口处理机制做对比交互 参考链接: https://www.eet-china.com/mp/a161019.html
- vue 3 打印 print-js
1.安装 npm install print-js --save 2.引用 import print from 'print-js' 3.编写打印函数 const enterDialog = asyn ...
- 新版 Mediasoup Windows 安装 编译
https://vc.feiyefeihua.top/ ps:视频测试demo,服务器配置很低,加载有点慢:需要有音视频设备,不然会报错. 关于官网文档 官网文档地址 只测试了 Windows .讲的 ...