Yeah, unfortunately there is no implementation in PyTorch for that – the random seeds are all global. One solution though as others suggested:



 Oli:

I mean there is the torch.randn and torch.randint. Hope that works for you. But could also create it in numpy and then convert it to a tensor with torch.tensor()


is just to sample via NumPy and then convert to tensors … until there’s maybe a PyTorch implementation one day …
EDIT: just following the link on the answer above, it does seem that you can manually set the seed for the torch.Generator. That should then be equivalent and probably what you were looking for:
gen1 = torch.Generator()

gen1 = gen1.manual_seed(1)
torch.rand(5, generator=gen1)