Torch.manual_seed seems not honored in torch.randint

torch.manual_seed seems not honored in torch.randint.
I ran the following program multiple times in torch 1.5.1 and got different output each time.

torch.manual_seed=123
torch.randint(3, 5, (3,))

torch.manual_seed(123) call used to work before torch 1.4, but with torch 1.5.1 I got the following error. So I changed the call to be torch.manual_seed=123, not sure if that is the problem.


TypeError Traceback (most recent call last)
in
----> 1 torch.manual_seed(123)

TypeError: ‘int’ object is not callable

Hi,

torch.manual_seed is a function. You should call it with the new seed you want to use doc.

When you do torch.manual_seed=123 you actually override the function and change it to 123. This is why you get the error you report. Don’t do this assignment and just call the function after a new import of pytorch.

As you can see, with torch 1.5.1 the function torch.manual_seed cannot take in an int somehow.

Can you restart the notebook? This is most likely because above you did torch.manual_seed = 123.
Doing import foo multiple times in python does not import it again, it just returns the same module.

You are right! Many thanks!