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

Function _shuffle_batch_join

tensorflow/python/training/input.py:879–919  ·  view source on GitHub ↗

Helper function for `shuffle_batch_join` and `maybe_shuffle_batch_join`.

(tensors_list, batch_size, capacity,
                        min_after_dequeue, keep_input, seed=None,
                        enqueue_many=False, shapes=None,
                        allow_smaller_final_batch=False, shared_name=None,
                        name=None)

Source from the content-addressed store, hash-verified

877
878
879def _shuffle_batch_join(tensors_list, batch_size, capacity,
880 min_after_dequeue, keep_input, seed=None,
881 enqueue_many=False, shapes=None,
882 allow_smaller_final_batch=False, shared_name=None,
883 name=None):
884 """Helper function for `shuffle_batch_join` and `maybe_shuffle_batch_join`."""
885 if context.executing_eagerly():
886 raise ValueError(
887 "Input pipelines based on Queues are not supported when eager execution"
888 " is enabled. Please use tf.data to ingest data into your model"
889 " instead.")
890 tensor_list_list = _as_tensor_list_list(tensors_list)
891 with ops.name_scope(name, "shuffle_batch_join",
892 _flatten(tensor_list_list) + [keep_input]) as name:
893 tensor_list_list = _validate_join(tensor_list_list)
894 keep_input = _validate_keep_input(keep_input, enqueue_many)
895 tensor_list_list, sparse_info = _store_sparse_tensors_join(
896 tensor_list_list, enqueue_many, keep_input)
897 types = _dtypes(tensor_list_list)
898 shapes = _shapes(tensor_list_list, shapes, enqueue_many)
899 queue = data_flow_ops.RandomShuffleQueue(
900 capacity=capacity, min_after_dequeue=min_after_dequeue, seed=seed,
901 dtypes=types, shapes=shapes, shared_name=shared_name)
902 _enqueue_join(queue, tensor_list_list, enqueue_many, keep_input)
903 full = (math_ops.cast(
904 math_ops.maximum(0, queue.size() - min_after_dequeue), dtypes.float32) *
905 (1. / (capacity - min_after_dequeue)))
906 # Note that name contains a '/' at the end so we intentionally do not place
907 # a '/' after %s below.
908 summary_name = (
909 "fraction_over_%d_of_%d_full" %
910 (min_after_dequeue, capacity - min_after_dequeue))
911 summary.scalar(summary_name, full)
912
913 if allow_smaller_final_batch:
914 dequeued = queue.dequeue_up_to(batch_size, name=name)
915 else:
916 dequeued = queue.dequeue_many(batch_size, name=name)
917 dequeued = _restore_sparse_tensors(dequeued, sparse_info)
918 # tensors_list was validated to not be empty.
919 return _as_original_type(tensors_list[0], dequeued)
920
921# Batching functions ----------------------------------------------------------
922

Callers 2

shuffle_batch_joinFunction · 0.85
maybe_shuffle_batch_joinFunction · 0.85

Calls 15

sizeMethod · 0.95
_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
RandomShuffleQueueMethod · 0.80

Tested by

no test coverage detected