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


Base class for queue implementations.

A queue is a TensorFlow data structure that stores tensors across multiple steps, and exposes operations that enqueue and dequeue tensors.

Each queue element is a tuple of one or more tensors, where each tuple component has a static dtype, and may have a static shape. The queue implementations support versions of enqueue and dequeue that handle single elements, versions that support enqueuing and dequeuing a batch of elements at once.

See tf.queue.FIFOQueue and tf.queue.RandomShuffleQueue for concrete implementations of this class, and instructions on how to create them.

dtypes A list of types. The length of dtypes must equal the number of tensors in each element.
shapes Constraints on the shapes of tensors in an element: A list of shape tuples or None. This list is the same length as dtypes. If the shape of any tensors in the element are constrained, all must be; shapes can be None if the shapes should not be constrained.
names Optional list of names. If provided, the enqueue() and dequeue() methods will use dictionaries with these names as keys. Must be None or a list or tuple of the same length as dtypes.
queue_ref The queue reference, i.e. the output of the queue op.

ValueError If one of the arguments is invalid.

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.



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.

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

The operation that closes the queue.


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 exe