def _try_tfevent_v2(event, val): if not val.HasField("tensor") or not _is_float_tensor(val.tensor): raise util.TryFailed() try: from tensorboard.util.tensor_util import make_ndarray except ImportError as e: log.debug("error importing make_ndarray: %s", e) raise util.TryFailed() return val.tag, make_ndarray(val.tensor).item(), event.step
def _try_tfevent_v2(event, val): if not val.HasField("tensor") or not _is_float_tensor(val.tensor): raise util.TryFailed() try: with warnings.catch_warnings(): warnings.simplefilter("ignore", Warning) from tensorboard.util.tensor_util import make_ndarray except ImportError as e: log.debug("error importing make_ndarray: %s", e) raise util.TryFailed() return val.tag, make_ndarray(val.tensor).item(), event.step
def _try_listen_tf_legacy(self): if not _tf_version().startswith("1."): raise util.TryFailed() try: # pylint: disable=import-error,no-name-in-module from tensorflow.summary import FileWriter except Exception as e: self.log.debug("error importing tensorflow.summary.FileWriter: %s", e) raise util.TryFailed() else: self.log.debug("wrapping tensorflow.summary.FileWriter.add_summary") python_util.listen_method(FileWriter, "add_summary", self._handle_summary)
def _try_listen_tf_v1(self): if not _tf_version().startswith("1."): raise util.TryFailed() try: from tensorflow.compat.v1.summary import FileWriter except Exception as e: self.log.debug( "error importing tensorflow.compat.v1.summary.FileWriter: %s", e) raise util.TryFailed() else: self.log.debug( "wrapping tensorflow.compat.v1.summary.FileWriter.add_summary") python_util.listen_method(FileWriter, "add_summary", self._handle_summary)
def _try_print_raw_run_attr(run, attr_name): try: val = run[attr_name] except KeyError: raise util.TryFailed() else: print(yaml_util.encode_yaml(val))
def _try_print_formatted_run_attr(run, attr_name): formatted = run_util.format_run(run) try: val = formatted[attr_name] except KeyError: raise util.TryFailed() else: print(val)
def _try_tfevent_v2(event, val): if not val.HasField("tensor"): raise util.TryFailed() if not _is_float_tensor(val.tensor): return None try: with warnings.catch_warnings(): warnings.simplefilter("ignore", Warning) from tensorboard.util.tensor_util import make_ndarray except ImportError as e: log.debug("error importing make_ndarray: %s", e) raise util.TryFailed() ndarray = make_ndarray(val.tensor) try: scalar_val = ndarray.item() except ValueError: return None else: return val.tag, scalar_val, event.step
def _try_listen_tf_v2(self): if not _tf_version().startswith("2."): raise util.TryFailed() self._listen_tb_v2_summary() self._listen_tf_v2_summary() self._listen_tf_summary()
def _try_tfevent_v1(event, val): if not val.HasField("simple_value"): raise util.TryFailed() return val.tag, val.simple_value, event.step