tensor akışı:: işlem:: Dinamik Dikiş

#include <data_flow_ops.h>

data tensörlerinden gelen değerleri tek bir tensöre ayırın.

Özet

Öyle ki birleştirilmiş bir tensör oluşturur

    merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]

Örneğin, her bir indices[m] skaler veya vektör ise, elimizde

    # Scalar indices:
    merged
[indices[m], ...] = data[m][...]

    # Vector indices:
    merged
[indices[m][i], ...] = data[m][i, ...]

Her data[i].shape karşılık gelen indices[i].shape ile başlamalı ve data[i].shape geri kalanı i ile sabit olmalıdır. Yani data[i].shape = indices[i].shape + constant sahip olmamız gerekir. Bu constant göre çıktı şekli şu şekildedir:

merged.shape = [max(indices)] + constant

Değerler sırayla birleştirilir, dolayısıyla (m,i) < (n,j) için hem indices[m][i] hem de indices[n][j] n][j]'de bir indeks görünürse, dilim data[n][j] birleştirilmiş sonuçta görünür. Bu garantiye ihtiyacınız yoksa ParallelDynamicStitch bazı cihazlarda daha iyi performans gösterebilir.

Örneğin:

    indices[0] = 6
    indices
[1] = [4, 1]
    indices
[2] = [[5, 2], [0, 3]]
    data
[0] = [61, 62]
    data
[1] = [[41, 42], [11, 12]]
    data
[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
    merged
= [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
             
[51, 52], [61, 62]]

Bu yöntem, aşağıdaki örnekte gösterildiği gibi, dynamic_partition tarafından oluşturulan bölümleri birleştirmek için kullanılabilir:

    # Apply function (increments x_i) on elements for which a certain condition
   
# apply (x_i != -1 in this example).
    x
=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
    condition_mask
=tf.not_equal(x,tf.constant(-1.))
    partitioned_data
= tf.dynamic_partition(
        x
, tf.cast(condition_mask, tf.int32) , 2)
    partitioned_data
[1] = partitioned_data[1] + 1.0
    condition_indices
= tf.dynamic_partition(
        tf
.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
    x
= tf.dynamic_stitch(condition_indices, partitioned_data)
   
# Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
   
# unchanged.

Argümanlar:

İade:

  • Output : Birleştirilmiş tensör.

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

DynamicStitch (const :: tensorflow::Scope & scope, :: tensorflow::InputList indices, :: tensorflow::InputList data)

Kamu işlevleri

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

Genel özellikler

birleştirilmiş

::tensorflow::Output merged

operasyon

Operation operation

Kamu işlevleri

Dinamik Dikiş

 DynamicStitch(
 
const ::tensorflow::Scope & scope,
 
::tensorflow::InputList indices,
 
::tensorflow::InputList data
)

düğüm

::tensorflow::Node * node() const 

operatör::tensorflow::Giriş

 operator::tensorflow::Input() const 

operatör::tensorflow::Çıktı

 operator::tensorflow::Output() const