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)
| 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(). |
| 800 | def _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 | |
| 835 | def _shuffle_batch(tensors, batch_size, capacity, min_after_dequeue, |
no test coverage detected