GatherNd

パブリックファイナルクラスGatherNd

`params`から` indexes`で指定された形状のTensorにスライスを収集します。

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

output [\\(i_0, ..., i_{K-2}\\)] = params [indices [\\(i_0, ..., i_{K-2}\\)]]

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

`indices`の最後の次元は、最大で` params`のランクにすることができます。

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

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

indexs.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]]
     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 = [[1], [0]]
     params = [['a', 'b'], ['c', 'd']]
     output = [['c', 'd'], ['a', 'b']]
 
3テンソルへのインデックス作成:l10n-placeholder5マトリックスへのバッチインデックス作成:
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も参照してください。

パブリックメソッド

出力<T>
asOutput ()
テンソルのシンボリックハンドルを返します。
static <T、U extends Number> GatherNd <T>
createスコープスコープ、オペランド<T>パラメータ、オペランド<U>インデックス)
新しいGatherNd操作をラップするクラスを作成するファクトリメソッド。
出力<T>
出力()
形状が `indices.shape [:-1] + params.shape [indices.shape [-1]:]`の `indices`によって与えられたインデックスから収集された` params`の値。

継承されたメソッド

パブリックメソッド

public Output <T> asOutput ()

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

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

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

新しいGatherNd操作をラップするクラスを作成するファクトリメソッド。

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

public Output <T> output ()

形状が `indices.shape [:-1] + params.shape [indices.shape [-1]:]`の `indices`によって与えられたインデックスから収集された` params`の値。