piiswrong closed pull request #8182: Make gluon.Block cooperative in multiple 
inheritance setting
URL: https://github.com/apache/incubator-mxnet/pull/8182
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index def5d145f8..b4c534289d 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -162,13 +162,16 @@ def forward(self, x):
             dense0 = nn.Dense(20)
             dense1 = nn.Dense(20, params=dense0.collect_params())
     """
-    def __init__(self, prefix=None, params=None):
+    def __init__(self, prefix=None, params=None, **kwargs):
         self._empty_prefix = prefix == ''
         self._prefix, self._params = _BlockScope.create(prefix, params, 
self._alias())
         self._name = self._prefix[:-1] if self._prefix.endswith('_') else 
self._prefix
         self._scope = _BlockScope(self)
         self._children = []
 
+        # Cooperative design for multiple inheritance
+        super(Block, self).__init__(**kwargs)
+
     def __repr__(self):
         s = '{name}(\n{modstr}\n)'
         modstr = '\n'.join(['  ({key}): {block}'.format(key=key,
@@ -319,8 +322,9 @@ class HybridBlock(Block):
     Refer `Hybrid tutorial <http://mxnet.io/tutorials/gluon/hybrid.html>`_ to 
see
     the end-to-end usage.
     """
-    def __init__(self, prefix=None, params=None):
-        super(HybridBlock, self).__init__(prefix=prefix, params=params)
+    def __init__(self, prefix=None, params=None, **kwargs):
+        # Cooperative design for multiple inheritance
+        super(HybridBlock, self).__init__(prefix=prefix, params=params, 
**kwargs)
         self._reg_params = {}
         self._cached_graph = ()
         self._cached_op = None


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to