<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L20-L126) |

Base class for image data iterators.

Inherits From: [`PyDataset`](https://www.tensorflow.org/api_docs/python/tf/keras/utils/PyDataset)

    tf.keras.preprocessing.image.Iterator(
        n, batch_size, shuffle, seed, **kwargs
    )

DEPRECATED.

Every `Iterator` must implement the `_get_batches_of_transformed_samples`
method.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `n` | Integer, total number of samples in the dataset to loop over. |
| `batch_size` | Integer, size of a batch. |
| `shuffle` | Boolean, whether to shuffle the data between epochs. |
| `seed` | Random seeding for data shuffling. |
| `**kwargs` | Additional keyword arguments for the `PyDataset` base class, such as `workers`, `use_multiprocessing`, and `max_queue_size`. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `max_queue_size` | <br /> <br /> |
| `num_batches` | Number of batches in the PyDataset. |
| `use_multiprocessing` | <br /> <br /> |
| `workers` | <br /> <br /> |

<br />

## Methods

### `on_epoch_begin`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/trainers/data_adapters/py_dataset_adapter.py#L189-L191)

    on_epoch_begin()

Method called at the beginning of every epoch.

### `on_epoch_end`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L77-L78)

    on_epoch_end()

Method called at the end of every epoch.

### `reset`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L80-L81)

    reset()

### `__getitem__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L57-L72)

    __getitem__(
        idx
    )

Gets batch at position `index`.

<br />

<br />

<br />

| Args ||
|---|---|
| `index` | position of the batch in the PyDataset. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A batch ||

<br />

### `__iter__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L106-L109)

    __iter__()

### `__len__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/legacy/preprocessing/image.py#L74-L75)

    __len__()

<br />

<br />

<br />

| ## Class Variables ||
|---|---|
| white_list_formats | `('png', 'jpg', 'jpeg', 'bmp', 'ppm', 'tif', 'tiff')` |

<br />