1. 程式人生 > >numpy幾個基本用法

numpy幾個基本用法

INPUT:

print(np.empty((2,3)))
print(np.zeros((2,3)))
print(np.ones((2,3)))
print(np.eye(2))
print(np.random.random((2,3)))

OUTPUT:

[[  2.67276450e+185   1.69506143e+190   1.75184137e+190]
 [  9.48819320e+077   1.63730399e-306   0.00000000e+000]]
[[ 0.  0.  0.]
 [ 0.  0.  0.]]
[[ 1.  1.  1.]
 [ 1.  1.  1.]]
[[ 1.  0.]
 [ 0.  1.]]
[[ 0.44727606  0.64725896  0.57567704]
 [ 0.32165218  0.91636548  0.60890067]]