# tf.contrib.layers.flatten

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/layers/python/layers/layers.py#L1616-L1635) |

Flattens the input while maintaining the batch_size.

    tf.contrib.layers.flatten(
        inputs, outputs_collections=None, scope=None
    )

Assumes that the first dimension represents the batch.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `inputs` | A tensor of size \[batch_size, ...\]. |
| `outputs_collections` | Collection to add the outputs. |
| `scope` | Optional scope for name_scope. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A flattened tensor with shape \[batch_size, k\]. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If inputs rank is unknown or less than 2. |

<br />