tf.keras.ops.dstack

Stack tensors in sequence depth wise (along third axis).

This is equivalent to concatenation along the third axis after 2-D tensors of shape (M, N) have been reshaped to (M, N, 1) and 1-D tensors of shape (N,) have been reshaped to (1, N, 1).

xs Sequence of tensors.

The tensor formed by stacking the given tensors.

Examples:

import keras
x = keras.ops.array([1, 2, 3])
y = keras.ops.array([4, 5, 6])
keras.ops.dstack([x, y])
array([[[1, 4],
        [2, 5],
        [3, 6]]])
x = keras.ops.array([[1], [2], [3]])
y = keras.ops.array([[4], [5], [6]])
keras.ops.dstack([x, y])
array([[[1, 4]],
       [[2, 5]],
       [[3, 6]]])