Beispiel #1
0
    def train_iterations(self):
        """Train model for the 'self.epochs' number of batches."""

        self.model.train()
        pbar = ProgressBar(target=self.epochs, width=8)
        iterator = InfiniteDataLoader(self.train_loader)
        correct = 0
        processed = 0
        for iteration in range(self.epochs):
            # Train a batch
            data, target = iterator.get_batch()
            loss = self.train_batch(data, target)

            # Update Progress Bar
            accuracy = 100 * self.train_correct / self.train_processed
            pbar.update(iteration,
                        values=[('loss', round(loss, 2)),
                                ('accuracy', round(accuracy, 2))])

            # Update training history
            self.update_training_history(loss, accuracy)

        pbar.add(1,
                 values=[('loss', round(loss, 2)),
                         ('accuracy', round(accuracy, 2))])
Beispiel #2
0
    def train_iterations(self):
        """Train model for the 'self.epochs' number of batches."""

        self.model.train()
        pbar = ProgressBar(target=self.epochs, width=8)
        iterator = InfiniteDataLoader(self.train_loader)
        for iteration in range(self.epochs):
            # Train a batch
            loss = self.train_batch(iterator.get_batch())

            # Update Progress Bar
            pbar_values = self._get_pbar_values(loss)
            pbar.update(iteration, values=pbar_values)

            # Update training history
            self.update_training_history(loss)

        pbar.add(1, values=pbar_values)