Groups examples into batches, dropping remainder.
(iterable, batch_size)
| 183 | |
| 184 | |
| 185 | def batch(iterable, batch_size): |
| 186 | """Groups examples into batches, dropping remainder.""" |
| 187 | if batch_size < 1: |
| 188 | raise ValueError('batch_size must be a positive integer.') |
| 189 | item_batch = [] |
| 190 | for item in iterable: |
| 191 | item_batch.append(item) |
| 192 | if len(item_batch) == batch_size: |
| 193 | yield item_batch |
| 194 | item_batch = [] |
| 195 | |
| 196 | |
| 197 | @profile.profiled_function |
no outgoing calls
no test coverage detected
searching dependent graphs…