np.random.permutation与种子? [英] np.random.permutation with seed?

查看:891
本文介绍了np.random.permutation与种子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用np.random.permutation的种子,例如

np.random.permutation(10, seed=42)

我收到以下错误:

"permutation() takes no keyword arguments"

我还能怎么做?谢谢.

推荐答案

如果您需要一行,可以创建一个新的RandomState,并在其上调用permutation:

If you want it in one line, you can create a new RandomState, and call the permutation on that:

np.random.RandomState(seed=42).permutation(10)

这比只设置np.random的种子要好,因为它只会产生局部效果.

This is better than just setting the seed of np.random, as it will have only a localized effect.

这篇关于np.random.permutation与种子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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