# tf.keras.utils.SequenceEnqueuer

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/utils/SequenceEnqueuer) | [![](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#L575-L700) |

Base class to enqueue inputs.

#### View aliases


**Compat aliases for migration**

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

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

<br />

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

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