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

Method get

tensorflow/python/keras/utils/data_utils.py:886–922  ·  view source on GitHub ↗

Creates a generator to extract data from the queue. Skip the data if it is `None`. Yields: The next element in the queue, i.e. a tuple `(inputs, targets)` or `(inputs, targets, sample_weights)`.

(self)

Source from the content-addressed store, hash-verified

884 executor.apply_async(next_sample, (self.uid,)), block=True)
885
886 def get(self):
887 """Creates a generator to extract data from the queue.
888
889 Skip the data if it is `None`.
890
891 Yields:
892 The next element in the queue, i.e. a tuple
893 `(inputs, targets)` or
894 `(inputs, targets, sample_weights)`.
895 """
896 try:
897 while self.is_running():
898 inputs = self.queue.get(block=True).get()
899 self.queue.task_done()
900 if inputs is not None:
901 yield inputs
902 except StopIteration:
903 # Special case for finite generators
904 last_ones = []
905 while self.queue.qsize() > 0:
906 last_ones.append(self.queue.get(block=True))
907 # Wait for them to complete
908 for f in last_ones:
909 f.wait()
910 # Keep the good ones
911 last_ones = [future.get() for future in last_ones if future.successful()]
912 for inputs in last_ones:
913 if inputs is not None:
914 yield inputs
915 except Exception as e: # pylint: disable=broad-except
916 self.stop()
917 if 'generator already executing' in str(e):
918 raise RuntimeError(
919 'Your generator is NOT thread-safe. '
920 'Keras requires a thread-safe generator when '
921 '`use_multiprocessing=False, workers > 1`. ')
922 six.reraise(*sys.exc_info())

Calls 5

is_runningMethod · 0.80
getMethod · 0.45
appendMethod · 0.45
waitMethod · 0.45
stopMethod · 0.45