I tried saving the parameters to the file like this: torch.save({'state_dict': m.state_dict()}, 'm1.p') # first time torch.save({'state_dict': m.state_dict()}, 'm2.p') # next time
And the output is:
-rw-r--r-- 1 root root 387361 Mar 8 14:05 m1.p
-rw-r--r-- 1 root root 387361 Mar 8 13:44 m2.p
Binary files m1.p and m2.p differ
I used iPython cells. and you can run any cell you like when you like.
This was the trick you need to have torch.manual_seed(0) in front of the command: m = MyModel(vocab_size, n_fac).to("cuda").
Just having torch.manual_seed(0) at the very start is not enough. because eny time you run the cell with m = MyModel(vocab_size, n_fac).to("cuda") you will have different parameters at startup.