mxnet-NDArray
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Aug 10 16:13:29 2018 @author: myhaspl """ from mxnet import nd x1=nd.array(((1,2,3),(5,6,7))) x2=nd.array(((10,20,30),(50,60,70))) y1=x1+x2 y2=x1*x2 print y1 print y2 print nd.ones((2,3)) print nd.random.uniform(-1,1,(2,3)) print nd.full((2,2.0) print (x1.shape,x1.size,x1.dtype)
the NDArray,MXNets primary tool for storing and transforming data. I 输出: [[11. 22. 33.] [[ 10. ?40. ?90.] [[1. 1. 1.] [[0.09762704 0.18568921 0.43037868] [[2. 2. 2.] #!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Aug 10 16:13:29 2018 @author: myhaspl """ from mxnet import nd x1=nd.array(((1,7))) x2=nd.array(((10,70))) print x1 print x1.T print nd.dot(x1,x2.T) print x1[:,1] print x1[0,:] print x2[0,2] x1[:,2]=888 print x1 [[1. 2. 3.] [[1. 5.] [[ 140. ?380.] [2. 6.] [1. 2. 3.] [30.] [[ ?1. ? 2. 888.] #!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Aug 10 16:13:29 2018 @author: myhaspl """ from mxnet import nd x1=nd.array(((1,70))) a = x1.asnumpy() print a print nd.array(a) [[1. 2. 3.] [[1. 2. 3.]?[5. 6. 7.]]<NDArray 2x3 @cpu(0)> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |