tf.keras.utils.SequenceEnqueuer
Stay organized with collections
Save and categorize content based on your preferences.
Base class to enqueue inputs.
tf.keras.utils.SequenceEnqueuer(
sequence, use_multiprocessing=False
)
The task of an Enqueuer is to use parallelism to speed up preprocessing.
This is done with processes or threads.
Example:
enqueuer = SequenceEnqueuer(...)
enqueuer.start()
datas = enqueuer.get()
for data in datas:
# Use the inputs; training, evaluating, predicting.
# ... stop sometime.
enqueuer.close()
The enqueuer.get()
should be an infinite stream of datas.
Methods
get
View source
get()
Creates a generator to extract data from the queue.
Skip the data if it is None
.
Returns
Generator yielding tuples `(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.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.utils.SequenceEnqueuer\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/utils/SequenceEnqueuer) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/utils/data_utils.py#L575-L696) |\n\nBase class to enqueue inputs.\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.SequenceEnqueuer`](/api_docs/python/tf/keras/utils/SequenceEnqueuer)\n\n\u003cbr /\u003e\n\n tf.keras.utils.SequenceEnqueuer(\n sequence, use_multiprocessing=False\n )\n\nThe task of an Enqueuer is to use parallelism to speed up preprocessing.\nThis is done with processes or threads.\n\n#### Example:\n\n enqueuer = SequenceEnqueuer(...)\n enqueuer.start()\n datas = enqueuer.get()\n for data in datas:\n # Use the inputs; training, evaluating, predicting.\n # ... stop sometime.\n enqueuer.close()\n\nThe `enqueuer.get()` should be an infinite stream of datas.\n\nMethods\n-------\n\n### `get`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/utils/data_utils.py#L687-L696) \n\n get()\n\nCreates a generator to extract data from the queue.\n\nSkip the data if it is `None`.\n\nReturns\n=======\n\n Generator yielding tuples `(inputs, targets)`\n or `(inputs, targets, sample_weights)`.\n\n### `is_running`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/utils/data_utils.py#L626-L627) \n\n is_running()\n\n### `start`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/utils/data_utils.py#L629-L647) \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.0.0/tensorflow/python/keras/utils/data_utils.py#L654-L668) \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"]]