def __call__(self): logger_util.add_model_indicators(self.model) logger.add_indicator(Queue("train_loss", 20, True)) logger.add_indicator(Histogram("test_loss", True)) logger.add_indicator(Histogram("accuracy", True)) for _ in self.loop: self._train() self._test() self.__log_model_params()
def __call__(self): # Training and testing logger_util.add_model_indicators(self.model) logger.add_indicator(Queue("train_loss", 20, True)) logger.add_indicator(Histogram("test_loss", True)) logger.add_indicator(Histogram("accuracy", True)) logger.add_indicator(IndexedScalar('test_sample_loss')) logger.add_indicator(IndexedScalar('test_sample_pred')) test_data = np.array([d[0].numpy() for d in self.test_loader.dataset]) logger.save_numpy("test_data", test_data) for _ in self.loop: self._train() self._test() self.__log_model_params()
def add_model_indicators(model: torch.nn.Module, model_name: str = "model"): for name, param in model.named_parameters(): if param.requires_grad: logger.add_indicator(Histogram(f"{model_name}.{name}")) logger.add_indicator(Histogram(f"{model_name}.{name}.grad"))
def startup(self): logger_util.add_model_indicators(self.model) logger.add_indicator(Queue("train_loss", 20, True)) logger.add_indicator(Histogram("test_loss", True)) logger.add_indicator(Histogram("accuracy", True))