# tf.broadcast_to

<br />

|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/broadcast_to) |

Broadcast an array for a compatible shape.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.broadcast_to`](https://www.tensorflow.org/api_docs/python/tf/broadcast_to)

<br />

    tf.broadcast_to(
        input, shape, name=None
    )

Broadcasting is the process of making arrays to have compatible shapes
for arithmetic operations. Two shapes are compatible if for each
dimension pair they are either equal or one of them is one. When trying
to broadcast a Tensor to a shape, it starts with the trailing dimensions,
and works its way forward.

For example,

    x = tf.constant([1, 2, 3])
    y = tf.broadcast_to(x, [3, 3])
    sess.run(y)
    array([[1, 2, 3],
           [1, 2, 3],
           [1, 2, 3]], dtype=int32)

In the above example, the input Tensor with the shape of `[1, 3]`
is broadcasted to output Tensor with shape of `[3, 3]`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input` | A `Tensor`. A Tensor to broadcast. |
| `shape` | A `Tensor`. Must be one of the following types: `int32`, `int64`. An 1-D `int` Tensor. The shape of the desired output. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor`. Has the same type as `input`. ||

<br />