nvflare.app_common.aggregators.weighted_aggregation_helper module

class WeightedAggregationHelper(exclude_vars: str | None = None, weigh_by_local_iter: bool = True)[source]

Bases: object

Perform weighted aggregation.

Parameters:
  • exclude_vars (str, optional) – regex string to match excluded vars during aggregation. Defaults to None.

  • weigh_by_local_iter (bool, optional) – Whether to weight the contributions by the number of iterations performed in local training in the current round. Defaults to True. Setting it to False can be useful in applications such as homomorphic encryption to reduce the number of computations on encrypted ciphertext. The aggregated sum will still be divided by the provided weights and aggregation_weights for the resulting weighted sum to be valid.

add(data, weight, contributor_name, contribution_round)[source]

Compute weighted sum and sum of weights.

get_history()[source]
get_len()[source]
get_result()[source]

Divide weighted sum by sum of weights.

reset_stats()[source]