mindspore.numpy.broadcast_to

mindspore.numpy.broadcast_to(array, shape)[源代码]

Broadcasts an array to a new shape.

参数
  • array (Tensor) – The array to broadcast.

  • shape (tuple) – The shape of the desired array.

返回

Tensor, original array broadcast to the given shape.

异常

ValueError – If array cannot be broadcast to shape.

Supported Platforms:

Ascend GPU CPU

示例

>>> import mindspore.numpy as np
>>> x = np.array([1, 2, 3])
>>> output = np.broadcast_to(x, (3, 3))
>>> print(output)
[[1 2 3]
[1 2 3]
[1 2 3]]