pytorch
刃刃刀刀
这个作者很懒,什么都没留下…
展开
-
循环拼接tensor的简单操作###踩坑
循环拼接tensor 1.创建空list 2.将单个tensor转换为numpy,tensor_tmp 3.将tensor_tmp压入list list.append(tensor_tmp) 4.转换list为tensor torch.Tensor(list)原创 2022-03-01 09:21:30 · 1482 阅读 · 0 评论 -
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to
Use Tensor.cpu() to copy the tensor to host memory first. Tensor在进行numpy计算的时候需要与numpy()的格式进行转换 1.查看计算的tensor的位置信息。cpu tensor或者gpu tensor(cuda) 2.如果为cuda tensor,需要进行转换numpy格式(cpu tensor原理一样) 1)data.cpu().detach().numpy() #将data转换成cpu numpy格式 2)result.cu原创 2021-04-09 12:45:42 · 1323 阅读 · 0 评论 -
RuntimeError: No CUDA GPUs are available
之前运行正常突然报错:RuntimeError: No CUDA GPUs are available // 报错信息 RuntimeError: No CUDA GPUs are available 解决方法 // 检测一下cuda是否可用 print(torch.cuda.is_available()) False //重新在文件头加入下面说明 import torch torch.cuda.current_device() torch.cuda._initialized = True ...原创 2021-03-16 09:53:57 · 8439 阅读 · 1 评论 -
2021-03-09踩坑 torch.cat
*将两张图像的detections tensor拟合在一起 ** 1. 通过循环检测后,两张图像的 tensor 存在 images_detections 中 ** 如: [tensor([[1,2], [2,3], [3,4]]), tensor([[1,2], [2,3], [3,4]])] ** 2. 直接对 images_detections 执行自融合 torch.cat(images_detections, 0 ) 即可** 如: tensor([[1,2], [2,3], [3,4], [1,原创 2021-03-09 21:25:14 · 345 阅读 · 2 评论