A = mx.sym.Variable('A')
B = mx.sym.Variable('B')
C = A + B
D = A - B
E = A * B
F = A / B
# a = mx.nd.empty(1) # 生成一个维度为1的随机值
a = mx.nd.array(2)
b = mx.nd.array(3) # b等于3
executor = D.bind(ctx=mx.cpu(), args={'A': a, 'B': b})
print(type(executor))
# print(executor.arg_dict)
executor.forward()
print(executor.outputs[0])
输出:
<class 'mxnet.executor.Executor'>
0.6666667
<NDArray @cpu(0)>