tensorflow::ops::ScatterNdAdd
#include <state_ops.h>
Применяет разреженное сложение к отдельным значениям или срезам в переменной.
Summary
ref — это Tensor с рангом P, а indices — это Tensor с рангом Q.
indices должно быть целочисленным тензором, содержащим индексы в ref. Его форма должна быть [d_0, ..., d_{Q-2}, K], где 0 < K <= P.
Наивнутреннее измерение indices (с длиной K) соответствует индексам элементов (если K = P) или срезов (если K < P) вдоль K-го измерения ref.
updates — это Tensor ранга Q-1+P-K с формой:
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
Например, предположим, что мы хотим добавить 4 рассеянных элемента к тензору ранга 1 с 8 элементами. В Python это сложение будет выглядеть так:
ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) indices = tf.constant([[4], [3], [1], [7]]) updates = tf.constant([9, 10, 11, 12]) add = tf.scatter_nd_add(ref, indices, updates) with tf.Session() as sess: print sess.run(add)
Результат обновления ref будет выглядеть так:
[1, 13, 3, 14, 14, 6, 7, 20]
См. tf.scatter_nd, чтобы узнать больше о том, как выполнять обновления срезов.
Аргументы:
- scope: Объект Scope
- ref: Изменяемый Tensor. Должен быть из узла переменной.
- indices: Tensor. Должен быть одного из следующих типов: int32, int64. Tensor индексов в ref.
- updates: Tensor. Должен иметь тот же тип, что и ref. Tensor обновлённых значений для добавления к ref.
Необязательные атрибуты (см. Attrs):
- use_locking: Необязательный bool. По умолчанию True. Если True, присвоение будет защищено блокировкой; в противном случае поведение не определено, но может быть меньше конкуренции.
Возвращает:
-
Output: То же, что и ref. Возвращается для удобства операций, которые хотят использовать обновлённые значения после завершения обновления.
| Конструкторы и деструкторы | |
|---|---|
ScatterNdAdd(const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates) | |
ScatterNdAdd(const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates, const ScatterNdAdd::Attrs & attrs) |
| Общественные атрибуты | |
|---|---|
operation | |
output_ref | |
| Общественные функции | |
|---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const | |
| Общественные статические функции | |
|---|---|
UseLocking(bool x) | |
| Структуры | |
|---|---|
| tensorflow::ops::ScatterNdAdd::Attrs | Необязательные установщики атрибутов для ScatterNdAdd. |
Общественные атрибуты
operation
Operation operation
output_ref
::tensorflow::Output output_ref
Общественные функции
ScatterNdAdd
ScatterNdAdd( const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates )
ScatterNdAdd
ScatterNdAdd( const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates, const ScatterNdAdd::Attrs & attrs )
node
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Общественные статические функции
UseLocking
Attrs UseLocking( bool x )
© 2020 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/versions/r2.4/api_docs/cc/class/tensorflow/ops/scatter-nd-add