rogerdettloff opened a new issue #18918:
URL: https://github.com/apache/incubator-mxnet/issues/18918


   ## Description
   When using npx.set_np(), I create a net (model), save it using 
`net.export()`, later re-load it using `mx.gluon.SymbolBlock.imports()`.  I get 
an error as show below...  
   
   ### Error Message
   ```
   Traceback (most recent call last):
     File "<input>", line 2, in <module>
     File 
"D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\mxnet\gluon\block.py",
 line 698, in __call__
       _check_all_np_ndarrays(out)
     File 
"D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\mxnet\gluon\utils.py",
 line 489, in _check_all_np_ndarrays
       .format(str(type(out))))
   TypeError: Block's output ndarrays/symbols must be of type 
`mxnet.numpy.ndarray` or `mxnet.symbol.numpy._Symbol`, while got output type 
<class 'mxnet.ndarray.ndarray.NDArray'>
   
   ```
   ## To Reproduce
   This works when NOT using npx.use_np()...posting it as a reference.
   ```
   import mxnet as mx
   # create a simple net...
   net1 = mx.gluon.nn.HybridSequential()
   net1.add(mx.gluon.nn.Dense(64, activation='relu'))
   net1.add(mx.gluon.nn.Dense(2))
   net1.hybridize()
   net1.collect_params().initialize(mx.init.Xavier())
   x = mx.nd.random.normal(shape=(1, 64))
   out1 = net1(x)
   net1.export('net1', epoch=1)
   
   net2 = mx.gluon.SymbolBlock.imports('net1-symbol.json', ['data'], 
'net1-0001.params')
   out2 = net2(x)
   ```
   
   Now try the same thing with `npx.use_np()` , and we get the error.
   ```
   import mxnet as mx
   from mxnet import np, npx
   npx.set_np()
   net1 = mx.gluon.nn.HybridSequential()
   net1.add(mx.gluon.nn.Dense(64, activation='relu'))
   net1.add(mx.gluon.nn.Dense(2))
   net1.hybridize()
   net1.collect_params().initialize(mx.init.Xavier())
   x = mx.np.random.normal(size=(1,64))
   out1 = net1(x)
   
   net2 = mx.gluon.SymbolBlock.imports('net1-symbol.json', ['data'], 
'net1-0001.params')
   out2 = net2(x)
   
   Traceback (most recent call last):
     File "<input>", line 2, in <module>
     File 
"D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\mxnet\gluon\block.py",
 line 698, in __call__
       _check_all_np_ndarrays(out)
     File 
"D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\mxnet\gluon\utils.py",
 line 489, in _check_all_np_ndarrays
       .format(str(type(out))))
   TypeError: Block's output ndarrays/symbols must be of type 
`mxnet.numpy.ndarray` or `mxnet.symbol.numpy._Symbol`, while got output type 
<class 'mxnet.ndarray.ndarray.NDArray'>
   
   ```
   
   ## Environment
   
   We recommend using our script for collecting the diagnositc information. Run 
the following command and paste the outputs below:
   ```
   ----------Python Info----------
   Version      : 3.7.6
   Compiler     : MSC v.1916 64 bit (AMD64)
   Build        : ('tags/v3.7.6:43364a7ae0', 'Dec 19 2019 00:42:30')
   Arch         : ('64bit', 'WindowsPE')
   ------------Pip Info-----------
   Version      : 20.2.1
   Directory    : 
D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\pip
   ----------MXNet Info-----------
   Version      : 1.6.0
   Directory    : 
D:\Projects\Combinati\dPCR-analysis\env-mxnet\lib\site-packages\mxnet
   Num GPUs     : 0
   Hashtag not found. Not installed from pre-built package.
   ----------System Info----------
   Platform     : Windows-10-10.0.18362-SP0
   system       : Windows
   node         : roger-5577
   release      : 10
   version      : 10.0.18362
   ----------Hardware Info----------
   machine      : AMD64
   processor    : Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
   Name                                       
   Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz  
   
   ```
   


----------------------------------------------------------------
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:
[email protected]


Reply via email to