array([[0.50122984, 0.98824375, 0.81388012],
[0.60951775, 0.02055326, 0.97622093]])
生成随机种子np.random
prng = np.random.RandomState(123456789) # 定义局部种子
prng.rand(2, 4) #生成2行4列矩阵
from numpy import random
注意,如果是 import numpy as np 的话,是 x = np.random.rand(2, 3)
x = random.rand(2, 3)#生成2行4列矩阵
[[ 0.1169922 0.08614147 0.17997144]
[ 0.5694889 0.43067372 0.62135592]]
x, y = random.rand(2, 3)
【11.|11. 创建二维随机数组 np.random.rand(2,3)】print(x)
print(y)
[ 0.60527337 0.78765269 0.71884661]
[ 0.67420571 0.946359 0.7632273 ]