MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / __init__

Method __init__

custom_writer.py:17–41  ·  view source on GitHub ↗
(self, log_dir, enabled=True)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected