コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
テンソルフロー::作戦::リソースScatterNdUpdate
#include <state_ops.h>
特定の値内の個々の値またはスライスにスパースupdates
を適用します。
まとめ
indices
に応じた変数。
ref
はランクP
のTensor
、 indices
はランクQ
のTensor
です。
indices
、 ref
へのインデックスを含む整数テンソルでなければなりません。これは形状[d_0, ..., d_{Q-2}, K]
0 < K <= P
である必要があります。
indices
の最も内側の次元 (長さK
) は、 ref
のK
番目の次元に沿った要素 ( K = P
の場合) またはスライス ( K < P
の場合) へのインデックスに対応します。
updates
、次の形状を持つランクQ-1+PK
のTensor
です。
[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]].
たとえば、4 つの散在要素を 8 要素のランク 1 テンソルに更新したいとします。 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])
update = tf.scatter_nd_update(ref, indices, updates)
with tf.Session() as sess:
print sess.run(update)
ref への結果の更新は次のようになります。
[1, 11, 3, 10, 9, 6, 7, 12]
スライスを更新する方法の詳細については、 tf.scatter_nd
参照してください。
引数:
- スコープ:スコープオブジェクト
- 参照: リソースハンドル。 VarHandleOp からのものである必要があります。
- インデックス: Tensor 。 int32、int64 のいずれかの型である必要があります。 ref へのインデックスのテンソル。
- 更新: Tensor 。 ref と同じ型でなければなりません。 ref に追加する更新された値のテンソル。
オプションの属性 ( Attrs
を参照):
- use_locking: オプションのブール値。デフォルトは True です。 True の場合、割り当てはロックによって保護されます。それ以外の場合、動作は未定義ですが、競合が少なくなる可能性があります。
戻り値:
パブリック属性
公共機能
演算子::tensorflow::オペレーション
operator::tensorflow::Operation() const
パブリック静的関数
ロックを使用する
Attrs UseLocking(
bool x
)
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# tensorflow::ops::ResourceScatterNdUpdate Class Reference\n\ntensorflow::ops::ResourceScatterNdUpdate\n========================================\n\n`#include \u003cstate_ops.h\u003e`\n\nApplies sparse `updates` to individual values or slices within a given.\n\nSummary\n-------\n\nvariable according to `indices`.\n\n`ref` is a [Tensor](/versions/r2.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with rank `P` and `indices` is a [Tensor](/versions/r2.2/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.2/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 update 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that update would look like this:\n\n\n```gdscript\n ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])\n indices = tf.constant([[4], [3], [1] ,[7]])\n updates = tf.constant([9, 10, 11, 12])\n update = tf.scatter_nd_update(ref, indices, updates)\n with tf.Session() as sess:\n print sess.run(update)\n```\n\n\u003cbr /\u003e\n\nThe resulting update to ref would look like this: \n\n```text\n[1, 11, 3, 10, 9, 6, 7, 12]\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.2/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.2/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.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must have the same type as ref. A tensor of updated values to add to ref.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_update_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.2/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [ResourceScatterNdUpdate](#classtensorflow_1_1ops_1_1_resource_scatter_nd_update_1a701849b468a1d765a8fa8ecf1820f464)`(const ::`[tensorflow::Scope](/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates)` ||\n| [ResourceScatterNdUpdate](#classtensorflow_1_1ops_1_1_resource_scatter_nd_update_1a6f3373c4c7b0450a123c9ba20c4c116a)`(const ::`[tensorflow::Scope](/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` ref, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` updates, const `[ResourceScatterNdUpdate::Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_update_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_resource_scatter_nd_update_1a01f20b9b8778a7d8d62790ded4be2b87) | [Operation](/versions/r2.2/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_update_1a34c9c3a28d29d52204c5232e44b0b7cf)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [UseLocking](#classtensorflow_1_1ops_1_1_resource_scatter_nd_update_1aa18969344553eac87e406dad8ba84204)`(bool x)` | [Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_resource_scatter_nd_update_1_1_attrs) |\n\n| ### Structs ||\n|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::ResourceScatterNdUpdate::Attrs](/versions/r2.2/api_docs/cc/struct/tensorflow/ops/resource-scatter-nd-update/attrs) | Optional attribute setters for [ResourceScatterNdUpdate](/versions/r2.2/api_docs/cc/class/tensorflow/ops/resource-scatter-nd-update#classtensorflow_1_1ops_1_1_resource_scatter_nd_update). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### ResourceScatterNdUpdate\n\n```gdscript\n ResourceScatterNdUpdate(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates\n)\n``` \n\n### ResourceScatterNdUpdate\n\n```gdscript\n ResourceScatterNdUpdate(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input ref,\n ::tensorflow::Input indices,\n ::tensorflow::Input updates,\n const ResourceScatterNdUpdate::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```"]]