Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::
ops::
ResourceScatterNdAdd
#include <state_ops.h>
Applies sparse addition to individual values or slices in a
Variable
.
Summary
ref
is a
Tensor
with rank
P
and
indices
is a
Tensor
of rank
Q
.
indices
must be integer tensor, containing indices into
ref
. It must be shape
[d_0, ..., d_{Q-2}, K]
where
0 < K <= P
.
The innermost dimension of
indices
(with length
K
) corresponds to indices into elements (if
K = P
) or slices (if
K < P
) along the
K
th dimension of
ref
.
updates
is
Tensor
of rank
Q-1+P-K
with shape:
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
For example, say we want to add 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that addition would look like this:
ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True)
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)
The resulting update to ref would look like this:
[1, 13, 3, 14, 14, 6, 7, 20]
See
tf.scatter_nd
for more details about how to make updates to slices.
Args:
-
scope: A
Scope
object
-
ref: A resource handle. Must be from a VarHandleOp.
-
indices: A
Tensor
. Must be one of the following types: int32, int64. A tensor of indices into ref.
-
updates: A
Tensor
. Must have the same type as ref. A tensor of values to add to ref.
Optional attributes (see
Attrs
):
-
use_locking: An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
Returns:
Public attributes
Public functions
operator::tensorflow::Operation
operator::tensorflow::Operation() const
Public static functions
UseLocking
Attrs UseLocking(
bool x
)
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 2021-08-16 UTC.
[null,null,["Last updated 2021-08-16 UTC."],[],[],null,["# tensorflow::ops::ResourceScatterNdAdd Class Reference\n\ntensorflow::\nops::\nResourceScatterNdAdd\n=======================================\n\n`\n#include \u003cstate_ops.h\u003e\n`\n\n\nApplies sparse addition to individual values or slices in a\n[Variable](/versions/r2.6/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable)\n.\n\nSummary\n-------\n\n\n`\nref\n`\nis a\n`\n`[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n`\nwith rank\n`\nP\n`\nand\n`\nindices\n`\nis a\n`\n`[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n`\nof rank\n`\nQ\n`\n.\n\n\n`\nindices\n`\nmust be integer tensor, containing indices into\n`\nref\n`\n. It must be shape\n`\n[d_0, ..., d_{Q-2}, K]\n`\nwhere\n`\n0 \u003c K \u003c= P\n`\n.\n\n\nThe innermost dimension of\n`\nindices\n`\n(with length\n`\nK\n`\n) corresponds to indices into elements (if\n`\nK = P\n`\n) or slices (if\n`\nK \u003c P\n`\n) along the\n`\nK\n`\nth dimension of\n`\nref\n`\n.\n\n\n`\nupdates\n`\nis\n`\n`[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n`\nof rank\n`\nQ-1+P-K\n`\nwith shape:\n\n\n```transact-sql\n[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]\n```\n\n\u003cbr /\u003e\n\n\nFor example, say we want to add 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that addition would look like this:\n\n\n```gdscript\nref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True)\nindices = tf.constant([[4], [3], [1], [7]])\nupdates = tf.constant([9, 10, 11, 12])\nadd = tf.scatter_nd_add(ref, indices, updates)\nwith tf.Session() as sess:\n print sess.run(add)\n```\n\n\u003cbr /\u003e\n\n\nThe resulting update to ref would look like this: \n\n```text\n[1, 13, 3, 14, 14, 6, 7, 20]\n```\n\n\u003cbr /\u003e\n\n\nSee\n`\ntf.scatter_nd\n`\nfor more details about how to make updates to slices.\n\n\nArgs:\n\n- scope: A [Scope](/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- ref: A resource handle. Must be from a VarHandleOp.\n- indices: A [Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) . Must be one of the following types: int32, int64. A tensor of indices into ref.\n- updates: A [Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) . Must have the same type as ref. A tensor of values to add to ref.\n\n\u003cbr /\u003e\n\n\nOptional attributes (see\n`\n`[Attrs](/versions/r2.6/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_add_1_1_attrs)`\n`\n):\n\n- use_locking: An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.\n\n\u003cbr /\u003e\n\n\nReturns:\n\n- the created `\n `[Operation](/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)`\n `\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| ` `[ResourceScatterNdAdd](#classtensorflow_1_1ops_1_1_resource_scatter_nd_add_1ac61a21576bf08251b3104cbc6368deaf)` (const :: `[tensorflow::Scope](/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates) ` ||\n| ` `[ResourceScatterNdAdd](#classtensorflow_1_1ops_1_1_resource_scatter_nd_add_1ac36189a70aec0cf684abb8369d023498)` (const :: `[tensorflow::Scope](/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ResourceScatterNdAdd::Attrs](/versions/r2.6/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_add_1_1_attrs)` & attrs) ` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|\n| ` `[operation](#classtensorflow_1_1ops_1_1_resource_scatter_nd_add_1ac94d129f0515c41be9253e727aaa988f)` ` | ` `[Operation](/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)` ` |\n\n| ### Public functions ||\n|------------------------------------------------------------------------------------------------------------------------------------------|-----|\n| ` `[operator::tensorflow::Operation](#classtensorflow_1_1ops_1_1_resource_scatter_nd_add_1a92cc69e6d97d0804f540a89ecc837f72)` () const ` | ` ` |\n\n| ### Public static functions ||\n|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` `[UseLocking](#classtensorflow_1_1ops_1_1_resource_scatter_nd_add_1a817236acee28e1372228a96333567b07)` (bool x) ` | ` `[Attrs](/versions/r2.6/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-add/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_add_1_1_attrs)` ` |\n\n| ### Structs ||\n|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow:: ops:: ResourceScatterNdAdd:: Attrs](/versions/r2.6/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-add/attrs) | Optional attribute setters for [ResourceScatterNdAdd](/versions/r2.6/api_docs/cc/class/tensorflow/ops/resource-scatter-nd-add#classtensorflow_1_1ops_1_1_resource_scatter_nd_add) . |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### ResourceScatterNdAdd\n\n```gdscript\n ResourceScatterNdAdd(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ResourceScatterNdAdd\n\n```gdscript\n ResourceScatterNdAdd(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ResourceScatterNdAdd::Attrs & attrs\n)\n``` \n\n### operator::tensorflow::Operation\n\n```gdscript\n operator::tensorflow::Operation() const \n``` \n\nPublic static functions\n-----------------------\n\n### UseLocking\n\n```text\nAttrs UseLocking(\n bool x\n)\n```"]]