|
|
|
|
|
|
from collections import defaultdict |
|
|
|
from enum import Enum |
|
|
|
from typing import List, Dict, NamedTuple, Any |
|
|
|
from typing import List, Dict, NamedTuple, Any, Optional |
|
|
|
import numpy as np |
|
|
|
import abc |
|
|
|
import csv |
|
|
|
|
|
|
) -> None: |
|
|
|
if property_type == StatsPropertyType.HYPERPARAMETERS: |
|
|
|
assert isinstance(value, dict) |
|
|
|
text = self._dict_to_tensorboard("Hyperparameters", value) |
|
|
|
summary = self._dict_to_tensorboard("Hyperparameters", value) |
|
|
|
self.summary_writers[category].add_summary(text, 0) |
|
|
|
if summary is not None: |
|
|
|
self.summary_writers[category].add_summary(summary, 0) |
|
|
|
def _dict_to_tensorboard(self, name: str, input_dict: Dict[str, Any]) -> str: |
|
|
|
def _dict_to_tensorboard( |
|
|
|
self, name: str, input_dict: Dict[str, Any] |
|
|
|
) -> Optional[bytes]: |
|
|
|
""" |
|
|
|
Convert a dict to a Tensorboard-encoded string. |
|
|
|
:param name: The name of the text. |
|
|
|
|
|
|
s = sess.run(s_op) |
|
|
|
return s |
|
|
|
except Exception: |
|
|
|
logger.warning("Could not write text summary for Tensorboard.") |
|
|
|
return "" |
|
|
|
logger.warning( |
|
|
|
f"Could not write {name} summary for Tensorboard: {input_dict}" |
|
|
|
) |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
class CSVWriter(StatsWriter): |
|
|
|