tf.compat.v1.train.QueueRunner

View source on GitHub

Holds a list of enqueue operations for a queue, each to be run in a thread.

tf.compat.v1.train.QueueRunner(
    queue=None, enqueue_ops=None, close_op=None, cancel_op=None,
    queue_closed_exception_types=None, queue_runner_def=None, import_scope=None
)

Queues are a convenient TensorFlow mechanism to compute tensors asynchronously using multiple threads. For example in the canonical 'Input Reader' setup one set of threads generates filenames in a queue; a second set of threads read records from the files, processes them, and enqueues tensors on a second queue; a third set of threads dequeues these input records to construct batches and runs them through training operations.

There are several delicate issues when running multiple threads that way: closing the queues in sequence as the input is exhausted, correctly catching and reporting exceptions, etc.

The QueueRunner, combined with the Coordinator, helps handle these issues.

Args:

Attributes:

Raises:

Eager Compatibility

QueueRunners are not compatible with eager execution. Instead, please use tf.data to get data into your model.

Methods

create_threads

View source

create_threads(
    sess, coord=None, daemon=False, start=False
)

Create threads to run the enqueue ops for the given session.

This method requires a session in which the graph was launched. It creates a list of threads, optionally starting them. There is one thread for each op passed in enqueue_ops.

The coord argument is an optional coordinator that the threads will use to terminate together and report exceptions. If a coordinator is given, this method starts an additional thread to close the queue when the coordinator requests a stop.

If previously created threads for the given session are still running, no new threads will be created.

Args:

Returns:

A list of threads.

from_proto

View source

@staticmethod
from_proto(
    queue_runner_def, import_scope=None
)

Returns a QueueRunner object created from queue_runner_def.

to_proto

View source

to_proto(
    export_scope=None
)

Converts this QueueRunner to a QueueRunnerDef protocol buffer.

Args:

Returns:

A QueueRunnerDef protocol buffer, or None if the Variable is not in the specified name scope.