DynamicStitch


tensorflow C++ API

tensorflow::ops::DynamicStitch

Interleave the values from thedatatensors into a single tensor.


Summary

Builds a merged tensor such that

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

For example, if eachindices[m]is scalar or vector, we have

```python Scalar indices:

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

Vector indices:

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

Eachdata[i].shapemust start with the correspondingindices[i].shape, and the rest ofdata[i].shapemust be constant w.r.t.i. That is, we must havedata[i].shape = indices[i].shape + constant. In terms of thisconstant, the output shape is

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

Values are merged in order, so if an index appears in bothindices[m][i]andindices[n][j]for(m,i) < (n,j)the slicedata[n][j]will appear in the merged result.

For example:

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

This method can be used to merge partitions created bydynamic_partitionas illustrated on the following example:

```python 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:

Returns:

  • Output : The merged tensor.

Constructor

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

Public attributes

  • tensorflow::Output merged

DynamicStitch block

Source link : https://github.com/EXPNUNI/enuSpace-Tensorflow/blob/master/enuSpaceTensorflow/tf_data_flow_ops.cpp

Argument:

  • Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
  • indices : connect Input node or input data.
  • data: connect Input node.

Return:

  • Output merged: Output object of DynamicStitch class object.

Result:

  • std::vector(Tensor) product_result : Returned object of executed result by calling session.

Using Method

results matching ""

    No results matching ""