a = Variable(torch.FloatTensor([1,1]))
a[0].data = torch.FloatTensor([2])
print(a[0]) # doesn't work, it is still [1], not [2]
OK, I know that.
It should be
a.data[0] = 2
If you want backprop, avoid using .data
on Variable.
a = Variable(torch.FloatTensor([1,1]))
a[0].data = torch.FloatTensor([2])
print(a[0]) # doesn't work, it is still [1], not [2]
OK, I know that.
It should be
a.data[0] = 2
If you want backprop, avoid using .data
on Variable.