简体   繁体   English

关于 np.random.permutation 种子的问题

[英]a question about the seed of np.random.permutation

I'm trying to shuffle my data along the first axis.我正在尝试沿第一个轴打乱我的数据。 The code is as following:代码如下:

shuffle_indexes = np.random.permutation(new_data.shape[0])
new_data = new_data[shuffle_indexes]

I wanna set a random seed to the function in order to replicate the result and control variables.我想为 function 设置一个随机种子,以复制结果和控制变量。 But I check the official website and I didn't find such parameters for the function.但是查了官网,没有找到function的参数。 How can I solve this problem?我怎么解决这个问题?

numpy.random.seed(0)

Sets the seed.设置种子。

In your specific case you can also short the code to shuffle the array using在您的特定情况下,您还可以缩短代码以使用

numpy.random.shuffle(array)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 np.random.permutation 与种子? - np.random.permutation with seed? np.random.permutation,np.random.choice的时间性能 - Time performance of np.random.permutation, np.random.choice 函数np.random.permutation是否可以替换? - Does the function np.random.permutation work with or without replacement? 为什么 np.random.default_rng().permutation(n) 优于原始的 np.random.permutation(n)? - Why is np.random.default_rng().permutation(n) preferred over the original np.random.permutation(n)? 从命令行运行.py文件但不在juypter笔记本中运行np.random.permutation时出现ValueError - ValueError on np.random.permutation when running .py file from command line but not in juypter notebook 使用 len() function 和使用 np.random.permutation 索引时的结果差异 - Difference in result while using len() function and index with np.random.permutation 包含混合元素的列表的置换列表(np.random.permutation()失败,出现ValueError) - Permute list of lists with mixed elements (np.random.permutation() fails with ValueError) 带有种子的固定随机排列 - A fixed, random permutation with a seed np.random.seed(1) 和 np.random.seed(0) 的区别? - Difference between np.random.seed(1) and np.random.seed(0)? np.random.seed() 和 np.random.RandomState() 之间的区别 - Difference between np.random.seed() and np.random.RandomState()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM