The source of manual_seed pytorch follows, the role of: generating a fixed random number
def manual_seed(seed):
r"""Sets the seed for generating random numbers. Returns a
`torch.Generator` object.
Args:
seed (int): The desired seed.
"""
seed = int(seed)
import torch.cuda
if not torch.cuda._in_bad_fork:
torch.cuda.manual_seed_all(seed)
return default_generator.manual_seed(seed)
example:
import torch
print(torch.rand(2))
torch.manual_seed(2)
print(torch.rand(2))
Run multiple times after to know the results