W3cubDocs

/TensorFlow Python

tf.keras.utils.SequenceEnqueuer

Class SequenceEnqueuer

Defined in tensorflow/python/keras/_impl/keras/utils/data_utils.py.

Base class to enqueue inputs.

The task of an Enqueuer is to use parallelism to speed up preprocessing. This is done with processes or threads.

Examples:

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

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

is_running()

start

start(
    workers=1,
    max_queue_size=10
)

Starts the handler's workers.

Arguments:

  • workers: number of worker threads
  • max_queue_size: queue size (when full, threads could block on put()).

stop

stop(timeout=None)

Stop 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()

© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/utils/SequenceEnqueuer