TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tf.keras.backend.stack

TensorFlow 1 version View source on GitHub

Stacks a list of rank R tensors into a rank R+1 tensor.

Aliases:

tf.keras.backend.stack(
    x,
    axis=0
)

Arguments:

  • x: List of tensors.
  • axis: Axis along which to perform stacking.

Returns:

A tensor.

Example:

  >>> a = tf.constant([[1, 2],[3, 4]])
  >>> b = tf.constant([[10, 20],[30, 40]])
  >>> tf.keras.backend.stack((a, b))
  <tf.Tensor: id=146, shape=(2, 2, 2), dtype=int32, numpy=
  array([[[ 1,  2],
          [ 3,  4]],
         [[10, 20],
          [30, 40]]], dtype=int32)>