# Module: tf.keras.preprocessing

<br />

Utilities to preprocess data before training.

> [!WARNING]
> **Deprecated:** [`tf.keras.preprocessing`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/preprocessing) APIs do not operate on tensors and are not recommended for new code. Prefer loading data with either [`tf.keras.utils.text_dataset_from_directory`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/utils/text_dataset_from_directory) or [`tf.keras.utils.image_dataset_from_directory`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/utils/image_dataset_from_directory), and then transforming the output [`tf.data.Dataset`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/data/Dataset) with preprocessing layers. These approaches will offer better performance and intergration with the broader Tensorflow ecosystem. For more information, see the tutorials for [loading text](https://www.tensorflow.org/tutorials/load_data/text), [loading images](https://www.tensorflow.org/tutorials/load_data/images), and [augmenting images](https://www.tensorflow.org/tutorials/images/data_augmentation), as well as the [preprocessing layer guide](https://www.tensorflow.org/guide/keras/preprocessing_layers).

## Modules

[`image`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/preprocessing/image) module: Utilies for image preprocessing and augmentation.

[`sequence`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/preprocessing/sequence) module: Utilities for preprocessing sequence data.

[`text`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/preprocessing/text) module: Utilities for text input preprocessing.

## Functions

[`image_dataset_from_directory(...)`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/utils/image_dataset_from_directory): Generates a [`tf.data.Dataset`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/data/Dataset) from image files in a directory.

[`text_dataset_from_directory(...)`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/utils/text_dataset_from_directory): Generates a [`tf.data.Dataset`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/data/Dataset) from text files in a directory.

[`timeseries_dataset_from_array(...)`](https://www.tensorflow.org/versions/r2.12/api_docs/python/tf/keras/utils/timeseries_dataset_from_array): Creates a dataset of sliding windows over a timeseries provided as array.