命令式:Numpy, Matlab, Torch,优点在于 Straight-forward. Easy to view the middle level results
import mxnet.ndarray as nd
a = nd.ones((4,4))
b = nd.ones((4,4))
c = a + b
print(c.asnumpy())
符号式: Tensorflow, Theano, Caffe,优点在于 Easier to optimize.After getting the computational graph (logic), we couldapply rules to simplify the graph. We can also choose themost efficient implementation to do the real computation
import mxnet as mx
import numpy as np
a=mx.sym.Variable('a',shape=(4,4))
b=mx.sym.Variable('b',shape=(4,4))
c=a+b
#Compiletheexecutor
exe=c.simple_bind(ctx=mx.cpu())
#Runtheexecutor
exe.forward(a=np.ones((4,4)))
print(exe.outputs[0].asnumpy())