def fit(self): printer = Printer() while self.epoch < self.epochs: self.new_epoch() # increments self.epoch self.logger.set_mode("train") stats = self.train_epoch(self.epoch) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\ntrain: ") if self.epoch % self.test_every_n_epochs == 0 or self.phase1_will_end( ) or self.phase2_will_end(): self.logger.set_mode("test") stats = self.test_epoch(self.validdataloader) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\nvalid: ") if hasattr(self, "visdom"): self.visdom_log_test_run(stats) if hasattr(self, "visdom"): self.visdom.plot_epochs(self.logger.get_data()) self.check_events() # stores all stored values in the rootpath of the logger #if self.save_logger: self.logger.save() return self.logger.data
def fit(self): printer = Printer() while self.epoch < self.epochs: self.new_epoch() # increments self.epoch self.logger.set_mode("train") stats = self.train_epoch(self.epoch) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\n" + self.traindataloader.dataset.partition + ": ") if self.epoch % self.test_every_n_epochs == 0 or self.epoch == 1: self.logger.set_mode("test") stats = self.test_epoch(self.validdataloader) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\n" + self.validdataloader.dataset.partition + ": ") if self.visdom is not None: self.visdom_log_test_run(stats) if self.visdom is not None: self.visdom.plot_epochs(self.logger.get_data()) if self.checkpoint_every_n_epochs % self.epoch == 0: print("Saving model to {}".format(self.get_model_name())) self.snapshot(self.get_model_name()) print("Saving log to {}".format(self.get_log_name())) self.logger.get_data().to_csv(self.get_log_name()) if self.epoch > self.early_stopping_smooth_period and self.check_for_early_stopping( smooth_period=self.early_stopping_smooth_period): print() print( f"Model did not improve in the last {self.early_stopping_smooth_period} epochs. stopping training..." ) print("Saving model to {}".format(self.get_model_name())) self.snapshot(self.get_model_name()) print("Saving log to {}".format(self.get_log_name())) self.logger.get_data().to_csv(self.get_log_name()) return self.logger return self.logger
def fit(self): printer = Printer() while self.epoch < self.epochs: self.new_epoch() # increments self.epoch self.logger.set_mode("train") stats = self.train_epoch(self.epoch) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\ntrain: ") if self.epoch % self.test_every_n_epochs == 0 or self.phase1_will_end( ) or self.phase2_will_end(): self.logger.set_mode("test") stats = self.test_epoch(self.epoch) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\nvalid: ") self.visdom_log_test_run(stats) self.visdom.plot_epochs(self.logger.get_data()) self.check_events() return self.logger.data
def fit(self, epochs): printer = Printer() while self.epoch < epochs: self.new_epoch() # increments self.epoch self.logger.set_mode("train") stats = self.train_epoch(self.epoch) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\ntrain: ") if self.epoch % self.test_every_n_epochs == 0: self.logger.set_mode("test") stats = self.test_epoch(self.testdataloader) self.logger.log(stats, self.epoch) printer.print(stats, self.epoch, prefix="\ntest: ") if hasattr(self, "visdom"): self.visdom_log_test_run(stats) if hasattr(self, "visdom"): self.visdom.plot_epochs(self.logger.get_data()) self.logger.save() return self.logger.data