You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/03/31 22:50:33 UTC

[GitHub] [incubator-mxnet] ptrendx commented on issue #17800: _MinusScalar type not supported` ?

ptrendx commented on issue #17800: _MinusScalar type <class 'mxnet.ndarray.ndarray.NDArray'> not supported` ?
URL: https://github.com/apache/incubator-mxnet/issues/17800#issuecomment-606925771
 
 
   @aGiant You are still using `self.min_v` and `self.max_v` in your `hybrid_forward`. Are you sure you have them set as parameters? Here is a simple working example of using parameters:
   ```python
   class Test(gluon.HybridBlock):
       def __init__(self, **kwargs):
           super(Test, self).__init__(**kwargs)
           with self.name_scope():
               self.x_min = self.params.get('scales_min',
                                            shape=(1,),
                                            init=mx.init.Constant(5),
                                            differentiable=False)
               self.x_max = self.params.get('scales_max',
                                            shape=(1,),
                                            init=mx.init.Constant(10),
                                            differentiable=False)
               
       def hybrid_forward(self, F, x, x_min, x_max):
           return (x * x_min) + x_max
   
       
   t = Test()
   t.initialize()
   t(mx.nd.ones((1,)))
   ``` 
   ```python
   [15.]
   <NDArray 1 @cpu(0)>
   ```

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