ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf.queue.PriorityQueue

A queue implementation that dequeues elements in prioritized order.

Inherits From: QueueBase

See tf.queue.QueueBase for a description of the methods on this class.

capacity An integer. The upper bound on the number of elements that may be stored in this queue.
types A list of DType objects. The length of types must equal the number of tensors in each queue element, except the first priority element. The first tensor in each element is the priority, which must be type int64.
shapes (Optional.) A list of fully-defined TensorShape objects, with the same length as types, or None.
names (Optional.) A list of strings naming the components in the queue with the same length as dtypes, or None. If specified, the dequeue methods return a dictionary with the names as keys.
shared_name (Optional.) If non-empty, this queue will be shared under the given name across multiple sessions.
name Optional name for the queue operation.

dtypes The list of dtypes for each component of a queue element.
name The name of the underlying queue.
names The list of names for each component of a queue element.
queue_ref The underlying queue reference.
shapes The list of shapes for each component of a queue element.

Methods

close

View source

Closes this queue.

This operation signals that no more elements will be enqueued in the given queue. Subsequent enqueue and enqueue_many operations will fail. Subsequent dequeue and dequeue_many operations will continue to succeed if sufficient elements remain in the queue. Subsequently dequeue and dequeue_many operations that would otherwise block waiting for more elements (if close hadn't been called) will now fail immediately.

If cancel_pending_enqueues is True, all pending requests will also be canceled.

Args
cancel_pending_enqueues (Optional.) A boolean, defaulting to False (described above).
name A name for the operation (optional).

Returns
The operation that closes the queue.

dequeue

View source

Dequeues one element from this queue.

If the queue is empty when this operation executes, it will block until there is an element to dequeue.

At runtime, this operation may raise an error if the queue is tf.QueueBase.close before or during its execution. If the queue is closed, the queue is empty, and there are no pending enqueue operations that can fulfill this request, tf.errors.OutOfRangeError will be raised. If the session is tf.Session.close, tf.errors.CancelledError will be raised.

Args
name A name for the operation (optional).

Returns
The tuple of tensors that was dequeued.