tf.keras.utils.GeneratorEnqueuer
Stay organized with collections
Save and categorize content based on your preferences.
Builds a queue out of a data generator.
Inherits From: SequenceEnqueuer
tf.keras.utils.GeneratorEnqueuer(
sequence, use_multiprocessing=False, random_seed=None
)
The provided generator can be finite in which case the class will throw
a StopIteration
exception.
Used in fit_generator
, evaluate_generator
, predict_generator
.
Arguments |
generator
|
a generator function which yields data
|
use_multiprocessing
|
use multiprocessing if True, otherwise threading
|
wait_time
|
time to sleep in-between calls to put()
|
random_seed
|
Initial seed for workers,
will be incremented by one for each worker.
|
Methods
get
View source
get()
Creates a generator to extract data from the queue.
Skip the data if it is None
.
Yields |
The next element in the queue, i.e. a tuple
(inputs, targets) or
(inputs, targets, sample_weights) .
|
is_running
View source
is_running()
start
View source
start(
workers=1, max_queue_size=10
)
Starts the handler's workers.
Arguments |
workers
|
Number of workers.
|
max_queue_size
|
queue size
(when full, workers could block on put() )
|
stop
View source
stop(
timeout=None
)
Stops running threads and wait for them to exit, if necessary.
Should be called by the same thread which called start()
.
Arguments |
timeout
|
maximum time to wait on thread.join()
|
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 2021-02-18 UTC.
[null,null,["Last updated 2021-02-18 UTC."],[],[],null,["# tf.keras.utils.GeneratorEnqueuer\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/utils/GeneratorEnqueuer) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/utils/data_utils.py#L835-L921) |\n\nBuilds a queue out of a data generator.\n\nInherits From: [`SequenceEnqueuer`](../../../tf/keras/utils/SequenceEnqueuer)\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.utils.GeneratorEnqueuer`](https://www.tensorflow.org/api_docs/python/tf/keras/utils/GeneratorEnqueuer)\n\n\u003cbr /\u003e\n\n tf.keras.utils.GeneratorEnqueuer(\n sequence, use_multiprocessing=False, random_seed=None\n )\n\nThe provided generator can be finite in which case the class will throw\na `StopIteration` exception.\n\nUsed in `fit_generator`, `evaluate_generator`, `predict_generator`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|-----------------------|-----------------------------------------------------------------------|\n| `generator` | a generator function which yields data |\n| `use_multiprocessing` | use multiprocessing if True, otherwise threading |\n| `wait_time` | time to sleep in-between calls to `put()` |\n| `random_seed` | Initial seed for workers, will be incremented by one for each worker. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `get`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/utils/data_utils.py#L885-L921) \n\n get()\n\nCreates a generator to extract data from the queue.\n\nSkip the data if it is `None`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Yields ||\n|---|---|\n| The next element in the queue, i.e. a tuple `(inputs, targets)` or `(inputs, targets, sample_weights)`. ||\n\n\u003cbr /\u003e\n\n### `is_running`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/utils/data_utils.py#L622-L623) \n\n is_running()\n\n### `start`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/utils/data_utils.py#L625-L643) \n\n start(\n workers=1, max_queue_size=10\n )\n\nStarts the handler's workers.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments ||\n|------------------|--------------------------------------------------------|\n| `workers` | Number of workers. |\n| `max_queue_size` | queue size (when full, workers could block on `put()`) |\n\n\u003cbr /\u003e\n\n### `stop`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/utils/data_utils.py#L650-L664) \n\n stop(\n timeout=None\n )\n\nStops running threads and wait for them to exit, if necessary.\n\nShould be called by the same thread which called `start()`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments ||\n|-----------|-----------------------------------------|\n| `timeout` | maximum time to wait on `thread.join()` |\n\n\u003cbr /\u003e"]]