np.random.seed()产生随机数规则
import numpy as np
if __name__ == '__main__':
np.random.seed(1)
L1 = np.random.randn(1, 3)
np.random.seed(1)
L2 = np.random.randn(1, 3)
np.random.seed(2)
L3 = np.random.randn(1, 3)
L4 = np.random.randn(1, 3)
np.random.seed(2)
L5 = np.random.randn(1, 3)
print(L1)
print(L2)
print(L3)
print(L4)
print(L5)
得出结果
[[ 1.62434536 -0.61175641 -0.52817175]]
[[ 1.62434536 -0.61175641 -0.52817175]]
[[-0.41675785 -0.05626683 -2.1361961 ]]
[[ 1.64027081 -1.79343559 -0.84174737]]
[[-0.41675785 -0.05626683 -2.1361961 ]]
结论:产生随机数前,调用参数相同的seed(),则得出的随机数相同,否则不同