Python test.Test() Examples
The following are 8
code examples of test.Test().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test
, or try the search function
.
Example #1
Source File: main.py From PyTorch-ENet with MIT License | 5 votes |
def test(model, test_loader, class_weights, class_encoding): print("\nTesting...\n") num_classes = len(class_encoding) # We are going to use the CrossEntropyLoss loss function as it's most # frequentely used in classification problems with multiple classes which # fits the problem. This criterion combines LogSoftMax and NLLLoss. criterion = nn.CrossEntropyLoss(weight=class_weights) # Evaluation metric if args.ignore_unlabeled: ignore_index = list(class_encoding).index('unlabeled') else: ignore_index = None metric = IoU(num_classes, ignore_index=ignore_index) # Test the trained model on the test set test = Test(model, test_loader, criterion, metric, device) print(">>>> Running test dataset") loss, (iou, miou) = test.run_epoch(args.print_step) class_iou = dict(zip(class_encoding.keys(), iou)) print(">>>> Avg. loss: {0:.4f} | Mean IoU: {1:.4f}".format(loss, miou)) # Print per class IoU for key, class_iou in zip(class_encoding.keys(), iou): print("{0}: {1:.4f}".format(key, class_iou)) # Show a batch of samples and labels if args.imshow_batch: print("A batch of predictions from the test set...") images, _ = iter(test_loader).next() predict(model, images, class_encoding)
Example #2
Source File: main.py From RPNet-Pytorch with MIT License | 5 votes |
def test(model, test_loader, class_weights, class_encoding, step): print("\nTesting...\n") num_classes = len(class_encoding) # We are going to use the CrossEntropyLoss loss function as it's most # frequentely used in classification problems with multiple classes which # fits the problem. This criterion combines LogSoftMax and NLLLoss. criterion = nn.CrossEntropyLoss(weight=class_weights) if use_cuda: criterion = criterion.cuda() # Evaluation metric if args.ignore_unlabeled: ignore_index = list(class_encoding).index('unlabeled') else: ignore_index = None metric = IoU(num_classes, ignore_index=ignore_index) # Test the trained model on the test set test = Test(model, test_loader, criterion, metric, use_cuda, step) print(">>>> Running test dataset") loss, (iou, miou) = test.run_epoch(args.print_step) class_iou = dict(zip(class_encoding.keys(), iou)) print(">>>> Avg. loss: {0:.4f} | Mean IoU: {1:.4f}".format(loss, miou)) # Print per class IoU for key, class_iou in zip(class_encoding.keys(), iou): print("{0}: {1:.4f}".format(key, class_iou)) # Show a batch of samples and labels if args.imshow_batch: print("A batch of predictions from the test set...") images, _ = iter(test_loader).next() predict(model, images, class_encoding)
Example #3
Source File: __init__.py From quark with Apache License 2.0 | 5 votes |
def invoke(self, object, args): obj = _cast(object, lambda: test.Test); (obj).go(); return None
Example #4
Source File: __init__.py From quark with Apache License 2.0 | 5 votes |
def __init__(self): super(test_Test, self).__init__(u"test.Test"); (self).name = u"test.Test" (self).parameters = _List([]) (self).fields = _List([quark.reflect.Field(u"quark.String", u"name")]) (self).methods = _List([test_Test_go_Method()]) (self).parents = _List([u"quark.Object"])
Example #5
Source File: __init__.py From quark with Apache License 2.0 | 5 votes |
def construct(self, args): return test.Test()
Example #6
Source File: __init__.py From quark with Apache License 2.0 | 5 votes |
def invoke(self, object, args): obj = _cast(object, lambda: test.subtest.Test); (obj).go(); return None
Example #7
Source File: __init__.py From quark with Apache License 2.0 | 5 votes |
def __init__(self): super(test_subtest_Test, self).__init__(u"test.subtest.Test"); (self).name = u"test.subtest.Test" (self).parameters = _List([]) (self).fields = _List([quark.reflect.Field(u"quark.int", u"size")]) (self).methods = _List([test_subtest_Test_go_Method()]) (self).parents = _List([u"quark.Object"])
Example #8
Source File: main.py From SMIT with MIT License | 5 votes |
def main(config): from torch.backends import cudnn # For fast training cudnn.benchmark = True data_loader = get_loader( config.mode_data, config.image_size, config.batch_size, config.dataset_fake, config.mode, num_workers=config.num_workers, all_attr=config.ALL_ATTR, c_dim=config.c_dim) from misc.scores import set_score if set_score(config): return if config.mode == 'train': from train import Train Train(config, data_loader) from test import Test test = Test(config, data_loader) test(dataset=config.dataset_real) elif config.mode == 'test': from test import Test test = Test(config, data_loader) if config.DEMO_PATH: test.DEMO(config.DEMO_PATH) else: test(dataset=config.dataset_real)