tensorflow :: ops :: GatherNd
#include <array_ops.h>
params
からindices
指定された形状のTensorにスライスを 収集しindices
。
概要
indices
K次元の整数テンソルの最良と考えられるへのインデックスの(K-1)次元テンソルとしてparams
、各要素がスライス定義params
:
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]
一方でtf.gather
indices
定義スライスの最初の次元へparams
で、 tf.gather_nd
、 indices
定義スライス最初にN
の寸法params
、 N = indices.shape[-1]
最後の次元indices
最大でのランクすることができparams
:
indices.shape[-1] <= params.rank
indices
の最後の次元は、 params
次元indices.shape[-1]
に沿った要素( 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.shape[:-1] + params.shape[indices.shape[-1]:]
、indices.shape[:-1] + params.shape[indices.shape[-1]:]
によって指定されたindices
から収集されたparams
値。
コンストラクタとデストラクタ | |
---|---|
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
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