wkcn commented on issue #14268: Add numpy module under root module mxnet
URL: 
https://github.com/apache/incubator-mxnet/issues/14268#issuecomment-468168003
 
 
   @reminisce 
   The block in gluon accepts the instance of mx.nd.NDArray or mx.nd.Symbol.
   We can distinguish between symbolic and imperative namespaces by the type of 
inputs.
   
   An Example:
   ```python
   import mxnet as mx
   
   
   class TestBlock(mx.gluon.nn.HybridBlock):
       def hybrid_forward(self, F, x):
           if isinstance(x, mx.nd.NDArray):
               print('the input is an instance of NDArray')
           elif isinstance(x, mx.sym.Symbol):
               print('the input is an instance of Symbol')
           return x
   
   
   block = TestBlock()
   a_nd = mx.nd.array([1, 2, 3])
   print(block(a_nd))
   a_sym = mx.sym.Variable('a')
   print(block(a_sym))
   ```

----------------------------------------------------------------
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