<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/core.py#L305-L333) |

Returns a tensor of shape `shape` where `indices` are set to `values`.

    tf.keras.ops.scatter(
        indices, values, shape
    )

At a high level, this operation does `zeros[indices] = updates` and
returns the output. It is equivalent to:

    zeros = keras.ops.zeros(shape)
    output = keras.ops.scatter_update(zeros, indices, values)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `indices` | A tensor or list/tuple specifying indices for the values in `values`. |
| `values` | A tensor, the values to be set at `indices`. |
| `shape` | Shape of the output tensor. |

<br />

#### Example:

    indices = [[0, 1], [1, 1]]
    values = np.array([1., 1.])
    keras.ops.scatter(indices, values, shape=(2, 2))
    array([[0., 1.],
           [0., 1.]])