# tf.keras.layers.InputSpec

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/engine/input_spec.py#L34-L103) |

Specifies the ndim, dtype and shape of every input to a layer.

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.keras.layers.InputSpec(
        dtype=None, shape=None, ndim=None, max_ndim=None, min_ndim=None, axes=None
    )

Every layer should expose (if appropriate) an `input_spec` attribute:
a list of instances of InputSpec (one per input tensor).

A None entry in a shape is compatible with any dimension,
a None shape is compatible with any shape.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `dtype` | Expected DataType of the input. |
| `shape` | Shape tuple, expected shape of the input (may include None for unchecked axes). |
| `ndim` | Integer, expected rank of the input. |
| `max_ndim` | Integer, maximum rank of the input. |
| `min_ndim` | Integer, minimum rank of the input. |
| `axes` | Dictionary mapping integer axes to a specific dimension value. |

<br />

## Methods

### `from_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/engine/input_spec.py#L101-L103)

    @classmethod
    from_config(
        config
    )

### `get_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/engine/input_spec.py#L92-L99)

    get_config()