mindspore.ops.Tile

class mindspore.ops.Tile[源代码]

按照给定的次数复制输入Tensor。

更多参考详见 mindspore.ops.tile()

输入:
  • input_x (Tensor) - 1-D或更高维的Tensor,设其shape为 (x1,x2,...,xS)

  • multiples (tuple[int]) - 指定复制次数的参数,参数类型为tuple,数据类型为整数。如 (y1,y2,...,yS)multiples 的长度不能小于 input_x 的维度。只支持常量值。

输出:

Tensor,具有与 input_x 相同的数据类型。假设 multiples 的长度为 dinput_x 的维度为 input_x.diminput_x 的shape为 (x1,x2,...,xS)

  • 如果 input_x.dim = d ,将其相应位置的shape相乘,输出的shape为 (x1y1,x2y2,...,xSyS)

  • 如果 input_x.dim < d ,在 input_x 的shape的前面填充1,直到它们的长度一致。例如将 input_x 的shape设置为 (1,...,x1,x2,...,xS) ,然后可以将其相应位置的shape相乘,输出的shape为 (1y1,...,xRyR,xSyS)

支持平台:

Ascend GPU CPU

样例:

>>> tile = ops.Tile()
>>> input_x = Tensor(np.array([[1, 2], [3, 4]]), mindspore.float32)
>>> multiples = (2, 3)
>>> output = tile(input_x, multiples)
>>> print(output)
[[1.  2.  1.  2.  1.  2.]
 [3.  4.  3.  4.  3.  4.]
 [1.  2.  1.  2.  1.  2.]
 [3.  4.  3.  4.  3.  4.]]
>>> multiples = (2, 3, 2)
>>> output = tile(input_x, multiples)
>>> print(output)
[[[1. 2. 1. 2.]
  [3. 4. 3. 4.]
  [1. 2. 1. 2.]
  [3. 4. 3. 4.]
  [1. 2. 1. 2.]
  [3. 4. 3. 4.]]
 [[1. 2. 1. 2.]
  [3. 4. 3. 4.]
  [1. 2. 1. 2.]
  [3. 4. 3. 4.]
  [1. 2. 1. 2.]
  [3. 4. 3. 4.]]]