Class GeneratorEnqueuer
Inherits From: SequenceEnqueuer
Defined in tensorflow/python/keras/utils/data_utils.py
.
Builds a queue out of a data generator.
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 datause_multiprocessing
: use multiprocessing if True, otherwise threadingwait_time
: time to sleep in-between calls toput()
random_seed
: Initial seed for workers, will be incremented by one for each worker.
__init__
__init__(
sequence,
use_multiprocessing=False,
random_seed=None
)
Initialize self. See help(type(self)) for accurate signature.
Methods
tf.keras.utils.GeneratorEnqueuer.get
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)
.
tf.keras.utils.GeneratorEnqueuer.is_running
is_running()
tf.keras.utils.GeneratorEnqueuer.start
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 onput()
)
tf.keras.utils.GeneratorEnqueuer.stop
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 onthread.join()