Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
tensoreflusso:: ops:: ResourceScatterNdAdd
#include <state_ops.h>
Applica un'addizione sparsa a singoli valori o sezioni in una Variabile .
Riepilogo
ref
è un Tensor
di rango P
e indices
è un Tensor
di rango Q
.
indices
devono essere tensori interi, contenenti indici in ref
. Deve essere di forma [d_0, ..., d_{Q-2}, K]
dove 0 < K <= P
.
La dimensione più interna degli indices
(con lunghezza K
) corrisponde agli indici in elementi (se K = P
) o fette (se K < P
) lungo la K
-esima dimensione di ref
.
updates
sono Tensor
di rango Q-1+PK
con forma:
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
Ad esempio, supponiamo di voler aggiungere 4 elementi sparsi a un tensore di rango 1 a 8 elementi. In Python, tale aggiunta sarebbe simile a questa:
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)
L'aggiornamento risultante a ref sarebbe simile al seguente:
[1, 13, 3, 14, 14, 6, 7, 20]
Vedi tf.scatter_nd
per maggiori dettagli su come apportare aggiornamenti alle sezioni.
Argomenti:
- scope: un oggetto Scope
- ref: un handle di risorsa. Deve provenire da un VarHandleOp.
- indici: A Tensore . Deve essere uno dei seguenti tipi: int32, int64. Un tensore di indici nel rif.
- aggiornamenti: Un Tensore . Deve essere dello stesso tipo del rif. Un tensore di valori da aggiungere al rif.
Attributi facoltativi (vedi Attrs
):
- use_locking: un valore bool opzionale. Il valore predefinito è Vero. Se True, l'assegnazione sarà protetta da un lucchetto; altrimenti il comportamento non è definito, ma può mostrare meno contesa.
Resi:
Attributi pubblici
Funzioni pubbliche
operator::tensorflow::Operazione
operator::tensorflow::Operation() const
Funzioni pubbliche statiche
UsaLocking
Attrs UseLocking(
bool x
)
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[],[],null,["# tensorflow::ops::ResourceScatterNdAdd Class Reference\n\ntensorflow::ops::ResourceScatterNdAdd\n=====================================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse addition to individual values or slices in a [Variable](/versions/r1.15/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable).\n\nSummary\n-------\n\n`ref` is a [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with rank `P` and `indices` is a [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of rank `Q`.\n\n`indices` must be integer tensor, containing indices into `ref`. It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 \u003c K \u003c= P`.\n\nThe innermost dimension of `indices` (with length `K`) corresponds to indices into elements (if `K = P`) or slices (if `K \u003c P`) along the `K`th dimension of `ref`.\n\n`updates` is [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of rank `Q-1+P-K` with 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\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\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\nSee `tf.scatter_nd` for more details about how to make updates to slices.\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/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/r1.15/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/r1.15/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\nOptional attributes (see [Attrs](/versions/r1.15/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- 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\nReturns:\n\n- the created [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)\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/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ResourceScatterNdAdd::Attrs](/versions/r1.15/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/r1.15/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/r1.15/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/r1.15/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-add/attrs) | Optional attribute setters for [ResourceScatterNdAdd](/versions/r1.15/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```"]]