# tf.compat.v1.layers.Flatten

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/layers/core.py#L275-L297) |

Flattens an input tensor while preserving the batch axis (axis 0).

Inherits From: [`Flatten`](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/layers/Flatten), [`Layer`](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/compat/v1/layers/Layer)

    tf.compat.v1.layers.Flatten(
        data_format=None, **kwargs
    )

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `data_format` | A string, one of `channels_last` (default) or `channels_first`. The ordering of the dimensions in the inputs. `channels_last` corresponds to inputs with shape `(batch, ..., channels)` while `channels_first` corresponds to inputs with shape `(batch, channels, ...)`. |

<br />

#### Examples:

      x = tf.compat.v1.placeholder(shape=(None, 4, 4), dtype='float32')
      y = Flatten()(x)
      # now `y` has shape `(None, 16)`

      x = tf.compat.v1.placeholder(shape=(None, 3, None), dtype='float32')
      y = Flatten()(x)
      # now `y` has shape `(None, None)`

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `graph` | DEPRECATED FUNCTION <br /> > [!WARNING] > **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Stop using this property because tf.layers layers no longer track their graph. |
| `scope_name` | <br /> |

<br />