(self, log_dir, enabled=True)
| 15 | enabled : bool, whether to enable tensorboard writer. |
| 16 | ''' |
| 17 | def __init__(self, log_dir, enabled=True): |
| 18 | self.writer = None |
| 19 | self.selected_module = '' |
| 20 | |
| 21 | if enabled: |
| 22 | self.log_dir = str(log_dir) |
| 23 | self.stats = {} |
| 24 | if not os.path.exists(self.log_dir): |
| 25 | os.makedirs(self.log_dir, exist_ok=True) |
| 26 | |
| 27 | # Attributes to record |
| 28 | self.epoch = 0 |
| 29 | self.mode = None |
| 30 | self.timer = datetime.datetime.now() |
| 31 | self.tb_writer_funcs = { |
| 32 | 'add_scalar', 'add_scalars', |
| 33 | 'add_image', 'add_images', |
| 34 | 'add_figure', |
| 35 | 'add_audio', |
| 36 | 'add_text', |
| 37 | 'add_histogram', |
| 38 | 'add_pr_curve', |
| 39 | #'add_embedding', # TODO: problem with add_embedding |
| 40 | } |
| 41 | self.tag_mode_exceptions = {'add_histogram', 'add_embedding'} # TODO : Test these two funcs. |
| 42 | |
| 43 | def dump_stats(self): |
| 44 | with open(f"{self.log_dir}/log", "w") as f: |
nothing calls this directly
no outgoing calls
no test coverage detected