tf.ragged.stack

Stacks a list of rank-R tensors into one rank-(R+1) RaggedTensor.

Given a list of tensors or ragged tensors with the same rank R (R >= axis), returns a rank-R+1 RaggedTensor result such that result[i0...iaxis] is [value[i0...iaxis] for value in values].

Examples:

# Stacking two ragged tensors.
t1 = tf.ragged.constant([[1, 2], [3, 4, 5]])
t2 = tf.ragged.constant([[6], [7, 8, 9]])
tf.ragged.stack([t1, t2], axis=0)
<tf.RaggedTensor [[[1, 2], [3, 4, 5]], [[6], [7, 8, 9]]]>
tf.ragged.stack([t1, t2], axis=1)
<tf.RaggedTensor [[[1, 2], [6]], [[3, 4, 5], [7, 8, 9]]]>
# Stacking two dense tensors with different sizes.
t3 = tf.constant([[1, 2, 3], [4, 5, 6]])
t4 = tf.constant([[5], [6], [7]])</