Esempio n. 1
0
 def custom_train(config, models, dataloader, criterion, optimizers,
                  **kwargs):
     result = {}
     for i, (model, optimizer) in enumerate(zip(models, optimizers)):
         result["model_{}".format(i)] = train(config, model, dataloader,
                                              criterion, optimizer)
     return result
Esempio n. 2
0
    def step(self):
        """Runs a training epoch and updates the model parameters."""
        logger.debug("Begin Training Epoch {}".format(self.epoch + 1))
        with self._timers["training"]:
            train_stats = utils.train(self.train_loader, self.model,
                                      self.criterion, self.optimizer)
            train_stats["epoch"] = self.epoch

        self.epoch += 1

        train_stats.update(self.stats())
        return train_stats