Example #1
0
def get_data_set(type='train'):
    if type == 'train':
        return imagenet_dali.get_imagenet_iter_dali('train', args.data_path, args.train_batch_size,
                                                   num_threads=4, crop=224, device_id=args.gpus[0], num_gpus=1)
    else:
        return imagenet_dali.get_imagenet_iter_dali('val', args.data_path, args.eval_batch_size,
                                                   num_threads=4, crop=224, device_id=args.gpus[0], num_gpus=1)
Example #2
0
 def get_data_set(type='train'):
     if type == 'train':
         return imagenet_dali.get_imagenet_iter_dali('train',
                                                     args.data_dir,
                                                     args.batch_size,
                                                     num_threads=4,
                                                     crop=224,
                                                     device_id=0,
                                                     num_gpus=1)
     else:
         return imagenet_dali.get_imagenet_iter_dali('val',
                                                     args.data_dir,
                                                     args.batch_size,
                                                     num_threads=4,
                                                     crop=224,
                                                     device_id=0,
                                                     num_gpus=1)
from importlib import import_module

device = torch.device(
    f"cuda:{args.gpus[0]}") if torch.cuda.is_available() else 'cpu'
loss_func = nn.CrossEntropyLoss()

# Data
print('==> Preparing data..')
if args.data_set == 'cifar10':
    testLoader = cifar10.Data(args).testLoader
else:  #imagenet
    if device != 'cpu':
        testLoader = imagenet_dali.get_imagenet_iter_dali(
            'val',
            args.data_path,
            args.eval_batch_size,
            num_threads=4,
            crop=224,
            device_id=args.gpus[0],
            num_gpus=1)
    else:
        testLoader = imagenet.Data(args).testLoader


def test(model, topk=(1, )):
    model.eval()

    losses = utils.AverageMeter()
    accuracy = utils.AverageMeter()
    top5_accuracy = utils.AverageMeter()

    start_time = time.time()