Problem using torch.manual_seed

The weights will be the same, of you copy them, but you are initializing Ind again in get_clone.
This means, that the PRNG will be called for sampling the weights.
Calling .normal_() after this will yield different random numbers.
Have a look at the following example:

seed = 2809

torch.manual_seed(seed)
print(torch.empty(5).normal_())

torch.manual_seed(seed)
print(torch.empty(5).normal_()) # Same numbers as before

torch.manual_seed(seed)
# Init a model before sampling
model = nn.Linear(10, 10)
print(torch.empty(5).normal_()) 
# Numbers are different, since PRNG was called in nn.Linear
1 Like