先贴参考链接:
https://stackoverflow.com/questions/21494489/what-does-numpy-random-seed0-do
numpy.random.seed(num):如果使用相同的num,则每次生成的随机数都相同。
1.无num参数
代码:
import numpy as np
for i in range(5):
np.random.seed()
perm = np.random.permutation(10)
print(perm)
2.num为任意整数值(但每次都相同)
代码:
import numpy as np
for i in range(5):
np.random.seed(10)
perm = np.random.permutation(10)
print(perm)
3.num为任意整数值(但每次都不同)
代码:
import numpy as np
for i in range(5):
np.random.seed(i)
perm = np.random.permutation(10)
print(perm)
4.numpy.random.rand()
代码:
import numpy as np
for i in range(5):
np.random.rand()
perm = np.random.permutation(10)
print(perm)