pytorch報錯Unable to get repr for
標籤出現了-1,2或者其餘值,loss計算以後,ide
報錯:CUDA error: device-side assert triggeredspa
而後出現此錯誤:調試
Unable to get repr for class tensorcode
pytorch 在調試的時候,變量出現了Unable to get repr for <class ‘torch.Tensor’>
是本身數據格式的問題,具體緣由後面在詳細整理。ip
具體情景: 作roipooling的時候,rois的數據類型不對,出現了以上錯誤。
解決方法:採用torch.tensor([0, 2, 2, 10, 10]),就是採用了torch.tensor。前期有嘗試torch.from_numpy, torch.FloatTensor(),雖然數據值都是同樣的,可是就是報錯。
get
具體代碼以下:class
temp = rois.numpy().tolist() # rois = torch.FloatTensor([0] + [temp[0][1], temp[0][2], temp[0][3], temp[0][4]] ) rois = torch.tensor([0] + [temp[0][1], temp[0][2], temp[0][3], temp[0][4]]) pooled_feat = pooling(base_feat, rois.view(-1, 5))