tf.keras.ops.scatter | TensorFlow v2.16.1 (original) (raw)
tf.keras.ops.scatter
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)
| 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. |
Example:
indices = [[0, 1], [1, 1]]
values = np.array([1., 1.])
keras.ops.scatter(indices, values, shape=(2, 2))
array([[0., 1.],
[0., 1.]])
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.