MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _batch_join

Function _batch_join

tensorflow/python/training/input.py:800–832  ·  view source on GitHub ↗

Helper function for `batch_join` and `maybe_batch_join`.

(tensors_list, batch_size, keep_input, capacity=32,
                enqueue_many=False, shapes=None, dynamic_pad=False,
                allow_smaller_final_batch=False, shared_name=None, name=None)

Source from the content-addressed store, hash-verified

798# read that many files in parallel due to the number of seeks required).
799# Once this is done, batch() can be written as a call to batch_join().
800def _batch_join(tensors_list, batch_size, keep_input, capacity=32,
801 enqueue_many=False, shapes=None, dynamic_pad=False,
802 allow_smaller_final_batch=False, shared_name=None, name=None):
803 """Helper function for `batch_join` and `maybe_batch_join`."""
804 if context.executing_eagerly():
805 raise ValueError(
806 "Input pipelines based on Queues are not supported when eager execution"
807 " is enabled. Please use tf.data to ingest data into your model"
808 " instead.")
809 tensor_list_list = _as_tensor_list_list(tensors_list)
810 with ops.name_scope(name, "batch_join",
811 _flatten(tensor_list_list) + [keep_input]) as name:
812 tensor_list_list = _validate_join(tensor_list_list)
813 keep_input = _validate_keep_input(keep_input, enqueue_many)
814 tensor_list_list, sparse_info = _store_sparse_tensors_join(
815 tensor_list_list, enqueue_many, keep_input)
816 types = _dtypes(tensor_list_list)
817 shapes = _shapes(tensor_list_list, shapes, enqueue_many)
818 # TODO(josh11b,mrry): Switch to BatchQueue once it is written.
819 queue = _which_queue(dynamic_pad)(
820 capacity=capacity, dtypes=types, shapes=shapes, shared_name=shared_name)
821 _enqueue_join(queue, tensor_list_list, enqueue_many, keep_input)
822 summary.scalar(
823 "fraction_of_%d_full" % capacity,
824 math_ops.cast(queue.size(), dtypes.float32) * (1. / capacity))
825
826 if allow_smaller_final_batch:
827 dequeued = queue.dequeue_up_to(batch_size, name=name)
828 else:
829 dequeued = queue.dequeue_many(batch_size, name=name)
830 dequeued = _restore_sparse_tensors(dequeued, sparse_info)
831 # tensors_list was validated to not be empty.
832 return _as_original_type(tensors_list[0], dequeued)
833
834
835def _shuffle_batch(tensors, batch_size, capacity, min_after_dequeue,

Callers 2

batch_joinFunction · 0.85
maybe_batch_joinFunction · 0.85

Calls 15

_as_tensor_list_listFunction · 0.85
_validate_joinFunction · 0.85
_validate_keep_inputFunction · 0.85
_dtypesFunction · 0.85
_shapesFunction · 0.85
_enqueue_joinFunction · 0.85
_restore_sparse_tensorsFunction · 0.85
_as_original_typeFunction · 0.85
executing_eagerlyMethod · 0.80
dequeue_up_toMethod · 0.80
dequeue_manyMethod · 0.80

Tested by

no test coverage detected