Retrieves the next batch of input data.
(generator)
| 358 | |
| 359 | |
| 360 | def _get_next_batch(generator): |
| 361 | """Retrieves the next batch of input data.""" |
| 362 | try: |
| 363 | generator_output = next(generator) |
| 364 | except (StopIteration, errors.OutOfRangeError): |
| 365 | return None |
| 366 | |
| 367 | if not isinstance(generator_output, tuple): |
| 368 | # Always wrap in a tuple. |
| 369 | generator_output = (generator_output,) |
| 370 | if len(generator_output) not in [1, 2, 3]: |
| 371 | raise ValueError( |
| 372 | 'Output of generator should be a tuple of 1 or 2 or 3 ' |
| 373 | 'elements: (input,) or (input, target) or ' |
| 374 | '(input, target, sample_weights). Received {}'.format(generator_output)) |
| 375 | return generator_output |
| 376 | |
| 377 | |
| 378 | def _validate_arguments(is_sequence, is_dataset, use_multiprocessing, workers, |
no test coverage detected