Hello,
I’m curious if its possible to do something like np.random.choice([a, b], p=[p_a, p_b])
using PyTorch where a
and b
are 1-d tensors of length L and p_a
and p_b
are probabilities used to sample elements from either tensor a
or b
into the resultant 1-d tensor.
I think torch.multinomial([p_a, p_b], L)
might be useful here - it returns a 1-d tensor length L
of 0s and 1s based on the probabilities I give it but I’m drawing a blank of how to utilize this tensor to sample from my tensors a
and b
. Appreciate any help!