def validate(self):
    correct = 0
    losses = []
    for minibatch in self.validation_loader:
        if self.use_cuda:
            anchor_frames = minibatch[0].cuda()
            anchor_quats = minibatch[1].cuda()
        (loss, a_pred) = self.loss_fn(self.model, anchor_frames, anchor_quats)
        losses.append(loss.data.cpu().numpy())
        correct += (torch.norm((a_pred - anchor_quats), 2) < 0.1).data.cpu().numpy().sum()
    self.writer.add_scalar('data/valid_loss', np.mean(losses), self.validation_calls)
    self.writer.add_scalar('data/validation_correct', (correct / self.len_validation_set), self.validation_calls)
    self.validation_calls += 1
    loss = np.mean(losses)
    self.logger.info('Validation score correct  {correct}/{total}'.format(correct=correct, total=self.len_validation_set))
    self.logger.info('val loss: ', loss)
    return (loss, correct)
def validate(self):
    correct = 0
    losses = []
    for minibatch in self.validation_loader:
        if self.use_cuda:
            anchor_frames = minibatch[0].cuda()
            anchor_quats = minibatch[1].cuda()
        (loss, a_pred) = self.loss_fn(self.model, anchor_frames, anchor_quats)
        losses.append(loss.data.cpu().numpy())
        correct += (torch.norm((a_pred - anchor_quats), 2) < 0.1).data.cpu().numpy().sum()
    self.writer.add_scalar('data/valid_loss', np.mean(losses), self.validation_calls)
    self.writer.add_scalar('data/validation_correct', (correct / self.len_validation_set), self.validation_calls)
    self.validation_calls += 1
    loss = np.mean(losses)
    self.logger.info('Validation score correct  {correct}/{total}'.format(correct=correct, total=self.len_validation_set))
    self.logger.info('val loss: ', loss)
    return (loss, correct)