# tf.keras.preprocessing.image.Iterator

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.8.0/keras/preprocessing/image.py#L317-L319) |

Base class for image data iterators.

Inherits From: [`Sequence`](https://www.tensorflow.org/versions/r2.8/api_docs/python/tf/keras/utils/Sequence)

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.preprocessing.image.Iterator`](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/Iterator)

<br />

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

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

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `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. |

<br />

## Methods

### `next`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L106-L116)

    next()

For python 2.x.

<br />

<br />

<br />

| Returns ||
|---|---|
| The next batch. ||

<br />

### `on_epoch_end`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L70-L71)

    on_epoch_end()

### `reset`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L73-L74)

    reset()

### `__getitem__`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L52-L65)

    __getitem__(
        idx
    )

### `__iter__`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L98-L101)

    __iter__()

### `__len__`

[View source](https://github.com/keras-team/keras-preprocessing/tree/1.1.2/keras_preprocessing/image/iterator.py#L67-L68)

    __len__()

<br />

<br />

<br />

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

<br />