跨平台 numpy.random.seed() [英] cross platform numpy.random.seed()

查看:65
本文介绍了跨平台 numpy.random.seed()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档 说:

兼容性保证 一个固定的种子和一系列固定的调用使用相同参数的RandomState"方法将始终产生直到舍入误差的结果相同,除非值是不正确.不正确的值将被修复,NumPy 版本在修复的内容将在相关文档字符串中注明.现有参数范围的扩展和新参数的添加只要之前的行为保持不变,就允许使用参数.

Compatibility Guarantee A fixed seed and a fixed series of calls to ‘RandomState’ methods using the same parameters will always produce the same results up to roundoff error except when the values were incorrect. Incorrect values will be fixed and the NumPy version in which the fix was made will be noted in the relevant docstring. Extension of existing parameter ranges and the addition of new parameters is allowed as long the previous behavior remains unchanged.

没有提到操作系统.

如果我在 windows 和 linux 上调用 np.random.seed(42) ,之后生成的随机数是否相同?不同版本的 64 位 Ubuntu 是否相同?

If I call np.random.seed(42) on windows and linux, will the random numbers generated afterwards be the same ? Will it be the same across different versions of 64bit Ubuntu ?

我假设 rng 使用系统库,因此代码可能不可移植.如果这是真的,是否有解决办法?我知道这可能很丑陋,就像为模拟 Windows 的东西更改 linux rng 系统一样.但我已准备好采用创造性的解决方案.

I assume that the rng uses system libraries, so the code is probably not portable. If that's true, is there a fix ? I know that this would probably be ugly, like changing the linux rng system for something that emulates windows. But I'm ready for creative solutions.

推荐答案

根据 sascha 的评论,随机数与平台无关.

As per sascha’s comment, random numbers are platform independent.

这篇关于跨平台 numpy.random.seed()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆