您的位置:首页 > 其它

np.random.seed(0)的作用:作用:使得随机数据可预测

2017-10-07 15:33 393 查看


转自:http://blog.csdn.net/a821235837/article/details/52839050

  

[python] view
plain copy

 print?

>>>> numpy.random.seed(0) ; numpy.random.rand(4)  

array([ 0.55,  0.72,  0.6 ,  0.54])  

>>> numpy.random.seed(0) ; numpy.random.rand(4)  

array([ 0.55,  0.72,  0.6 ,  0.54])  

当我们设置相同的seed,每次生成的随机数相同。

如果不设置seed,则每次会生成不同的随机数

[python] view
plain copy

 print?

>>> numpy.random.rand(4)  

array([ 0.42,  0.65,  0.44,  0.89])  

>>> numpy.random.rand(4)  

array([ 0.96,  0.38,  0.79,  0.53])  

参考资料:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: