I have a long tensor with y dim vector per sample. I want to choose x random dimensions from y. I’m unsure who to do this. I’m new to Pytorch and Python. Thanks.
I have tried this:
random.sample(set(outputs2[0]), 10)
I’m wanting 10 random tensors from a 1000x1024 tensor (outputs2), it it’s giving me ‘10’ of them, but something is not quite correct, because when I take this result and put it back in my code path, it is not working.
[tensor(1.0000, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-0.9909, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(0.9999, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-0.9808, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-1.0000, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-0.9999, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(0.9999, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(1.0000, device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-1., device=‘cuda:0’, grad_fn=<SelectBackward>), tensor(-1.0000, device=‘cuda:0’, grad_fn=<SelectBackward>)]