Class FeedingQueueRunner
Inherits From: QueueRunner
A queue runner that allows the feeding of values such as numpy arrays.
__init__
__init__(
queue=None,
enqueue_ops=None,
close_op=None,
cancel_op=None,
feed_fns=None,
queue_closed_exception_types=None
)
Initialize the queue runner.
For further documentation, see queue_runner.py. Note that
FeedingQueueRunner does not support construction from protobuffer nor
serialization to protobuffer.
Args:
queue: AQueue.enqueue_ops: List of enqueue ops to run in threads later.close_op: Op to close the queue. Pending enqueue ops are preserved.cancel_op: Op to close the queue and cancel pending enqueue ops.feed_fns: a list of functions that return a dictionary mapping fedTensors to values. Must be the same length asenqueue_ops.queue_closed_exception_types: Optional tuple of Exception types that indicate that the queue has been closed when raised during an enqueue operation. Defaults to(tf.errors.OutOfRangeError, tf.errors.CancelledError).
Raises:
ValueError:feed_fnsis notNoneand has different length thanenqueue_ops.
Properties
cancel_op
close_op
enqueue_ops
exceptions_raised
Exceptions raised but not handled by the QueueRunner threads.
Exceptions raised in queue runner threads are handled in one of two ways
depending on whether or not a Coordinator was passed to
create_threads():
- With a
Coordinator, exceptions are reported to the coordinator and forgotten by theQueueRunner. - Without a
Coordinator, exceptions are captured by theQueueRunnerand made available in thisexceptions_raisedproperty.
Returns:
A list of Python Exception objects. The list is empty if no exception
was captured. (No exceptions are captured when using a Coordinator.)
name
The string name of the underlying Queue.
queue
queue_closed_exception_types
Methods
tf.contrib.training.FeedingQueueRunner.create_threads
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:
sess: ASession.coord: OptionalCoordinatorobject for reporting errors and checking stop conditions.daemon: Boolean. IfTruemake the threads daemon threads.start: Boolean. IfTruestarts the threads. IfFalsethe caller must call thestart()method of the returned threads.
Returns:
A list of threads.
tf.contrib.training.FeedingQueueRunner.from_proto
from_proto(
queue_runner_def,
import_scope=None
)
Returns a QueueRunner object created from queue_runner_def.
tf.contrib.training.FeedingQueueRunner.to_proto
to_proto()
Converts this QueueRunner to a QueueRunnerDef protocol buffer.
Args:
export_scope: Optionalstring. Name scope to remove.
Returns:
A QueueRunnerDef protocol buffer, or None if the Variable is not in
the specified name scope.