Dear all,
I would please like some advice/comments on what is the behaviour of the assignment operator “=” when it comes to assigning a whole model. E.g. say I have a model
net = gluon.nn.HybridSequential()
with net.name_scope():
for i in range(5):
net.add(gluon.nn.Conv2D( ...) )
# copy to other model
net_2 = net
Without having performed weights initialization, net_2 is a copy of the initial net (i.e. an independent object) or a reference to it? Do they have the same names in param_dict? That is, modification of net_2 will pass in net? And also, does similar hold for individual layers? E.g.
class Custom(HybridBlock):
def __init__(self,**kwards):
HybridBlock.__init__(self,**kwards):
with self.name_scope():
self.feature1 = gluon.nn.Conv2D(...)
self.feature2 = gluon.nn.Conv2D(...)
def hybrid_forward(self,F,_x):
out = self.feature1(_x)
return self.feature2(out)
net = Custom()
net2 = net # is this copy/reference?
Thank you very much.
edit:
net2 == net # prints True
net2.collect_params().keys() == net.collect_params().keys # prints True
net2.collect_params() == net.collect_params() # prints False