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-tensor随后再转到numpy格式
报错行:
tcls[index, best_n, g_y_center, g_x_center, np.array(target[index, t, 0])] = 1
修改后:
tcls[index, best_n, g_y_center, g_x_center, np.array(target[index, t, 0].cpu())] = 1
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.的更多相关文章
- 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 ...
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- tensorflow基础--LeNet-5测试模型遇到TypeError: Failed to convert object of type <class 'list'> to Tensor
最近在看<TensorFlow 实战Google深度学习框架第二版>这本书,测试LeNet-5这个模型时遇到了TypeError: Failed to convert object of ...
- 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 ...
- 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 ...
- tensorflow TypeError: Can not convert a float32 into a Tensor or Operation
遇到这种情况可能是你的程序中有和你定义的tensor 变量重名的其他变量名字,jishi在for循环中使用了这个名字的作为临时变量也不行.tenor 变量很娇气.坑了我一晚上的时间. 比如:x = t ...
随机推荐
- Easy sssp(spfa)(负环)
vijos 1053 Easy sssp 方法:用spfa判断是否存在负环 描述 输入数据给出一个有N(2 <= N <= 1,000)个节点,M(M <= 100,00 ...
- Google代码风格配置文件(Java)(IDEA/Eclipse)
官网:http://www.cnblogs.com/EasonJim/p/7837474.html 下载: 安装: IDEA/Eclipse导入相应文件即可. 说明: Google代码风格文件的缩进是 ...
- 【转载】云计算的三种服务模式:IaaS,PaaS和SaaS
一张图就看懂了.其他的都不用说了. 原文:http://blog.csdn.net/hjxgood/article/details/18363789
- js正則表達式:验证邮箱格式、password复杂度、手机号码、QQ号码
$(function () { $("input[name='sub']").on("click", function () { if (!isEmail($( ...
- 关于 redux-saga 中 take 使用方法详解
本文介绍了关于redux-saga中take使用方法详解,分享给大家,具体如下: 带来一个自己研究好久的API使用方法. redux-saga中effect中take这个API使用方式,用的多的是ca ...
- weex 小结
1. import 文件时,必须引入全称,不能省略 .vue import mEcharts from '../components/Echarts.vue' 2.weex 的 cli 中没有 配置 ...
- Intel processor brand names-Xeon,Core,Pentium,Celeron----Atom
http://en.wikipedia.org/wiki/Intel_atom Intel Atom From Wikipedia, the free encyclopedia (Redirect ...
- Android逆向利器和smali代码修改出错举例-入参类型
当smali修改代码出错举例1,log如下: 虚拟机层次: 1.本身做出了预测,寄存器v2是符合要求入参,暗示你这个也许是你想要的.VFY: register1 v2 type 17, wanted ...
- POJ 2378 Tree Cutting 子树统计
题目大意:给出一棵树.将树中的一个节点去掉之后,这棵树会分裂成一些联通块.求去掉哪些点之后.全部联通块的大小不超过全部节点的一半.并按顺序输出. 思路:基础的子树统计问题,仅仅要深搜一遍就能够出解.这 ...
- Mac OS用docker Desktop安装单节点kubernetes
方案: 安装方式:阿里云minikube,k8s官方minikube,kubeadm, docker Desktop中自带第k8s 安装环境:在linux虚拟机中安装k8s,在macos中安装k8s, ...