|TensorFlow 1 version|
Interleave the values from the
data tensors into a single tensor.
Compat aliases for migration
See Migration guide for more details.
tf.dynamic_stitch( indices, data, name=None )
Builds a merged tensor such that
merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
For example, if each
indices[m] is scalar or vector, we have
# Scalar indices: merged[indices[m], ...] = data[m][...] # Vector indices: merged[indices[m][i], ...] = data[m][i, ...]
data[i].shape must start with the corresponding
and the rest of
data[i].shape must be constant w.r.t.
i. That is, we
data[i].shape = indices[i].shape + constant. In terms of this
constant, the output shape is
merged.shape = [max(indices)] + constant
Values are merged in order, so if an index appears in both
(m,i) < (n,j) the slice
data[n][j] will appear in the
merged result. If you do not need this guarantee, ParallelDynamicStitch might
perform better on some devices.
indices = 6 indices = [4, 1] indices = [[5, 2], [0, 3]] data = [61, 62] data = [[41, 42], [11, 12]] data = [[[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 by
as illustrated on the following example:
# Apply function (increments x_i) on elements for which a certain condition # apply (x_i != -1 in this example). x=tf