tensorflow::ops::ScatterNdSub
#include <state_ops.h>
Применяет разреженное вычитание к отдельным значениям или срезам в переменной.
Summary
в данной переменной в соответствии с indices.
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]) sub = tf.scatter_nd_sub(ref, indices, updates) with tf.Session() as sess: print sess.run(sub)
Результирующее обновление ref будет выглядеть так:
[1, -9, 3, -6, -4, 6, 7, -4]
См. tf.scatter_nd, чтобы узнать больше о том, как выполнять обновления срезов.
Аргументы:
- scope: Объект Scope
- ref: Изменяемый Tensor. Должен быть из узла Variable.
- indices: Tensor. Должен быть одного из следующих типов: int32, int64. Tensor индексов в ref.
- updates: Tensor. Должен иметь тот же тип, что и ref. Tensor обновленных значений для вычитания из ref.
Необязательные атрибуты (см. Attrs):
- use_locking: Необязательный bool. По умолчанию True. Если True, присвоение будет защищено блокировкой; в противном случае поведение не определено, но может иметь меньшую конкуренцию.
Возвращает:
-
Output: То же, что и ref. Возвращается для удобства операций, которые хотят использовать обновленные значения после завершения обновления.
| Конструкторы и деструкторы | |
|---|---|
ScatterNdSub(const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates) | |
ScatterNdSub(const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates, const ScatterNdSub::Attrs & attrs) |
| Общественные атрибуты | |
|---|---|
operation | |
output_ref | |
| Общественные функции | |
|---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const | |
| Общественные статические функции | |
|---|---|
UseLocking(bool x) | |
| Структуры | |
|---|---|
| tensorflow::ops::ScatterNdSub::Attrs | Необязательные атрибуты для установки ScatterNdSub. |
Общественные атрибуты
operation
Operation operation
output_ref
::tensorflow::Output output_ref
Общественные функции
ScatterNdSub
ScatterNdSub( const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates )
ScatterNdSub
ScatterNdSub( const ::tensorflow::Scope & scope, ::tensorflow::Input ref, ::tensorflow::Input indices, ::tensorflow::Input updates, const ScatterNdSub::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 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-sub