nvflare.app_common.abstract.model_learner module

class ModelLearner[source]

Bases: FLComponentWrapper

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.

STATE = None
configure(model: FLModel)[source]

Called by the framework to configure the Learner with the config info in the model

Parameters:

model – the object that contains config parameters

Returns: None

get_model(model_name: str) str | FLModel[source]

Called by the framework to return the trained model from the Learner.

Parameters:

model_name – type of the model for validation

Returns: trained model; or return code if failed

train(model: FLModel) str | FLModel[source]

Called by the framework to perform training. Can be called many times during the lifetime of the Learner.

Parameters:

model – the training input model

Returns: train result as a FLModel if successful; or return code as str if failed.

validate(model: FLModel) str | FLModel[source]

Called by the framework to validate the model with the specified weights in dxo

Parameters:

model – the FLModel object that contains model weights to be validated

Returns: validation metrics in FLModel if successful; or return code if failed.