标签:cpu net usr create random imp bin data array
#!/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,3), 2.0)
print (x1.shape, x1.size, x1.dtype)
the NDArray, MXNets primary tool for storing and transforming data. I
输出:
[[11. 22. 33.]
?[55. 66. 77.]]
<NDArray 2x3 @cpu(0)>
[[ 10. ?40. ?90.]
?[250. 360. 490.]]
<NDArray 2x3 @cpu(0)>
[[1. 1. 1.]
?[1. 1. 1.]]
<NDArray 2x3 @cpu(0)>
[[0.09762704 0.18568921 0.43037868]
?[0.6885315 ?0.20552671 0.71589124]]
<NDArray 2x3 @cpu(0)>
[[2. 2. 2.]
?[2. 2. 2.]]
<NDArray 2x3 @cpu(0)>
((2L, 3L), 6L, <type ‘numpy.float32‘>)
#!/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)))
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.]
?[5. 6. 7.]]
<NDArray 2x3 @cpu(0)>
[[1. 5.]
?[2. 6.]
?[3. 7.]]
<NDArray 3x2 @cpu(0)>
[[ 140. ?380.]
?[ 380. 1100.]]
<NDArray 2x2 @cpu(0)>
[2. 6.]
<NDArray 2 @cpu(0)>
[1. 2. 3.]
<NDArray 3 @cpu(0)>
[30.]
<NDArray 1 @cpu(0)>
[[ ?1. ? 2. 888.]
?[ ?5. ? 6. 888.]]
<NDArray 2x3 @cpu(0)>
#!/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)))
a = x1.asnumpy()
print a
print nd.array(a)
[[1. 2. 3.]
?[5. 6. 7.]]
[[1. 2. 3.]
?[5. 6. 7.]]
<NDArray 2x3 @cpu(0)>
标签:cpu net usr create random imp bin data array
原文地址:http://blog.51cto.com/13959448/2316505