Я изменяю / присваиваю значение в массиве (torch.cuda.floatTensor).Я пытался каким-то образом, но это не работает.Пожалуйста, помогите мне!
# 1
#dis is [torch.cuda.FloatTensor of size 3185x1 (GPU 0)]
s = dis.size(0) #3185
for i in range (0,s,1):
if (dis[i,0] < 0):
dis[i,0]== 0
#There is no error but It does not work.
# 2
#dis is [torch.cuda.FloatTensor of size 3185x1 (GPU 0)]
s = dis.size(0)
a = torch.zeros(s, 1).cuda()
idx = (dis > a)
dis[idx] = a[idx]
AssertionError: can't compare Variable and tensor
# 3
#dis is [torch.cuda.FloatTensor of size 3185x1 (GPU 0)]
s = dis.size(0)
a = torch.zeros(s, 1).cuda()
for i in range (0,s,1):
if (dis[i,0] < a[i, 0]):
dis[i,0]==a[i, 0]
#RuntimeError: bool value of Variable objects containing non-empty torch.cuda.ByteTensor is ambiguous