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

 

posted @ 2019-04-09 15:46  小呆丶  阅读(12949)  评论(0编辑  收藏  举报