suppose that I have two models, which are created both by nn.module
model1 = Sequential(…)
model2 = Sequential(…)
model1 and modle2 looks like each other
so ,how to compare model1 and model 2 exactly? does pytorch provide API to compare them?
Could you explain what “compare” means in your use case?
If you want to check the parameters of both models and see if they are equal, you could check both
state_dicts and use e.g
torch.equal for each parameter/buffer.
On the other hand, if you want to verify the same forward pass logic (additionally to the
state_dicts), you could make sure the results are deterministic by following these docs and compare both outputs.
I wanna to compare both parameters network architecture
- whether the net architectures are same or not
- if net architectures are same, I wanna to compare if the parameters are same