tf.keras.ops.scatter
Возвращает тензор формы shape, где indices устанавливаются в values.
tf.keras.ops.scatter(
indices, values, shape
)
В общем случае, эта операция выполняет zeros[indices] = updates и возвращает результат. Она эквивалентна:
zeros = keras.ops.zeros(shape) output = keras.ops.scatter_update(zeros, indices, values)
| Аргументы | |
|---|---|
indices | Тензор или список/кортеж, определяющий индексы для значений в values. |
values | Тензор, значения, которые будут установлены по indices. |
shape | Форма выходного тензора. |
Пример:
indices = [[0, 1], [1, 1]]
values = np.array([1., 1.])
keras.ops.scatter(indices, values, shape=(2, 2))
array([[0., 1.],
[0., 1.]])
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/scatter