flux tensoriel : : opérations : : ParallelDynamicStitch

#include <data_flow_ops.h>

Entrelacez les valeurs des tenseurs data en un seul tenseur.

Résumé

Construit un tenseur fusionné tel que

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

Par exemple, si chaque indices[m] est scalaire ou vectoriel, on a

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

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

Chaque data[i].shape doit commencer par les indices[i].shape correspondants, et le reste de data[i].shape doit être constant par rapport à i . Autrement dit, nous devons avoir data[i].shape = indices[i].shape + constant . En termes de cette constant , la forme de sortie est

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

Les valeurs peuvent être fusionnées en parallèle, donc si un index apparaît à la fois dans indices[m][i] et indices[n][j] , le résultat peut être invalide. Cela diffère de l'opérateur DynamicStitch normal qui définit le comportement dans ce cas.

Par exemple:

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

Cette méthode peut être utilisée pour fusionner des partitions créées par dynamic_partition comme illustré dans l'exemple suivant :

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

Arguments:

  • scope : un objet Scope

Retour:

  • Output : Le tenseur fusionné.

Constructeurs et Destructeurs

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

Attributs publics

merged
operation

Fonctions publiques

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

Attributs publics

fusionné

::tensorflow::Output merged

opération

Operation operation

Fonctions publiques

ParallelDynamicStitch

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

nœud

::tensorflow::Node * node() const 

opérateur :: tensorflow :: Entrée

 operator::tensorflow::Input() const 

opérateur :: tensorflow :: Sortie

 operator::tensorflow::Output() const