mindspore.numpy.tile
- mindspore.numpy.tile(a, reps)[源代码]
- 通过重复 - a指定次数构造一个数组,次数由- reps给出。 如果- reps的长度为- d,结果将具有- max(d, a.ndim)的维度。如果- a.ndim < d,则通过在前面添加新轴将- a提升为- d维。因此,shape为- (3,)的数组会被提升为- (1, 3)以进行二维复制,或- (1, 1, 3)以进行三维复制。如果这不是所需的行为,可以在调用此函数之前手动将- a提升为- d维。如果- a.ndim > d,则通过在前面添加1来提升- reps为- a.ndim。因此,对于shape为- (2, 3, 4, 5)的- a,- reps为- (2, 2)被视为- (1, 1, 2, 2)。- 参数:
- a (Tensor) - 输入数组。 
- reps (int, ints的序列) - 在每个轴上重复 - a的次数。
 
- 返回:
- Tensor,重复后的输出数组。 
- 异常:
- TypeError - 如果输入不是Tensor。 
 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> import mindspore.numpy as np >>> a = np.array([0, 1, 2]) >>> output = np.tile(a, 2) >>> print(output) [0 1 2 0 1 2] >>> output = np.tile(a, (2, 2)) >>> print(output) [[0 1 2 0 1 2] [0 1 2 0 1 2]] >>> output = np.tile(a, (2, 1, 2)) >>> print(output) [[[0 1 2 0 1 2]] [[0 1 2 0 1 2]]]