參考API:https://docs.scipy.org/doc/numpy/reference/routines.random.htmlhtml
API中關於該函數是這樣描述的:dom
Modify a sequence in-place by shuffling its contents.
This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.函數
也就是說,numpy.random,shuffle(x)是進行原地洗牌,直接改變x的值,而無返回值。對於多維度的array來講,只對第一維進行洗牌,好比一個 $ 3 \times 3 $ 的array,只對行之間進行洗牌,而行內內容保持不變。
例子:
3d
API中關於該函數是這樣描述的:htm
Randomly permute a sequence, or return a permuted range.
If x is a multi-dimensional array, it is only shuffled along its first index.blog
也就是說,numpy.random,permutation(x)是返回一個被洗牌過的array,而x不變。對於多維度的array來講,只對第一維進行洗牌,好比一個 $ 3 \times 3 $ 的array,只對行之間進行洗牌,而行內內容保持不變。
例子:
ip