espnet2.train.reporter.aggregate
Less than 1 minute
espnet2.train.reporter.aggregate
espnet2.train.reporter.aggregate(values: Sequence[ReportedValue]) → float | int | complex | Tensor | ndarray
Aggregate values of reported statistics.
This function computes the aggregated value from a sequence of ReportedValue instances. It supports both Average and WeightedAverage types. If the sequence contains invalid values, it will exclude them from the calculation. If the input is empty, it raises a warning and returns NaN.
- Parameters:
- values (Sequence [ReportedValue ]) – A sequence of ReportedValue
- instances (Average or WeightedAverage)
- Returns: The aggregated value, which can be of type float, int, complex, torch.Tensor, or np.ndarray.
- Return type: Num
- Raises:
- ValueError – If the input contains different types of ReportedValue
- instances or if the input sequence is empty. –
- NotImplementedError – If the type of the values is not supported.
Examples
>>> avg1 = Average(2.0)
>>> avg2 = Average(4.0)
>>> result = aggregate([avg1, avg2])
>>> print(result)
3.0
>>> wavg1 = WeightedAverage((3.0, 1.0), 0.5)
>>> wavg2 = WeightedAverage((7.0, 2.0), 1.5)
>>> result = aggregate([wavg1, wavg2])
>>> print(result)
5.0
>>> result = aggregate([])
>>> print(result)
nan