wkcn commented on a change in pull request #16680: Implement Initializer.__eq__
URL: https://github.com/apache/incubator-mxnet/pull/16680#discussion_r341417992
##########
File path: tests/python/unittest/test_gluon.py
##########
@@ -3119,6 +3119,19 @@ def forward(self, x):
shape = (np.random.randint(1, 10), np.random.randint(1, 10), 1)
block(mx.nd.ones(shape))
+def test_shared_parameters_with_non_default_initializer():
+ class MyBlock(gluon.HybridBlock):
+ def __init__(self, **kwargs):
+ super(MyBlock, self).__init__(**kwargs)
+
+ with self.name_scope():
+ self.param = self.params.get("param", shape=(1, ), init=mx.init.Constant(-10.0))
+
+ bl = MyBlock()
+ bl2= MyBlock(params=bl.collect_params())
+ assert bl.param is bl2.param
Review comment:
Thanks for your contribution!
Could you add the unittest 'b1.param is not bl3.param’ and the test for mx.init.Initializer?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|