我曾经以为设置种子会每次得到相同的结果。但是我每次得到的结果都不同。如何设置种子,使得我们每次获得相同的结果?
以下是MWE:
import numpy as np
import pandas as pd
random_state = 100
np.random.state = random_state
np.random.seed = random_state
mu, sigma = 0, 0.25
eps = np.random.normal(mu,sigma,size=100)
print(eps[0])
每次运行得到的结果都不同。
更新:
我不能使用np.random.seed(xxx)
np.random.seed
。关闭所有内容并重新开始,而不要覆盖。或者尝试使用del np.random.seed
。 - SpghttCd