- I have a tensor
requires_grad = True
- I apply a boolean advanced indexing to
t1 = t[mask].
- The mask is regular so I can reshape
t1to have a shape
s, that is
t2 = t1.reshape(s)(or
Now, I want to access the gradient of
t2, that is, to retrieve a tensor
g with shape
s containing the gradient of
t at the corresponding positions of
reshape operators make
t2 a non-leaf tensor, thus calling
Is there a way to get these gradients?