maxframe.tensor.repeat#
- maxframe.tensor.repeat(a, repeats, axis=None)[源代码]#
重复张量的元素。
- 参数:
- 返回:
repeated_tensor -- 输出数组,其形状与 a 相同,除了沿给定轴外。
- 返回类型:
Tensor
参见
tile平铺一个张量。
示例
>>> import maxframe.tensor as mt
>>> mt.repeat(3, 4).execute() array([3, 3, 3, 3]) >>> x = mt.array([[1,2],[3,4]]) >>> mt.repeat(x, 2).execute() array([1, 1, 2, 2, 3, 3, 4, 4]) >>> mt.repeat(x, 3, axis=1).execute() array([[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4]]) >>> mt.repeat(x, [1, 2], axis=0).execute() array([[1, 2], [3, 4], [3, 4]])