pytho3.5 + Numpy 关于tile函数,做了下面三个试验。
场景1
a = [[1,2,3],[4,5]]
b = tile(a,[2,3])
b
array([[[1, 2, 3], [4, 5], [1, 2, 3], [4, 5], [1, 2, 3], [4, 5]],
[[1, 2, 3], [4, 5], [1, 2, 3], [4, 5], [1, 2, 3], [4, 5]]], dtype=object)场景2
a = [[1,2,3],[4,5,6]]
b = tile(a,[2,3])
b
array([[1, 2, 3, 1, 2, 3, 1, 2, 3],
[4, 5, 6, 4, 5, 6, 4, 5, 6],
[1, 2, 3, 1, 2, 3, 1, 2, 3],
[4, 5, 6, 4, 5, 6, 4, 5, 6]])
场景3
a = [[1,2,3],[4,5,6,7]]
b = tile(a,[2,3])
b
array([[[1, 2, 3], [4, 5, 6, 7], [1, 2, 3], [4, 5, 6, 7], [1, 2, 3],
[4, 5, 6, 7]],
[[1, 2, 3], [4, 5, 6, 7], [1, 2, 3], [4, 5, 6, 7], [1, 2, 3],
[4, 5, 6, 7]]], dtype=object)
上述场景1、场景3 比较容易理解。但场景2的输出,为什么不是下面的输出呢?
array([[[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6], [1, 2, 3],
[4, 5, 6]],
[[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6], [1, 2, 3],
[4, 5, 6]]])