@torch.no_grad()
def test(self, split=None, return_per_class_results=False):
    'A generic testing pipeline.'
    self.set_model_mode('eval')
    self.evaluator.reset()
    if (split is None):
        split = self.cfg.TEST.SPLIT
    if ((split == 'val') and (self.val_loader is not None)):
        data_loader = self.val_loader
        print('Do evaluation on {} set'.format(split))
    else:
        data_loader = self.test_loader
        print('Do evaluation on test set')
    for (batch_idx, batch) in enumerate(data_loader):
        (input, label) = self.parse_batch_test(batch)
        output = self.model_inference(input)
        self.evaluator.process(output, label)
    results = self.evaluator.evaluate()
    for (k, v) in results.items():
        if (k == 'perclass_accuracies'):
            continue
        tag = '{}/{}'.format(split, k)
        self.write_scalar(tag, v, self.epoch)
    if (not return_per_class_results):
        return list(results.values())[0]
    else:
        return (results['accuracy'], results['perclass_accuracies'])
A generic testing pipeline.
@torch.no_grad()
def test(self, split=None, return_per_class_results=False):
    
    self.set_model_mode('eval')
    self.evaluator.reset()
    if (split is None):
        split = self.cfg.TEST.SPLIT
    if ((split == 'val') and (self.val_loader is not None)):
        data_loader = self.val_loader
        print('Do evaluation on {} set'.format(split))
    else:
        data_loader = self.test_loader
        print('Do evaluation on test set')
    for (batch_idx, batch) in enumerate(data_loader):
        (input, label) = self.parse_batch_test(batch)
        output = self.model_inference(input)
        self.evaluator.process(output, label)
    results = self.evaluator.evaluate()
    for (k, v) in results.items():
        if (k == 'perclass_accuracies'):
            continue
        tag = '{}/{}'.format(split, k)
        self.write_scalar(tag, v, self.epoch)
    if (not return_per_class_results):
        return list(results.values())[0]
    else:
        return (results['accuracy'], results['perclass_accuracies'])