MCPcopy Create free account
hub / github.com/HobbitLong/PyContrast / logging

Method logging

pycontrast/learning/linear_trainer.py:19–35  ·  view source on GitHub ↗

logging to tensorboard Args: epoch: training epoch logs: loss and accuracy lr: learning rate train: True of False

(self, epoch, logs, lr=None, train=True)

Source from the content-addressed store, hash-verified

17 super(LinearTrainer, self).__init__(args)
18
19 def logging(self, epoch, logs, lr=None, train=True):
20 """ logging to tensorboard
21
22 Args:
23 epoch: training epoch
24 logs: loss and accuracy
25 lr: learning rate
26 train: True of False
27 """
28 args = self.args
29 if args.rank == 0:
30 pre = 'train_' if train else 'test_'
31 self.logger.log_value(pre+'acc', logs[0], epoch)
32 self.logger.log_value(pre+'acc5', logs[1], epoch)
33 self.logger.log_value(pre+'loss', logs[2], epoch)
34 if train and (lr is not None):
35 self.logger.log_value('learning_rate', lr, epoch)
36
37 def wrap_up(self, model, classifier):
38 """Wrap up models with DDP

Callers 1

main_workerFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected