Watch keynotes, product sessions, workshops, and more from Google I/O See playlist

tf.keras.backend.flatten

TensorFlow 1 version View source on GitHub

Flatten a tensor.

x A tensor or variable.

A tensor, reshaped into 1-D

Example:

  b = tf.constant([[1, 2], [3, 4]])
  b
    <tf.Tensor: id=102, shape=(2, 2), dtype=int32, numpy=
    array([[1, 2],
           [3, 4]], dtype=int32)>
  tf.keras.backend.flatten(b)
    <tf.Tensor: id=105, shape=(4,), dtype=int32,
        numpy=array([1, 2, 3, 4], dtype=int32)>