(model, criterion, dataloader)
return (losses.avg,
            {'top1': top1.avg, 'top5': top5.avg})
Computes accuracy of given CNN model.
  
    :param model: PyTorch model
    :type model: `torch.nn.Module`
    :param criterion: Loss function
    :param dataloader: Data loader to use
    :return: Top-1 and Top-5 accuracies
    :rtype: Tuple(top1, top5)
Computes accuracy of given CNN model.
  
    :param model: PyTorch model
    :type model: `torch.nn.Module`
    :param criterion: Loss function
    :param dataloader: Data loader to use
    :return: Top-1 and Top-5 accuracies
    :rtype: Tuple(top1, top5)
Computes accuracy of given CNN model . : param model : PyTorch model : type model : torch . nn . Module : param criterion : Loss function : param dataloader : Data loader to use : return : Top - 1 and Top - 5 accuracies : rtype : Tuple ( top1 top5 )
def cnn_statistics(model, criterion, dataloader):
    """
    Computes accuracy of given CNN model.
  
    :param model: PyTorch model
    :type model: `torch.nn.Module`
    :param criterion: Loss function
    :param dataloader: Data loader to use
    :return: Top-1 and Top-5 accuracies
    :rtype: Tuple(top1, top5)
    """
    losses = AverageMeter()
    top1 = AverageMeter()
    top5 = AverageMeter()

    model.eval()
    pzero = list(model.parameters())[0]
    if (pzero.dtype != torch.float32 and pzero.dtype != torch.float16):
        raise NotImplementedError('Only FP16 and FP32 weights are supported')
    cast2fp16 = (isinstance(pzero, torch.HalfTensor)
                 or isinstance(pzero, torch.cuda.HalfTensor))
    loss = 0.
    correct = 0.
    with torch.no_grad():
        for input, target in dataloader:
            if torch.cuda.is_available():
                input = input.cuda(non_blocking=True)
                target = target.cuda(non_blocking=True)
            if cast2fp16:
                input = input.half()
            output = model(input)
            loss = criterion(output, target)
            prec1, prec5 = accuracy(output.data, target, topk=(1, 5))
            losses.update(to_python_float(loss.data), input.size(0))
            top1.update(to_python_float(prec1), input.size(0))
            top5.update(to_python_float(prec5), input.size(0))
    return (losses.avg,
            {'top1': top1.avg, 'top5': top5.avg})
def cnn_statistics ( model , criterion , dataloader ) : losses = AverageMeter ( ) top1 = AverageMeter ( ) top5 = AverageMeter ( ) model . eval ( ) pzero = list ( model . parameters ( ) ) [ 0 ] if ( pzero . dtype != torch . float32 and pzero . dtype != torch . float16 ) : raise NotImplementedError ( 'Only FP16 and FP32 weights are supported' ) cast2fp16 = ( isinstance ( pzero , torch . HalfTensor ) or isinstance ( pzero , torch . cuda . HalfTensor ) ) loss = 0. correct = 0. with torch . no_grad ( ) : for input , target in dataloader : if torch . cuda . is_available ( ) : input = input . cuda ( non_blocking = True ) target = target . cuda ( non_blocking = True ) if cast2fp16 : input = input . half ( ) output = model ( input ) loss = criterion ( output , target ) prec1 , prec5 = accuracy ( output . data , target , topk = ( 1 , 5 ) ) losses . update ( to_python_float ( loss . data ) , input . size ( 0 ) ) top1 . update ( to_python_float ( prec1 ) , input . size ( 0 ) ) top5 . update ( to_python_float ( prec5 ) , input . size ( 0 ) ) return ( losses . avg , { 'top1' : top1 . avg , 'top5' : top5 . avg } )