文档
参数:
- 整数 则随机打乱
np.arange(x)
- 数组
复制
一份并且使用shuffle
随机打乱
返回值:ndarray
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28In [1]: import numpy as np In [2]: np.random.permutation(10) Out[2]: array([0, 8, 9, 5, 2, 1, 4, 3, 7, 6]) In [3]: np.random.permutation([1, 4, 9, 12, 15]) Out[3]: array([ 9, 12, 1, 4, 15]) In [4]: arr = np.arange(9).reshape((3,3)) In [5]: arr Out[5]: array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) In [6]: np.random.permutation(arr) Out[6]: array([[3, 4, 5], [0, 1, 2], [6, 7, 8]]) In [7]: np.random.permutation(arr) Out[7]: array([[6, 7, 8], [3, 4, 5], [0, 1, 2]])
最后
以上就是无私母鸡最近收集整理的关于numpy.random.permutation的全部内容,更多相关numpy内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复