a1 = 66
b1 = np.tile(a1, (3, 2))
print("b1:")
print(f"{b1}\n",)
c1 = np.tile(a1,2)
print("c1:")
print(f"{c1}")
b1:
[[66 66]
[66 66]
[66 66]]
c1:
[66 66]
a1 = [1, 2, 3]
b1 = np.tile(a1, (3, 2))
print("b1:")
print(f"{b1}\n",)
c1 = np.tile(a1,2)
print("c1:")
print(f"{c1}")
b1:
[[1 2 3 1 2 3]
[1 2 3 1 2 3]
[1 2 3 1 2 3]]
c1:
[1 2 3 1 2 3]
a1 = [[1, 2, 3], [4, 5, 6]]
b1 = np.tile(a1, (3, 2))
print("b1:")
print(f"{b1}\n",)
c1 = np.tile(a1,2)
print("c1:")
print(f"{c1}")
b1:
[[1 2 3 1 2 3]
[4 5 6 4 5 6]
[1 2 3 1 2 3]
[4 5 6 4 5 6]
[1 2 3 1 2 3]
[4 5 6 4 5 6]]
c1:
[[1 2 3 1 2 3]
[4 5 6 4 5 6]]
b1 = np.tile(x, (m, n))会将x在行方向上重复m次,列方向上重复n次,得到b1. b1的维数为2.
c1 = np.tile(x, m)只会将x重复m次,得到c1. 此时c1的维数和x一致.