Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
przepływ tensorowy:: ops:: ResourceScatterNdSub
#include <state_ops.h>
Stosuje rzadkie odejmowanie do poszczególnych wartości lub wycinków w zmiennej .
Streszczenie
ref
jest Tensor
o randze P
, a indices
jest Tensor
o randze Q
indices
muszą być tensorami całkowitymi, zawierającymi indeksy w ref
. Musi to być kształt [d_0, ..., d_{Q-2}, K]
gdzie 0 < K <= P
.
Najbardziej wewnętrzny wymiar indices
(o długości K
) odpowiada indeksom na elementy (jeśli K = P
) lub plasterki (jeśli K < P
) wzdłuż K
-tego wymiaru ref
.
updates
to Tensor
rangi Q-1+PK
o kształcie:
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
Załóżmy na przykład, że chcemy odjąć 4 rozproszone elementy od tensora rangi 1 zawierającego 8 elementów. W Pythonie to odejmowanie wyglądałoby następująco:
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])
sub = tf.scatter_nd_sub(ref, indices, updates)
with tf.Session() as sess:
print sess.run(sub)
Wynikowa aktualizacja ref będzie wyglądać następująco:
[1, -9, 3, -6, -4, 6, 7, -4]
Zobacz tf.scatter_nd
, aby uzyskać więcej szczegółów na temat aktualizowania plasterków.
Argumenty:
- zakres: Obiekt Scope
- ref: Uchwyt zasobu. Musi pochodzić z VarHandleOp.
- indeksy: Tensor . Musi to być jeden z następujących typów: int32, int64. Tensor indeksów w ref.
- aktualizacje: Tensor . Musi mieć ten sam typ co ref. Tensor wartości do dodania do ref.
Opcjonalne atrybuty (patrz Attrs
):
- use_locking: opcjonalny bool. Wartość domyślna to Prawda. Jeśli ma wartość True, przypisanie będzie chronione zamkiem; w przeciwnym razie zachowanie jest niezdefiniowane, ale może wykazywać mniejszą rywalizację.
Zwroty:
Atrybuty publiczne
Funkcje publiczne
operator::tensorflow::Operacja
operator::tensorflow::Operation() const
Publiczne funkcje statyczne
Użyj Blokowania
Attrs UseLocking(
bool x
)
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[],[],null,["# tensorflow::ops::ResourceScatterNdSub Class Reference\n\ntensorflow::ops::ResourceScatterNdSub\n=====================================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse subtraction to individual values or slices in a [Variable](/versions/r2.0/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable).\n\nSummary\n-------\n\n`ref` is a [Tensor](/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with rank `P` and `indices` is a [Tensor](/versions/r2.0/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/r2.0/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 subtract 4 scattered elements from a rank-1 tensor with 8 elements. In Python, that subtraction 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])\nsub = tf.scatter_nd_sub(ref, indices, updates)\nwith tf.Session() as sess:\n print sess.run(sub)\n```\n\n\u003cbr /\u003e\n\nThe resulting update to ref would look like this: \n\n```text\n[1, -9, 3, -6, -4, 6, 7, -4]\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/r2.0/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.0/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.0/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/r2.0/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_sub_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/r2.0/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [ResourceScatterNdSub](#classtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1a25e5c067a5d697fef98c041f96651e44)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates)` ||\n| [ResourceScatterNdSub](#classtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1a24f475452b33af301e07cf9d813549ec)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ResourceScatterNdSub::Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1a63fdcb76d053d0965e87b95192e7dcbb) | [Operation](/versions/r2.0/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_sub_1aa2d4f9b23d89ee2fef6c5d15417e75ae)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [UseLocking](#classtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1a91aca593a855009a4e43ecb827f8e410)`(bool x)` | [Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-sub/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_sub_1_1_attrs) |\n\n| ### Structs ||\n|--------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ResourceScatterNdSub::Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-sub/attrs) | Optional attribute setters for [ResourceScatterNdSub](/versions/r2.0/api_docs/cc/class/tensorflow/ops/resource-scatter-nd-sub#classtensorflow_1_1ops_1_1_resource_scatter_nd_sub). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### ResourceScatterNdSub\n\n```gdscript\n ResourceScatterNdSub(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ResourceScatterNdSub\n\n```gdscript\n ResourceScatterNdSub(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ResourceScatterNdSub::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```"]]