from mxnet import nd
from time import time
a = nd.ones(shape=1000)
b = nd.ones(shape=1000)
start =time()
c = nd.zeros(shape=1000)for i inrange(1000):
c[i]= a[i]+ b[i]
end =time()
running_time1 = end - start
print('time cost : %.10f sec'% running_time1)
start =time()
d = a + b
end =time()
running_time2 = end - start
print('time cost : %.10f sec'% running_time2)
a = nd.ones(shape=3)
b =10print(a + b)
运行结果
time cost :0.3278212547 sec
time cost :0.0000000000 sec
[11.11.11.]<NDArray 3 @cpu(0)>