tf.queue.PriorityQueue

View source on GitHub

A queue implementation that dequeues elements in prioritized order.

Inherits From: QueueBase

tf.queue.PriorityQueue(
    capacity, types, shapes=None, names=None, shared_name=None,
    name='priority_queue'
)

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

Args:

Attributes:

Methods

close

View source

close(
    cancel_pending_enqueues=False, name=None
)

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:

Returns:

The operation that closes the queue.

dequeue

View source

dequeue(
    name=None
)

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:

Returns:

The tuple of tensors that was dequeued.

dequeue_many

View source

dequeue_many(
    n, name=None
)

Dequeues and concatenates n elements from this queue.

This operation concatenates queue-element component tensors along the 0th dimension to make a single component tensor. All of the components in the dequeued tuple will have size n in the 0th dimension.

If the queue is closed and there are less than n elements left, then an OutOfRange exception is raised.

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 contains fewer than n elements, 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:

Returns:

The list of concatenated tensors that was dequeued.

dequeue_up_to

View source

dequeue_up_to(
    n, name=None
)

Dequeues and concatenates n elements from this queue.

Note This operation is not supported by all queues. If a queue does not support DequeueUpTo, then a tf.errors.UnimplementedError is raised.

This operation concatenates queue-element component tensors along the 0th dimension to make a single component tensor. If the queue has not been closed, all of the components in the dequeued tuple will have size n in the 0th dimension.

If the queue is closed and there are more than 0 but fewer than n elements remaining, then instead of raising a tf.errors.OutOfRangeError like tf.QueueBase.dequeue_many, less than n elements are returned immediately. If the queue is closed and there are 0 elements left in the queue, then a tf.errors.OutOfRangeError is raised just like in dequeue_many. Otherwise the behavior is identical to dequeue_many.

Args:

Returns:

The tuple of concatenated tensors that was dequeued.

enqueue

View source

enqueue(
    vals, name=None
)

Enqueues one element to this queue.

If the queue is full when this operation executes, it will block until the element has been enqueued.

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 before this operation runs, tf.errors.CancelledError will be raised. If this operation is blocked, and either (i) the queue is closed by a close operation with cancel_pending_enqueues=True, or (ii) the session is tf.Session.close, tf.errors.CancelledError will be raised.

Args:

Returns:

The operation that enqueues a new tuple of tensors to the queue.

enqueue_many

View source

enqueue_many(
    vals, name=None
)

Enqueues zero or more elements to this queue.

This operation slices each component tensor along the 0th dimension to make multiple queue elements. All of the tensors in vals must have the same size in the 0th dimension.

If the queue is full when this operation executes, it will block until all of the elements have been enqueued.

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 before this operation runs, tf.errors.CancelledError will be raised. If this operation is blocked, and either (i) the queue is closed by a close operation with cancel_pending_enqueues=True, or (ii) the session is tf.Session.close, tf.errors.CancelledError will be raised.

Args:

Returns:

The operation that enqueues a batch of tuples of tensors to the queue.

from_list

View source

@staticmethod
from_list(
    index, queues
)

Create a queue using the queue reference from queues[index].

Args:

Returns:

A QueueBase object.

Raises:

is_closed

View source

is_closed(
    name=None
)

Returns true if queue is closed.

This operation returns true if the queue is closed and false if the queue is open.

Args:

Returns:

True if the queue is closed and false if the queue is open.

size

View source

size(
    name=None
)

Compute the number of elements in this queue.

Args:

Returns:

A scalar tensor containing the number of elements in this queue.