tensorflow:: ops:: GatherNd
#include <array_ops.h> paramsからスライスをindicesで指定された形状のテンソルに集めます。
まとめ
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 = indices.shape[-1]です。
indicesの最後の次元は、最大でparamsのランクまでです。
indices.shape[-1] <= params.rank
indicesの最後の次元は、 paramsの次元indices.shape[-1] == params.rank indices.shape[-1] < params.rank indices.shape[-1] < params.rank の場合) に対応します。出力テンソルの形状は次のようになります。
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も参照してください。
議論:
- スコープ:スコープオブジェクト
- params: 値を取得するテンソル。
- インデックス: インデックステンソル。
返品:
-
Output:indicesで指定されたインデックスから収集されたparamsの値。形状はindices.shape[:-1] + params.shape[indices.shape[-1]:]。
コンストラクターとデストラクタ | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
公開属性 | |
|---|---|
operation | |
output | |
公的機能 | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
公開属性
手術
Operation operation
出力
::tensorflow::Output output
公的機能
ギャザーンド
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
ノード
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const