种子之谜~

简单说下设定好随机种子时,本身不会重现仅在下次运行才会对应起来。

import numpy as np
i=0
np.random.seed(0)
while(i<3):
    print(np.random.randn(1,5))
    i+=1
print("--------------------------")
i=0
np.random.seed(1)
while(i<3):
    print(np.random.randn(1,5))
    i+=1

参考:sklearn.model_selection.train_test_split(random_state=42) 与 np.random.seed(42)的联系和原理详解_Sany 何灿的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/mikewzp/article/details/129692232