# tf.keras.utils.GeneratorEnqueuer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/utils/data_utils.py#L917-L1007) |

Builds a queue out of a data generator.

Inherits From: [`SequenceEnqueuer`](https://www.tensorflow.org/versions/r2.13/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\`

<br />

    tf.keras.utils.GeneratorEnqueuer(
        generator, use_multiprocessing=False, random_seed=None
    )

The provided generator can be finite in which case the class will throw
a `StopIteration` exception.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `generator` | a generator function which yields data |
| `use_multiprocessing` | use multiprocessing if True, otherwise threading |
| `random_seed` | Initial seed for workers, will be incremented by one for each worker. |

<br />

## Methods

### `get`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/utils/data_utils.py#L968-L1007)

    get()

Creates a generator to extract data from the queue.

Skip the data if it is `None`.

<br />

<br />

<br />

| Yields ||
|---|---|
| The next element in the queue, i.e. a tuple `(inputs, targets)` or `(inputs, targets, sample_weights)`. ||

<br />

### `is_running`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/utils/data_utils.py#L702-L703)

    is_running()

### `start`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/utils/data_utils.py#L705-L723)

    start(
        workers=1, max_queue_size=10
    )

Starts the handler's workers.

<br />

<br />

<br />

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

<br />

### `stop`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/utils/data_utils.py#L730-L744)

    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 />

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

<br />