nvflare.app_common.aggregators.model_aggregator module

class ModelAggregator[source]

Bases: Aggregator

Abstract class for aggregating FLModels. Subclasses need to implement accept_model and aggregate_model methods.

Init FLComponent.

The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)

FLComponents have the capability to handle and fire events and contain various methods for logging.

accept(shareable: Shareable, fl_ctx: FLContext) bool[source]

called by ScatterAndGather

abstract accept_model(model: FLModel)[source]

needs to implement logic to accept a model, e.g. add to sum, count, etc.

aggregate(fl_ctx: FLContext) Shareable[source]

called by ScatterAndGather

abstract aggregate_model() FLModel[source]

needs to implement aggregation logic and reset any internal stats

error(message: str)[source]
exception(message: str)[source]
handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

info(message: str)[source]
reset(fl_ctx: FLContext)[source]

called by ScatterAndGather

abstract reset_stats()[source]

needs to implement logic to reset any internal stats

warning(message: str)[source]