Google I/O'yu ayarladığınız için teşekkür ederiz. İsteğe bağlı olarak tüm oturumları görüntüleyin İsteğe bağlı olarak izleyin

tensorflow :: ops :: GatherNd

#include <array_ops.h>

indices belirtilen şekle sahip bir Tensöre params dilimleri toplayın .

Özet

indices K-boyutlu bir tam sayı tensörü, en düşünce içine indekslerinin (K-1) boyutlu tensörü olarak params her bir eleman bir dilim tanımlar, params :

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

Oysa in tf.gather indices tanımlar birinci boyuta dilimleri params olarak, tf.gather_nd , indices ilk olarak tanımlar dilimleri N boyutlarına params , burada N = indices.shape[-1] .

indices son boyutu, en fazla params sıralaması olabilir:

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

indices son boyutu, params boyut indices.shape[-1] boyunca öğelere ( indices.shape[-1] == params.rank ) veya dilimlere ( indices.shape[-1] < params.rank ) indices.shape[-1] . Çıkış tensörü

indices.shape[:-1] + params.shape[indices.shape[-1]:]
şekline sahiptir

CPU'da, sınır dışı bir dizin bulunursa, bir hata döndürüldüğünü unutmayın. GPU'da, sınır dışı bir dizin bulunursa, ilgili çıktı değerinde bir 0 saklanır.

Aşağıda bazı örnekler.

Bir matrise basit indeksleme:

    indices = [[0, 0], [1, 1]]
    params = [['a', 'b'], ['c', 'd']]
    output = ['a', 'd']

Bir matrise dizin oluşturmayı dilimleyin:

    indices = [[1], [0]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['c', 'd'], ['a', 'b']]

3 tensöre indeksleme:

    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']

Bir matrise toplu indeksleme:

    indices = [[[0, 0]], [[0, 1]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['a'], ['b']]

Bir matrise toplu dilim indeksleme:

    indices = [[[1]], [[0]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [[['c', 'd']], [['a', 'b']]]

3 tensöre toplu indeksleme:

    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']]

Ayrıca tf.gather ve tf.batch_gather da bakın.

Argümanlar:

  • kapsam: Bir Scope nesnesi
  • parametreler: Değerlerin toplanacağı tensör.
  • indisler: Endeks tensörü.

İadeler:

  • Output : şekil indices.shape[:-1] + params.shape[indices.shape[-1]:] ile indices tarafından verilen indislerden toplanan params alınan değerler.

Yapıcılar ve Yıkıcılar

GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices)

Genel özellikler

operation
output

Kamusal işlevler

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

Genel özellikler

operasyon

Operation operation

çıktı

::tensorflow::Output output

Kamusal işlevler

GatherNd

 GatherNd(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input params,
  ::tensorflow::Input indices
)

düğüm

::tensorflow::Node * node() const 

operator :: tensorflow :: Girdi

 operator::tensorflow::Input() const 

operator :: tensorflow :: Çıktı

 operator::tensorflow::Output() const