In A3C, the gradients of main thread parameters are copied from training threads.
But the gradients of pytorch nn.module cannot be reassigned?
So how to implement this procedure?
BTW. is there a function like tf.gather_nd() in pytorch?
to extract values in specific indexes of the tensor (multidimensional).
Cause right now, the torch.indes_select can only select from one dimension.
to answer your second question, you can create a mask tensor and index elements via this mask tensor:
x = torch.randn(2, 3, 2)
mask = x.gt(0.5)
# mask is a torch.ByteTensor of same shape and size as x
(0 ,.,.) =
(1 ,.,.) =
[torch.ByteTensor of size 2x3x2]
[torch.FloatTensor of size 4]
Thank you smth.
If I have an index list where same indexes may repeat for several times.
Then I think this method is useless.
But gather always returns a tensor with same dimension as the input right?
Yes, that’s the limitation.