What’s the equivalence of theano’s inc_subtensor()?
To change the values of a subset elements of a tensor, in theano we have inc_subtensor(), what is the equivalence in pytorch?
david-leon
Hi,
albanD
Yes, I noticed there is torch.index_select() function. However this function returns a new tensor not a view, so if I do <SCODE>t2 = torch.index_select(t1,  axis, index)
t2 += 1.0
<ECODE>
david-leon
you can do standard numpy-like indexing: Try this: <SCODE>t1 = torch.randn(10, 5)
t2 = t1[:, 3]
t2.fill_(0)
print(t1)
<ECODE>
smth
david-leon
I think index_add_ is what you are looking for.
ypxie
Thanks, that’s exactly what I’m looking for.
david-leon
apaszke
albanD
david-leon
apaszke
david-leon
apaszke
david-leon