テンソルフロー::作戦::ダイナミックステッチ

#include <data_flow_ops.h>

dataテンソルの値を単一のテンソルにインターリーブします。

まとめ

次のようなマージされたテンソルを構築します。

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

たとえば、各indices[m]がスカラーまたはベクトルの場合、次のようになります。

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

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

data[i].shape対応するindices[i].shapeで始まる必要があり、 data[i].shapeの残りの部分はiに関して定数でなければなりません。つまり、 data[i].shape = indices[i].shape + constantが必要です。このconstantに関して、出力形状は

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

値は順番にマージされるため、 (m,i) < (n,j)の場合、インデックスがindices[m][i] indices[n][j] n][j] の両方に出現する場合、スライスdata[n][j]次のようになります。結合結果に表示されます。この保証が必要ない場合は、一部のデバイスではParallelDynamicStitch のパフォーマンスが向上する可能性があります。

例えば:

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

次の例に示すように、このメソッドを使用して、 dynamic_partitionによって作成されたパーティションをマージできます。

    # 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.

引数:

戻り値:

  • Output : マージされたテンソル。

コンストラクターとデストラクター

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

パブリック属性

merged
operation

公共機能

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

パブリック属性

合併した

::tensorflow::Output merged

手術

Operation operation

公共機能

ダイナミックステッチ

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

ノード

::tensorflow::Node * node() const 

演算子::tensorflow::入力

 operator::tensorflow::Input() const 

演算子::tensorflow::出力

 operator::tensorflow::Output() const