Unable to get repr for <class 'torch.Tensor'>
tensor越界通路後就會變成這樣。
import torch
a_data=torch.Tensor([1,2,3])
index=[0,1,1,2,1]
ba=a_data[index]
print(ba)
labels[[0,5]]
2021.03.28測試發現越界錯誤好像又改了:
import torch
a_data =torch.Tensor([1 ,2 ,3])
index =[0 ,1 ,1 ,2 ,5]
ba =a_data[index]
print(ba)
報錯内容:
IndexError: index 5 is out of bounds for dimension 0 with size 3
錯誤原因:a_data中隻有3個數
但是index中有取第5個數(由于從0開始編号,實際是第6個數),越界報錯。