از اینکه با Google I/O تنظیم کردید متشکریم. مشاهده همه جلسات در صورت تقاضا تماشا کنید

tensorflow :: ops :: جمع کن

#include <array_ops.h>

جمع آوری برش از params به یک تانسور با شکل مشخص شده توسط indices .

خلاصه

indices یک تانسور عدد صحیح K بعدی، بهترین فکر از آن به عنوان یک (K-1) تانسور بعدی شاخص به params ، که در آن هر عنصر یک تکه از تعریف params :

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

در حالی که در tf.gather indices تعریف برش به axis ابعاد params ، در tf.gather_nd ، indices تعریف برش را به اولین N ابعاد params ، که در آن N = indices.shape[-1] .

بعد آخرین indices می توانید حداکثر باشد رتبه params :

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

آخرین ابعاد indices مربوط به عناصر (اگر indices.shape[-1] == params.rank ) یا برش (اگر indices.shape[-1] < params.rank ) همراه بعد indices.shape[-1] از params . تانسور خروجی به شکل

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-tensor:

    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 .

استدلال ها:

  • دامنه: یک شی Sc Scope
  • params: تنسوری که می توان مقادیر را از آن جمع کرد.
  • شاخص ها: تانسور شاخص.

بازده:

  • Output : مقادیر params جمع شده از شاخص های داده شده توسط indices ، با indices شکل. شکل 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 

عملگر :: tensorflow :: ورودی

 operator::tensorflow::Input() const 

عملگر :: tensorflow :: خروجی

 operator::tensorflow::Output() const