MXNet prints intermediate character values

How to find the actual numerical values ​​stored in the MXNet symbol.

Suppose I,

x = mx.sym.Variable('x') y = mx.sym.Variable('y') z = x + y, 

if x = [100,200] and y = [300,400], I want to print:

z = [400,600] ,

like tensor flow method eval ()

+4
source share
1 answer

Looking around a bit, I found that you can do this:

 x = mx.sym.Variable('x') y = mx.sym.Variable('y') z = x + y executor = z.bind(mx.cpu(), {'x': mx.nd.array([100,200]), 'y':mx.nd.array([300,400])}) output = executor.forward() 

will give you an "exit":

 [<NDArray 2 @cpu(0)>] 

To print the actual digital result:

 print output[0].asnumpy() array([ 400., 600.], dtype=float32) 
+7
source

Source: https://habr.com/ru/post/1265896/


All Articles