GatherNd

パブリック最終クラスGatherNd

`params` からのスライスを、`indices` で指定された形状を持つ Tensor に集めます。

`indices` は K 次元の整数テンソルであり、`params` へのインデックスの (K-1) 次元テンソルとして考えるのが最も適切です。ここで、各要素は `params` のスライスを定義します。

出力[\\(i_0, ..., i_{K-2}\\)] = params[インデックス[\\(i_0, ..., i_{K-2}\\)]]

tf.gatherの `indices` は `params` の `axis` 次元にスライスを定義しますが、 tf.gather_ndでは、 `indices` は `params` の最初の `N` 次元にスライスを定義します。 ここで、 `N = indices.shape [-1]`。

`indices` の最後の次元は、最大でも `params` のランクになります。

indices.shape[-1] <= params.rank

`indices` の最後の次元は、次元 `indices` に沿った要素 (`indices.shape[-1] == params.rank` の場合) またはスライス (`indices.shape[-1] < params.rank` の場合) に対応します。 `params`のshape[-1]`。出力テンソルには形状があります

indices.shape[:-1] + params.shape[indices.shape[-1]:]

CPU では、範囲外のインデックスが見つかった場合、エラーが返されることに注意してください。 GPU では、範囲外のインデックスが見つかった場合、対応する出力値に 0 が格納されます。

以下にいくつかの例を示します。

行列への単純なインデックス作成:

indices = [[0, 0], [1, 1]]
     params = [['a', 'b'], ['c', 'd']]
     output = ['a', 'd']
 
行列へのスライスのインデックス作成:
indices = [[1], [0]]
     params = [['a', 'b'], ['c', 'd']]
     output = [['c', 'd'], ['a', 'b']]
 
3 テンソルへのインデックス作成:
indices = [[1]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = [[['a1', 'b1'], ['c1', 'd1']]]
 
 
     indices = [[0, 1], [1, 0]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = [['c0', 'd0'], ['a1', 'b1']]
 
 
     indices = [[0, 0, 1], [1, 0, 1]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = ['b0', 'b1']
 
行列へのバッチ インデックス作成:
indices = [[[0, 0]], [[0, 1]]]
     params = [['a', 'b'], ['c', 'd']]
     output = [['a'], ['b']]
 
行列へのスライス インデックスのバッチ作成:
indices = [[[1]], [[0]]]
     params = [['a', 'b'], ['c', 'd']]
     output = [[['c', 'd']], [['a', 'b']]]
 
行列へのバッチ インデックス作成3 テンソル:
indices = [[[1]], [[0]]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = [[[['a1', 'b1'], ['c1', 'd1']]],
               [[['a0', 'b0'], ['c0', 'd0']]]]
 
     indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = [[['c0', 'd0'], ['a1', 'b1']],
               [['a0', 'b0'], ['c1', 'd1']]]
 
 
     indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]]
     params = [[['a0', 'b0'], ['c0', 'd0']],
               [['a1', 'b1'], ['c1', 'd1']]]
     output = [['b0', 'b1'], ['d0', 'c1']]
 
tf.gatherと `tf.batch_gather` も参照してください。

パブリックメソッド

出力<T>
asOutput ()
テンソルのシンボリック ハンドルを返します。
静的 <T, U 拡張番号> GatherNd <T>
create (スコープscope、オペランド<T>パラメータ、オペランド<U>インデックス)
新しい GatherNd オペレーションをラップするクラスを作成するためのファクトリ メソッド。
出力<T>
出力()
`params` の値は、`indices` で指定されたインデックスから収集され、形状は `indices.shape[:-1] + params.shape[indices.shape[-1]:]` になります。

継承されたメソッド

パブリックメソッド

public Output <T> asOutput ()

テンソルのシンボリック ハンドルを返します。

TensorFlow オペレーションへの入力は、別の TensorFlow オペレーションの出力です。このメソッドは、入力の計算を表すシンボリック ハンドルを取得するために使用されます。

public static GatherNd <T> create (スコープスコープ、オペランド<T> パラメータ、オペランド<U> インデックス)

新しい GatherNd オペレーションをラップするクラスを作成するためのファクトリ メソッド。

パラメーター
範囲現在のスコープ
パラメータ値を収集するテンソル。
インデックスインデックステンソル。
戻り値
  • GatherNd の新しいインスタンス

public出力<T>出力()

`params` の値は、`indices` で指定されたインデックスから収集され、形状は `indices.shape[:-1] + params.shape[indices.shape[-1]:]` になります。