nvflare.app_common.app_defined.shareable_generator module¶
- class AppDefinedShareableGenerator[source]¶
Bases:
ShareableGenerator
,ComponentBase
,ABC
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.
- learnable_to_shareable(learnable: Learnable, fl_ctx: FLContext) → Shareable[source]¶
Generate the initial Shareable from the Learnable object.
- Parameters:
model – model object
fl_ctx – FLContext
- Returns:
shareable
- abstract model_to_trainable(model_obj: ~typing.Any) -> (typing.Any, <class 'dict'>)[source]¶
Convert the model weights and meta to a format that can be sent to clients to do training
- Parameters:
model_obj – model object
Returns: a tuple of (weights, meta)
The returned weights and meta will be for training and serializable
- shareable_to_learnable(shareable: Shareable, fl_ctx: FLContext) → Learnable[source]¶
Construct the Learnable object from Shareable.
- Parameters:
shareable – shareable
fl_ctx – FLContext
- Returns:
model object
- abstract update_model(model_obj: Any, training_result: Any, meta: dict) → Any[source]¶
Update model with training result and meta
- Parameters:
model_obj – base model object to be updated
training_result – training result to be applied to the model object
meta – trained meta
Returns: the updated model object