I have a tensor size of
BxCxHxW) and a list of row index that used to assign to zero row postion of the tensor. For example,
index_zeros_list=[2,5,9] means all value in the row 3th, 6th, and 10th (index from 0) will be zero. I used bellow code in pytorch 0.3.1 and it got the below error. Could you have me to fix it? it worked in pytorch 0.4.1
B,C,H,W=3,2,32,32 input_tensor = torch.randn(B, C, H, W) input_tensor =Variable(input_tensor).cuda() index_zeros_list = random.sample(range(0, H), 5) input_tensor[:, :, index_zeros_list, :] = 0
The error is
TypeError: Performing basic indexing on a tensor and encountered an error indexing dim 2 with an object of type list. The only supported types are integers, slices, numpy scalars, or if indexing with a torch.LongTensor or torch.ByteTensor only a single Tensor may be passed.