mindspore.numpy.broadcast_to

View Source On Gitee
mindspore.numpy.broadcast_to(array, shape)[source]

Broadcasts an array to a new shape.

Parameters
  • array (Tensor) – The array to broadcast.

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

Returns

Tensor, original array broadcast to the given shape.

Raises

ValueError – If array cannot be broadcast to shape.

Supported Platforms:

Ascend GPU CPU

Example

>>> 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]]