from NumPy import *
函式形式: tile(A,rep)
功能:重複A的各個維度
引數型別:
- A: Array類的都可以
- rep:A沿著各個維度重複的次數
這個英文單詞的本意是:貼瓷磚,還挺形象的。
舉例:
tile([17,29],2),如果rep引數是一個整數,則表示重複A中的元素rep次,即行數(即維度)只有1維,所以2的意思是在“列”這個維度上重複2次
輸出[17,29,17,29]
tile([29,17],(3,5))
此時的(3,5)和[3,5]是相同的效果。
結果是3組,每組重複5次,也可以理解為二維表,3行,5列。先分3組(重複3次),每組重複5次。
array([[29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17]])
tile([29,17],[3,5,7])
結果是3組,每組一個二維表,每個二維表5行,7列,可以理解為三維表
array([[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17, 29, 17]]])
tile([29,17],[3,5,7,4])
結果是4組,怎樣理解?我也不知道,這已經超過了人類空間的認知。
依次分組,先分3組重複,然後分5組重複,然後分7組,最後重複4次。
如果5維會怎樣?也是繼續按組重複下去。先分5組,用中括號分隔。
array([[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]],
[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]],
[[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]],
[[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17],
[29, 17, 29, 17, 29, 17, 29, 17]]]])