tf.keras.backend.flatten

Flatten a tensor.

Compat aliases for migration

See Migration guide for more details.

tf.compat.v1.keras.backend.flatten

x A tensor or variable.

A tensor, reshaped into 1-D

Example:

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