src/transformers/trainer_utils.py
def default_compute_objective(metrics: Dict[str, float]) -> float:
    """
    The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
    metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.

    Args:
        metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluate method.

    Return:
        :obj:`float`: The objective to minimize or maximize
    """
    metrics = copy.deepcopy(metrics)
    loss = metrics.pop("eval_loss", None)
    _ = metrics.pop("epoch", None)
    # Remove speed metrics
    speed_metrics = [m for m in metrics.keys() if m.endswith("_runtime") or m.endswith("_samples_per_second")]
    for sm in speed_metrics:
        _ = metrics.pop(sm, None)
    return loss if len(metrics) == 0 else sum(metrics.values())

    The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
    metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.

    Args:
        metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluate method.

    Return:
        :obj:`float`: The objective to minimize or maximize
    
The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.
The default objective to maximize / minimize when doing an hyperparameter search . It is the evaluation loss if no metrics are provided to the : class : ` ~transformers . Trainer ` the sum of all metrics otherwise .
def default_compute_objective(metrics: Dict[str, float]) -> float:
    metrics = copy.deepcopy(metrics)
    loss = metrics.pop("eval_loss", None)
    _ = metrics.pop("epoch", None)
    speed_metrics = [m for m in metrics.keys() if m.endswith("_runtime") or m.endswith("_samples_per_second")]
    for sm in speed_metrics:
        _ = metrics.pop(sm, None)
    return loss if len(metrics) == 0 else sum(metrics.values())
def default_compute_objective ( metrics : Dict [ str , float ] ) -> float : metrics = copy . deepcopy ( metrics ) loss = metrics . pop ( "eval_loss" , None ) _ = metrics . pop ( "epoch" , None ) speed_metrics = [ m for m in metrics . keys ( ) if m . endswith ( "_runtime" ) or m . endswith ( "_samples_per_second" ) ] for sm in speed_metrics : _ = metrics . pop ( sm , None ) return loss if len ( metrics ) == 0 else sum ( metrics . values ( ) )
The default objective to maximize/minimize when doing an hyperparameter search.
The default objective to maximize / minimize when doing an hyperparameter search .
"""
    The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
    metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.

    Args:
        metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluate method.

    Return:
        :obj:`float`: The objective to minimize or maximize
    """ # Remove speed metrics
metrics
Dict[str, float]
metrics (
`Dict[str, float]`): The metrics returned by the evaluate method.
` Dict [ str float ] ` ) : The metrics returned by the evaluate method .