# tf.keras.utils.GeneratorEnqueuer

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/utils/GeneratorEnqueuer) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/utils/data_utils.py#L836-L922) |

Builds a queue out of a data generator.

Inherits From: [`SequenceEnqueuer`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/utils/SequenceEnqueuer)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.utils.GeneratorEnqueuer`](https://www.tensorflow.org/api_docs/python/tf/keras/utils/GeneratorEnqueuer), \`tf.compat.v2.keras.utils.GeneratorEnqueuer\`

<br />

    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`.

<br />

<br />

<br />

| ## 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. |

<br />

## Methods

### `get`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/utils/data_utils.py#L886-L922)

    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](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/utils/data_utils.py#L626-L627)

    is_running()

### `start`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/utils/data_utils.py#L629-L647)

    start(
        workers=1, max_queue_size=10
    )

Starts the handler's workers.

<br />

<br />

<br />

| Arguments ||
|---|---|
| `workers` | Number of workers. |
| `max_queue_size` | queue size (when full, workers could block on `put()`) |

<br />

### `stop`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/utils/data_utils.py#L654-L668)

    stop(
        timeout=None
    )

Stops running threads and wait for them to exit, if necessary.

Should be called by the same thread which called `start()`.

<br />

<br />

<br />

| Arguments ||
|---|---|
| `timeout` | maximum time to wait on `thread.join()` |

<br />