def _eval_steps(self): eval_tqdm = tqdm(initial=0, total=len(self.dataloader["eval"]), desc="eval") for batch in self.dataloader["eval"]: batch = to_device(batch, self.device) self.eval(batch) eval_tqdm.update(1) eval_tqdm.close()
def _dev_step(self): if (self.steps % self.conf["dev_steps"] == 0 and self.steps > self.conf["dev_steps"] - 1 and self.steps != self.resume_steps): dev_loss_values = self._get_loss_dict() for dev_idx, batch in enumerate(self.dataloader["dev"]): batch = to_device(batch, self.device) dev_loss_values = self.dev(batch) if dev_idx > 0: break self._print_loss_values(dev_loss_values, phase="dev")
def _reconstruction_steps(self, tdir=False): for dkey in ["train", "dev"]: recon_tqdm = tqdm( initial=0, total=len(self.dataloader[dkey]), desc="reconstruction ({})".format(dkey), ) for batch in self.dataloader[dkey]: batch = to_device(batch, self.device) self.reconstruction(batch, tdir="reconstruction") recon_tqdm.update(1) recon_tqdm.close()
def _tr_step(self): for batch in self.dataloader["train"]: batch = to_device(batch, self.device) loss_values = self.train(batch, phase="train") if self.steps % self.conf["n_steps_print_loss"] == 0: self._print_loss_values(loss_values, phase="train") self._dev_step() # check step-by-step self._check_save_model() self._step_update() self._check_finish() # check custum func in each child self.check_custom_start()