当前位置: 首页>>代码示例>>Python>>正文


Python test.Test方法代码示例

本文整理汇总了Python中test.Test方法的典型用法代码示例。如果您正苦于以下问题:Python test.Test方法的具体用法?Python test.Test怎么用?Python test.Test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test的用法示例。


在下文中一共展示了test.Test方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
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) 
开发者ID:davidtvs,项目名称:PyTorch-ENet,代码行数:38,代码来源:main.py

示例2: test

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
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) 
开发者ID:superlxt,项目名称:RPNet-Pytorch,代码行数:40,代码来源:main.py

示例3: invoke

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
def invoke(self, object, args):
        obj = _cast(object, lambda: test.Test);
        (obj).go();
        return None 
开发者ID:datawire,项目名称:quark,代码行数:6,代码来源:__init__.py

示例4: __init__

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
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"]) 
开发者ID:datawire,项目名称:quark,代码行数:9,代码来源:__init__.py

示例5: construct

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
def construct(self, args):
        return test.Test() 
开发者ID:datawire,项目名称:quark,代码行数:4,代码来源:__init__.py

示例6: main

# 需要导入模块: import test [as 别名]
# 或者: from test import Test [as 别名]
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) 
开发者ID:BCV-Uniandes,项目名称:SMIT,代码行数:35,代码来源:main.py


注:本文中的test.Test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。