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 ...
随机推荐
- codechef Tree and Queries Solved
题目链接: https://www.codechef.com/problems/IITK1P10 大概是:修改点值,求子树节点为0有多少个, DFS序后,BIT 询问,修改 ; { ...
- JS---数组(Array)处理函数整理
1.concat() 连接两个或更多的数组该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本.例如: 代码如下: <script type="text/javascript&q ...
- 常见的哈希Hash算法 & MD5 & 对称非对称加密 & 海明码
参考 Link 另外,这篇文章也提到了利用Hash碰撞而产生DOS攻击的案例: http://www.cnblogs.com/charlesblc/p/5990475.html DJB的算法实现核心是 ...
- 源码编译安装php
原文:https://klionsec.github.io/2017/11/23/phpsec/#menu After compile install php 5.3.1, I can not fin ...
- 转:linux下ip修改与域名解析查看等
转自: http://www.justwinit.cn/post/7038/ IP: ifconfiggateway:172.16.0.254 [root@localhost ~]# nets ...
- 《ASP.NET》数据绑定—DataList实践篇
上篇文章大概讲了DataList的一些基础知识,掌握这些知识在将来的应用中起到非常大的作用,如今我们就開始讲上篇文章中说的基础知识做一个小样例. 首先,我机子的数据库中有一张person表.例如以下图 ...
- SolidEdge如何快速绘制并完全定义槽型孔
如果你点击A之后形成的圆弧不是你想要的 你试着换个方向,如下图所示 有时候只有一个方形可以形成你要的半圆
- UltraEdit UE常见问题 使用必读
1 UE设置出多个tag标签,能切换的那种样子 现在的现象就是图上显示的样子,我想弄出来多个标签能切换的样子,就像浏览器的多个标签那样,怎么操作呢 视图->视图/列表->打开文件标签可以使 ...
- ubuntu如何修改root密码
安装完Ubuntu后忽然意识到没有设置root密码,不知道密码自然就无法进入根用户下.到网上搜了一下,原来是这麽回事.Ubuntu的默认root密码是随机的,即每次开机都有一个新的root密码.我们可 ...
- Android Auto Scroll ViewPager (Smooth)
项目信息 项目地址 https://github.com/benniaobuguai/android-auto-scroll-viewpager 特性 支持自动平滑切换海报.相册等,无限次循环轮播 手 ...