tf.keras.preprocessing.image.Iterator
Stay organized with collections
Save and categorize content based on your preferences.
Base class for image data iterators.
Inherits From: Sequence
View aliases
Compat aliases for migration
See
Migration guide for
more details.
`tf.compat.v1.keras.preprocessing.image.Iterator`
tf.keras.preprocessing.image.Iterator(
n, batch_size, shuffle, seed
)
Every Iterator
must implement the _get_batches_of_transformed_samples
method.
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.
|
Methods
next
View source
next()
For python 2.x.
on_epoch_end
View source
on_epoch_end()
Method called at the end of every epoch.
reset
View source
reset()
__getitem__
View source
__getitem__(
idx
)
Gets batch at position index
.
Args |
index
|
position of the batch in the Sequence.
|
__iter__
View source
__iter__()
Create a generator that iterate over the Sequence.
__len__
View source
__len__()
Number of batch in the Sequence.
Returns |
The number of batches in the Sequence.
|
Class Variables |
white_list_formats
|
('png', 'jpg', 'jpeg', 'bmp', 'ppm', 'tif', 'tiff')
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.keras.preprocessing.image.Iterator\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L56-L170) |\n\nBase class for image data iterators.\n\nInherits From: [`Sequence`](../../../../tf/keras/utils/Sequence)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.keras.preprocessing.image.Iterator\\`\n\n\u003cbr /\u003e\n\n tf.keras.preprocessing.image.Iterator(\n n, batch_size, shuffle, seed\n )\n\n| **Deprecated:** [`tf.keras.preprocessing.image.Iterator`](../../../../tf/keras/preprocessing/image/Iterator) is not recommended for new code. Prefer loading images with [`tf.keras.utils.image_dataset_from_directory`](../../../../tf/keras/utils/image_dataset_from_directory) and transforming the output [`tf.data.Dataset`](../../../../tf/data/Dataset) with preprocessing layers. For more information, see the tutorials for [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).\n\nEvery `Iterator` must implement the `_get_batches_of_transformed_samples`\nmethod.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|---------------------------------------------------------------|\n| `n` | Integer, total number of samples in the dataset to loop over. |\n| `batch_size` | Integer, size of a batch. |\n| `shuffle` | Boolean, whether to shuffle the data between epochs. |\n| `seed` | Random seeding for data shuffling. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `next`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L150-L160) \n\n next()\n\nFor python 2.x.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The next batch. ||\n\n\u003cbr /\u003e\n\n### `on_epoch_end`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L115-L116) \n\n on_epoch_end()\n\nMethod called at the end of every epoch.\n\n### `reset`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L118-L119) \n\n reset()\n\n### `__getitem__`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L98-L110) \n\n __getitem__(\n idx\n )\n\nGets batch at position `index`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|----------------------------------------|\n| `index` | position of the batch in the Sequence. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A batch ||\n\n\u003cbr /\u003e\n\n### `__iter__`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L142-L145) \n\n __iter__()\n\nCreate a generator that iterate over the Sequence.\n\n### `__len__`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/preprocessing/image.py#L112-L113) \n\n __len__()\n\nNumber of batch in the Sequence.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The number of batches in the Sequence. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Class Variables --------------- ||\n|--------------------|-------------------------------------------------------|\n| white_list_formats | `('png', 'jpg', 'jpeg', 'bmp', 'ppm', 'tif', 'tiff')` |\n\n\u003cbr /\u003e"]]