報錯緣由:numpy不能讀取CUDA tensor 須要將它轉化爲 CPU tensor。code
因此若是想把CUDA tensor格式的數據改爲numpy時,須要先將其轉換成cpu float-tensor隨後再轉到numpy格式blog
報錯行:get
tcls[index, best_n, g_y_center, g_x_center, np.array(target[index, t, 0])] = 1
修改後:class
tcls[index, best_n, g_y_center, g_x_center, np.array(target[index, t, 0].cpu())] = 1