def _try_patch_tensorflow(self): try: import tensorflow as _ except ImportError: pass else: util.try_apply([ self._try_listen_tf_v2, self._try_listen_tf_v1, self._try_listen_tf_legacy, self._listen_tf_failed, ])
def __iter__(self): """Yields (tag, val, step) for scalars.""" events = self._tf_events() if not events: log.warning( "TF events API not supported - cannot read events " "from %r", self.dir) return try: for event in events: if not event.HasField("summary"): continue for val in event.summary.value: try: yield util.try_apply( [self._try_tfevent_v2, self._try_tfevent_v1], event, val) except util.TryFailed: log.debug("could not read event summary %s", val) except RuntimeError as e: # PEP 479 landed in Python 3.7 and TB triggers this # runtime error when there are no events to read. if e.args[0] != "generator raised StopIteration": raise
def __iter__(self): """Yields (tag, val, step) for all scalars in dir.""" for event in EventReader(self.dir): for val in event.summary.value: try: yield util.try_apply( [self._try_tfevent_v2, self._try_tfevent_v1], event, val) except util.TryFailed: log.debug("could not read event summary %s", val)
def _try_patch_tensorflow(self): util.try_apply([ self._try_listen_tf_v2, self._try_listen_tf_v1, self._try_listen_tf_legacy, self._log_listen_failed ])
def _print_run_attr(run, attr_name): util.try_apply([ lambda: _try_print_formatted_run_attr(run, attr_name), lambda: _try_print_raw_run_attr(run, attr_name), lambda: _no_such_run_attr_error(attr_name), ])