# tf.keras.layers.Reshape

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Reshape) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/layers/core.py#L376-L476) |

Reshapes an output to a certain shape.

Inherits From: [`Layer`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/layers/Layer)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.layers.Reshape`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Reshape), \`tf.compat.v2.keras.layers.Reshape\`

<br />

    tf.keras.layers.Reshape(
        target_shape, **kwargs
    )

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `target_shape` | Target shape. Tuple of integers, does not include the samples dimension (batch size). |

<br />

#### Input shape:

Arbitrary, although all dimensions in the input shaped must be fixed.
Use the keyword argument `input_shape`
(tuple of integers, does not include the samples axis)
when using this layer as the first layer in a model.

#### Output shape:

`(batch_size,) + target_shape`

#### Example:

    # as first layer in a Sequential model
    model = Sequential()
    model.add(Reshape((3, 4), input_shape=(12,)))
    # now: model.output_shape == (None, 3, 4)
    # note: `None` is the batch dimension

    # as intermediate layer in a Sequential model
    model.add(Reshape((6, 2)))
    # now: model.output_shape == (None, 6, 2)

    # also supports shape inference using `-1` as dimension
    model.add(Reshape((-1, 2, 2)))
    # now: model.output_shape == (None, None, 2, 2)