nemo/collections/asr/helpers.py
def process_evaluation_epoch(global_vars: dict, eval_metric='WER', tag=None):
    """
    Calculates the aggregated loss and WER across the entire evaluation dataset
    """
    eloss = torch.mean(torch.stack(global_vars['EvalLoss'])).item()
    hypotheses = global_vars['predictions']
    references = global_vars['transcripts']

    eval_metric = eval_metric.upper()
    if eval_metric not in {'WER', 'CER'}:
        raise ValueError('eval_metric must be \'WER\' or \'CER\'')
    use_cer = True if eval_metric == 'CER' else False

    wer = word_error_rate(hypotheses=hypotheses, references=references, use_cer=use_cer)

    if tag is None:
        logging.info(f"==========>>>>>>Evaluation Loss: {eloss}")
        logging.info(f"==========>>>>>>Evaluation {eval_metric}: " f"{wer * 100 : 5.2f}%")
        return {"Evaluation_Loss": eloss, f"Evaluation_{eval_metric}": wer}
    else:
        logging.info(f"==========>>>>>>Evaluation Loss {tag}: {eloss}")
        logging.info(f"==========>>>>>>Evaluation {eval_metric} {tag}: " f"{wer * 100 : 5.2f}%")
        return {
            f"Evaluation_Loss_{tag}": eloss,
            f"Evaluation_{eval_metric}_{tag}": wer,
        }

    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_evaluation_epoch(global_vars: dict, eval_metric='WER', tag=None):
    eloss = torch.mean(torch.stack(global_vars['EvalLoss'])).item()
    hypotheses = global_vars['predictions']
    references = global_vars['transcripts']
    eval_metric = eval_metric.upper()
    if eval_metric not in {'WER', 'CER'}:
        raise ValueError('eval_metric must be \'WER\' or \'CER\'')
    use_cer = True if eval_metric == 'CER' else False
    wer = word_error_rate(hypotheses=hypotheses, references=references, use_cer=use_cer)
    if tag is None:
        logging.info(f"==========>>>>>>Evaluation Loss: {eloss}")
        logging.info(f"==========>>>>>>Evaluation {eval_metric}: " f"{wer * 100 : 5.2f}%")
        return {"Evaluation_Loss": eloss, f"Evaluation_{eval_metric}": wer}
    else:
        logging.info(f"==========>>>>>>Evaluation Loss {tag}: {eloss}")
        logging.info(f"==========>>>>>>Evaluation {eval_metric} {tag}: " f"{wer * 100 : 5.2f}%")
        return {
            f"Evaluation_Loss_{tag}": eloss,
            f"Evaluation_{eval_metric}_{tag}": wer,
        }
def process_evaluation_epoch ( global_vars : dict , eval_metric = 'WER' , tag = None ) : eloss = torch . mean ( torch . stack ( global_vars [ 'EvalLoss' ] ) ) . item ( ) hypotheses = global_vars [ 'predictions' ] references = global_vars [ 'transcripts' ] eval_metric = eval_metric . upper ( ) if eval_metric not in { 'WER' , 'CER' } : raise ValueError ( 'eval_metric must be \'WER\' or \'CER\'' ) use_cer = True if eval_metric == 'CER' else False wer = word_error_rate ( hypotheses = hypotheses , references = references , use_cer = use_cer ) if tag is None : logging . info ( f"==========>>>>>>Evaluation Loss: {eloss}" ) logging . info ( f"==========>>>>>>Evaluation {eval_metric}: " f"{wer * 100 : 5.2f}%" ) return { "Evaluation_Loss" : eloss , f"Evaluation_{eval_metric}" : wer } else : logging . info ( f"==========>>>>>>Evaluation Loss {tag}: {eloss}" ) logging . info ( f"==========>>>>>>Evaluation {eval_metric} {tag}: " f"{wer * 100 : 5.2f}%" ) return { f"Evaluation_Loss_{tag}" : eloss , f"Evaluation_{eval_metric}_{tag}" : wer , }
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