# tf.keras.preprocessing.image.Iterator

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/preprocessing/image/Iterator) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/preprocessing/image.py#L135-L136) |

Base class for image data iterators.

Inherits From: [`Sequence`](https://www.tensorflow.org/versions/r2.0/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.

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

## Methods

### `next`

    next()

For python 2.x.

# Returns

    The next batch.

### `on_epoch_end`

    on_epoch_end()

Method called at the end of every epoch.

### `reset`

    reset()

### `__getitem__`

    __getitem__(
        idx
    )

Gets batch at position `index`.

<br />

<br />

<br />

| Arguments ||
|---|---|
| `index` | position of the batch in the Sequence. |

<br />

<br />

<br />

<br />

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

<br />

### `__iter__`

    __iter__()

Create a generator that iterate over the Sequence.

### `__len__`

    __len__()

Number of batch in the Sequence.

<br />

<br />

<br />

| Returns ||
|---|---|
| The number of batches in the Sequence. ||

<br />

## Class Variables

- `white_list_formats`