nemo/collections/asr/helpers.py
def process_classification_evaluation_epoch(global_vars: dict, eval_metric=None, tag=None):
    """
    Calculates the aggregated loss and WER across the entire evaluation dataset
    """
    if eval_metric is None:
        eval_metric = [1]

    if type(eval_metric) not in (list, tuple):
        eval_metric = [eval_metric]

    top_k = eval_metric

    eloss = torch.mean(torch.stack(global_vars['EvalLoss'])).item()
    batch_sizes = global_vars['batchsize']
    total_num_samples = torch.tensor(batch_sizes).sum().float()

    topk_accs = []
    for k in top_k:
        correct_counts = torch.tensor(global_vars[f'CorrectCount@{k}'])
        topk_acc = correct_counts.sum() / total_num_samples
        topk_accs.append(topk_acc)

    if tag is None:
        tag = ''

    logs = {f"Evaluation_Loss {tag}": eloss}

    logging.info(f"==========>>>>>>Evaluation Loss {tag}: {eloss}")
    for k, acc in zip(top_k, topk_accs):
        logging.info(f"==========>>>>>>Evaluation Accuracy Top@{k} {tag}: {acc * 100.:3.4f}")
        logs[f'Evaluation_Accuracy_Top@{k} {tag}'] = acc * 100.0

    return logs

    Calculates the aggregated loss and WER across the entire evaluation dataset
    
Calculates the aggregated loss and WER across the entire evaluation dataset
Calculates the aggregated loss and WER across the entire evaluation dataset
def process_classification_evaluation_epoch(global_vars: dict, eval_metric=None, tag=None):
    if eval_metric is None:
        eval_metric = [1]
    if type(eval_metric) not in (list, tuple):
        eval_metric = [eval_metric]
    top_k = eval_metric
    eloss = torch.mean(torch.stack(global_vars['EvalLoss'])).item()
    batch_sizes = global_vars['batchsize']
    total_num_samples = torch.tensor(batch_sizes).sum().float()
    topk_accs = []
    for k in top_k:
        correct_counts = torch.tensor(global_vars[f'CorrectCount@{k}'])
        topk_acc = correct_counts.sum() / total_num_samples
        topk_accs.append(topk_acc)
    if tag is None:
        tag = ''
    logs = {f"Evaluation_Loss {tag}": eloss}
    logging.info(f"==========>>>>>>Evaluation Loss {tag}: {eloss}")
    for k, acc in zip(top_k, topk_accs):
        logging.info(f"==========>>>>>>Evaluation Accuracy Top@{k} {tag}: {acc * 100.:3.4f}")
        logs[f'Evaluation_Accuracy_Top@{k} {tag}'] = acc * 100.0
    return logs
def process_classification_evaluation_epoch ( global_vars : dict , eval_metric = None , tag = None ) : if eval_metric is None : eval_metric = [ 1 ] if type ( eval_metric ) not in ( list , tuple ) : eval_metric = [ eval_metric ] top_k = eval_metric eloss = torch . mean ( torch . stack ( global_vars [ 'EvalLoss' ] ) ) . item ( ) batch_sizes = global_vars [ 'batchsize' ] total_num_samples = torch . tensor ( batch_sizes ) . sum ( ) . float ( ) topk_accs = [ ] for k in top_k : correct_counts = torch . tensor ( global_vars [ f'CorrectCount@{k}' ] ) topk_acc = correct_counts . sum ( ) / total_num_samples topk_accs . append ( topk_acc ) if tag is None : tag = '' logs = { f"Evaluation_Loss {tag}" : eloss } logging . info ( f"==========>>>>>>Evaluation Loss {tag}: {eloss}" ) for k , acc in zip ( top_k , topk_accs ) : logging . info ( f"==========>>>>>>Evaluation Accuracy Top@{k} {tag}: {acc * 100.:3.4f}" ) logs [ f'Evaluation_Accuracy_Top@{k} {tag}' ] = acc * 100.0 return logs
Calculates the aggregated loss and WER across the entire evaluation dataset
Calculates the aggregated loss and WER across the entire evaluation dataset
"""
    Calculates the aggregated loss and WER across the entire evaluation dataset
    """
global_vars
dict
eval_metric
tag