drytorch.lib.aggregators
Module containing generic accumulator-based aggregators.
Classes
Stateful aggregation container. |
|
|
Aggregate named values using accumulator objects. |
|
Aggregator computing mean over floats. |
|
Accumulator computing arithmetic mean for floats. |
|
Aggregator computing mean over tensors with distributed support. |
|
Accumulator computing arithmetic mean for tensors. |
- class AbstractAccumulator[source]
-
Stateful aggregation container.
- abstractmethod classmethod from_value(value: _T) AbstractAccumulator[_T, _R][source]
Create accumulator from raw value.
- Parameters:
value (_T)
- Return type:
AbstractAccumulator[_T, _R]
- abstractmethod merge(other: AbstractAccumulator[_T, _R]) None[source]
Merge another accumulator into this one.
- Parameters:
other (AbstractAccumulator[_T, _R])
- Return type:
None
- class AbstractAggregator(**kwargs: _T)[source]
Bases:
Generic[_T,_R]Aggregate named values using accumulator objects.
Initialize.
- Parameters:
kwargs (_T) – named values to aggregate.
- __add__(other: AbstractAggregator[_T, _R] | Mapping[str, _T]) AbstractAggregator[_T, _R][source]
Return new aggregator containing merged data.
- Parameters:
other (AbstractAggregator[_T, _R] | Mapping[str, _T])
- Return type:
AbstractAggregator[_T, _R]
- __iadd__(other: AbstractAggregator[_T, _R] | Mapping[str, _T]) AbstractAggregator[_T, _R][source]
Merge another aggregator or mapping into this one.
- Parameters:
other (AbstractAggregator[_T, _R] | Mapping[str, _T])
- Return type:
AbstractAggregator[_T, _R]
- class MeanAccumulator(total: float, count: int)[source]
Bases:
AbstractAccumulator[float,float]Accumulator computing arithmetic mean for floats.
- classmethod from_value(value: float) MeanAccumulator[source]
Create accumulator from raw value.
- Parameters:
value (float)
- Return type:
- merge(other: MeanAccumulator) None[source]
Merge another accumulator into this one.
- Parameters:
other (MeanAccumulator)
- Return type:
None
- class TorchMeanAccumulator(total: Tensor, count: int)[source]
Bases:
AbstractAccumulator[Tensor,Tensor]Accumulator computing arithmetic mean for tensors.
- total
sum of all values.
- Type:
- classmethod from_value(value: Tensor) TorchMeanAccumulator[source]
Create accumulator from raw value.
- Parameters:
value (Tensor)
- Return type:
- merge(other: TorchMeanAccumulator) None[source]
Merge another accumulator into this one.
- Parameters:
other (TorchMeanAccumulator)
- Return type:
None
- class Averager(**kwargs: _T)[source]
Bases:
AbstractAggregator[float,float]Aggregator computing mean over floats.
Initialize.
- Parameters:
kwargs (_T) – named values to aggregate.
- accumulator_cls
alias of
MeanAccumulator
- class TorchAverager(**kwargs: _T)[source]
Bases:
AbstractAggregator[Tensor,Tensor]Aggregator computing mean over tensors with distributed support.
Initialize.
- Parameters:
kwargs (_T) – named values to aggregate.
- accumulator_cls
alias of
TorchMeanAccumulator