Runs a list of tensors to fill a queue to create batches of examples. The `tensors_list` argument is a list of tuples of tensors, or a list of dictionaries of tensors. Each element in the list is treated similarly to the `tensors` argument of `tf.compat.v1.train.batch()`. WARNING: This fu
(tensors_list, batch_size, capacity=32, enqueue_many=False,
shapes=None, dynamic_pad=False, allow_smaller_final_batch=False,
shared_name=None, name=None)
| 1083 | "`tf.data.Dataset.interleave(...).batch(batch_size)` (or " |
| 1084 | "`padded_batch(...)` if `dynamic_pad=True`).") |
| 1085 | def batch_join(tensors_list, batch_size, capacity=32, enqueue_many=False, |
| 1086 | shapes=None, dynamic_pad=False, allow_smaller_final_batch=False, |
| 1087 | shared_name=None, name=None): |
| 1088 | """Runs a list of tensors to fill a queue to create batches of examples. |
| 1089 | |
| 1090 | The `tensors_list` argument is a list of tuples of tensors, or a list of |
| 1091 | dictionaries of tensors. Each element in the list is treated similarly |
| 1092 | to the `tensors` argument of `tf.compat.v1.train.batch()`. |
| 1093 | |
| 1094 | WARNING: This function is nondeterministic, since it starts a separate thread |
| 1095 | for each tensor. |
| 1096 | |
| 1097 | Enqueues a different list of tensors in different threads. |
| 1098 | Implemented using a queue -- a `QueueRunner` for the queue |
| 1099 | is added to the current `Graph`'s `QUEUE_RUNNER` collection. |
| 1100 | |
| 1101 | `len(tensors_list)` threads will be started, |
| 1102 | with thread `i` enqueuing the tensors from |
| 1103 | `tensors_list[i]`. `tensors_list[i1][j]` must match |
| 1104 | `tensors_list[i2][j]` in type and shape, except in the first |
| 1105 | dimension if `enqueue_many` is true. |
| 1106 | |
| 1107 | If `enqueue_many` is `False`, each `tensors_list[i]` is assumed |
| 1108 | to represent a single example. An input tensor `x` will be output as a |
| 1109 | tensor with shape `[batch_size] + x.shape`. |
| 1110 | |
| 1111 | If `enqueue_many` is `True`, `tensors_list[i]` is assumed to |
| 1112 | represent a batch of examples, where the first dimension is indexed |
| 1113 | by example, and all members of `tensors_list[i]` should have the |
| 1114 | same size in the first dimension. The slices of any input tensor |
| 1115 | `x` are treated as examples, and the output tensors will have shape |
| 1116 | `[batch_size] + x.shape[1:]`. |
| 1117 | |
| 1118 | The `capacity` argument controls the how long the prefetching is allowed to |
| 1119 | grow the queues. |
| 1120 | |
| 1121 | The returned operation is a dequeue operation and will throw |
| 1122 | `tf.errors.OutOfRangeError` if the input queue is exhausted. If this |
| 1123 | operation is feeding another input queue, its queue runner will catch |
| 1124 | this exception, however, if this operation is used in your main thread |
| 1125 | you are responsible for catching this yourself. |
| 1126 | |
| 1127 | *N.B.:* If `dynamic_pad` is `False`, you must ensure that either |
| 1128 | (i) the `shapes` argument is passed, or (ii) all of the tensors in |
| 1129 | `tensors_list` must have fully-defined shapes. `ValueError` will be |
| 1130 | raised if neither of these conditions holds. |
| 1131 | |
| 1132 | If `dynamic_pad` is `True`, it is sufficient that the *rank* of the |
| 1133 | tensors is known, but individual dimensions may have value `None`. |
| 1134 | In this case, for each enqueue the dimensions with value `None` |
| 1135 | may have a variable length; upon dequeue, the output tensors will be padded |
| 1136 | on the right to the maximum shape of the tensors in the current minibatch. |
| 1137 | For numbers, this padding takes value 0. For strings, this padding is |
| 1138 | the empty string. See `PaddingFIFOQueue` for more info. |
| 1139 | |
| 1140 | If `allow_smaller_final_batch` is `True`, a smaller batch value than |
| 1141 | `batch_size` is returned when the queue is closed and there are not enough |
| 1142 | elements to fill the batch, otherwise the pending elements are discarded. |
nothing calls this directly
no test coverage detected