Compare two different gluon Models

Is it possible to compare two gluon models to identify if there are equivalent? I want to have that feature to use it in some unittest where I am checking consistency of some loading and saving process.

I try to compare the dict returned by collect_params(), but if fails included with the same model.
p1 = net.collect_params()
p2 = net.collect_params()
self.assertTrue(p1 == p2). //it fails

Does anyone have a solution for that?
Thank you very much

I guess you could do something like:

params1 = net.collect_params().items()
params2 = net.collect_params().items()
same_model = True
for (name1, p1), (name2, p2) in zip(params1, params2):
    if name1 != name2 or p1 != p2:
        same_model = False
        break
self.assertTrue(same_model)

I hope this is what you’re trying to do here

Thanks @spanev.
Unfortunately it does not seems to work, when I create a model from the zoo, it seems that a postfix integer is added to the name of the parameter with a weird integer (as if it keeps track of the model I created).

For example with the following code:
I create two models from resnet152_v2, and I load the same parameters files. I expect that a function which check the equality between the two models states that the two models are identical.

net1 = models.get_model("resnet152_v2", ctx=ctx, pretrained=False)
#net1.load_parameters(f1)
net2 = models.get_model("resnet152_v2", ctx=ctx, pretrained=False)
#net1.load_parameters(f2)

params1 = net1.collect_params().items()
params2 = net2.collect_params().items()
same_model = True
for (name1, p1), (name2, p2) in zip(params1, params2):
    if name1 != name2 or p1 != p2:
        same_model = False
        break
self.assertTrue(same_model)

Actually, you do not need the parameters file to see that you code will not work. In my case, the name of the parameters are all different. It seems that there is a postfix attached to the name. For example for the first param1, the param name are: resnetv27_batchnorm0_gamma, resnetv27_batchnorm=_beta, …
however for the params, the names are resnetv28_batchnorm0_gamma, resnetv28_batchnorm=_beta, …

I could do a ugly hack and get this postfix removed, but is there any other solutions?

I think I have found a solution.

I use the save_parameters, for the two networks, and then I check wile filecmp if the two files are identical.
Is there any API solutions?