初級入門簡要記錄,矩陣運(yùn)算后續(xù)使用重新溫習(xí)補(bǔ)充
導(dǎo)入
import numpy as np?
創(chuàng)建10行10列的數(shù)值為浮點1的矩陣
array_one = np.ones([10,10])
創(chuàng)建10行10列的數(shù)值為浮點0的矩陣
array_zero = np.zeros([10,10])
隨機(jī)數(shù)組
np.random.rand(10, 10)創(chuàng)建指定形狀(示例為10行10列)的數(shù)組(范圍在0至1之間)
np.random.uniform(0, 100)創(chuàng)建指定范圍內(nèi)的一個數(shù)
np.random.randint(0, 100)?創(chuàng)建指定范圍內(nèi)的一個整數(shù)
給定均值/標(biāo)準(zhǔn)差/維度的正態(tài)分布
np.random.normal(1.75, 0.1, (2, 3))
條件判斷
arr = np.random.rand(2, 2)*10
print(arr)
arr_new = arr > 5
print(arr_new)
arr_new = np.where(arr > 5, 'reverse_false', 'reverse_true')
print(arr_new)

最大值amax( 數(shù)組; axis=0/1; 0表示列1表示行),最小值amin,平均值mean,方差std
np.amax(arr, axis=0)
np.amax(arr, axis=1)

附:numpy手冊:
https://www.w3cschool.cn/doc_numpy_1_13