You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.ops.Tile.rst 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. mindspore.ops.Tile
  2. ===================
  3. .. py:class:: mindspore.ops.Tile(*args, **kwargs)
  4. 按照给定的次数复制Tensor。
  5. 通过复制 `multiples` 次 `input_x` 来创建新的Tensor。输出Tensor的第i维度有 `input_x.shape[i] * multiples[i]` 个元素,并且 `input_x` 的值沿第i维度被复制 `multiples[i]` 次。
  6. .. note::
  7. `multiples` 的长度必须大于或等于 `input_x` 的维度。
  8. **输入:**
  9. - **input_x** (Tensor) - 1-D或更高的Tensor。将输入Tensor的shape设置为 :math:`(x_1, x_2, ..., x_S)` 。
  10. - **multiples** (tuple[int]) - 输入tuple由多个整数构成,如 :math:`(y_1, y_2, ..., y_S)` 。`multiples` 的长度不能小于 `input_x` 的维度。只支持常量值。
  11. **输出:**
  12. Tensor,具有与 `input_x` 相同的数据类型。假设 `multiples` 的长度为 `d` ,`input_x` 的维度为 `input_x.dim`。
  13. - 如果 `input_x.dim = d`: 将其相应位置的shape相乘,输出的shape为 :math:`(x_1*y_1, x_2*y_2, ..., x_S*y_S)` 。
  14. - 如果 `input_x.dim < d`: 在 `input_x` 的shape的前面填充1,直到它们的长度一致。例如将 `input_x` 的shape设置为 :math:`(1, ..., x_1, ..., x_R, x_S)` ,然后可以将其相应位置的shape相乘,输出的shape为 :math:`(1*y_1, ..., x_R*y_R, x_S*y_S)` 。
  15. **异常:**
  16. - **TypeError** - `multiples` 不是tuple或者其元素并非全部是int。
  17. - **ValueError** - `multiples` 的元素并非全部大于0。
  18. - **ValueError** - `multiples` 的长度小于 `input_x` 中的维度。
  19. **支持平台:**
  20. ``Ascend`` ``GPU`` ``CPU``
  21. **样例:**
  22. >>> tile = ops.Tile()
  23. >>> input_x = Tensor(np.array([[1, 2], [3, 4]]), mindspore.float32)
  24. >>> multiples = (2, 3)
  25. >>> output = tile(input_x, multiples)
  26. >>> print(output)
  27. [[1. 2. 1. 2. 1. 2.]
  28. [3. 4. 3. 4. 3. 4.]
  29. [1. 2. 1. 2. 1. 2.]
  30. [3. 4. 3. 4. 3. 4.]]
  31. >>> multiples = (2, 3, 2)
  32. >>> output = tile(input_x, multiples)
  33. >>> print(output)
  34. [[[1. 2. 1. 2.]
  35. [3. 4. 3. 4.]
  36. [1. 2. 1. 2.]
  37. [3. 4. 3. 4.]
  38. [1. 2. 1. 2.]
  39. [3. 4. 3. 4.]]
  40. [[1. 2. 1. 2.]
  41. [3. 4. 3. 4.]
  42. [1. 2. 1. 2.]
  43. [3. 4. 3. 4.]
  44. [1. 2. 1. 2.]
  45. [3. 4. 3. 4.]]]