rony2:

s = sum([np.prod(list(p.size())) for p in m1.parameters()]);
print (‘Number of params: %d’ % s)
It prints 22. Which means, that you have 22 parameters for each of m1 and m2, but only 2 of them are alike. And


I don’t see how you can come to this conclusion from this code. What it is doing. It is just calculating the number of parameters in m1 model and nothing to compare it with m2



 rony2:

m1.parameters() != m2.parameters()


Here you are comparing two generators (and as they are 2 different python objects they are obviously not the same). You can see the type: type(m1.parameters()). That is why you need to iterate and compare parameters themself.
Also in this simple model you can just print parameters for both models and make sure they are the same:
for p1, p2 in zip(m1.parameters(), m2.parameters()):
    print("m1")
    print(p1)
    print("m2")
    print(p2)