def _get_val_loss(self):
    self.model.eval()
    validation_loss = torch.zeros(1, device=self.device, requires_grad=False)
    with torch.no_grad():
        for (data, target) in self.validation_loader:
            (data, target) = (data.to(self.device), target.to(self.device))
            output = self.model(data)
            validation_loss += self.loss_function(output, target).mean()
    validation_loss /= len(self.validation_loader.dataset)
    self.model.train()
    return validation_loss
def _get_val_loss(self):
    self.model.eval()
    validation_loss = torch.zeros(1, device=self.device, requires_grad=False)
    with torch.no_grad():
        for (data, target) in self.validation_loader:
            (data, target) = (data.to(self.device), target.to(self.device))
            output = self.model(data)
            validation_loss += self.loss_function(output, target).mean()
    validation_loss /= len(self.validation_loader.dataset)
    self.model.train()
    return validation_loss