nvflare.app_common.filters.convert_weights module

class ConvertWeights(direction: str)[source]

Bases: DXOFilter

Convert WEIGHTS to WEIGHT_DIFF or vice versa.


direction (str) – control conversion direction. Either weights_to_diff or diff_to_weights.


ValueError – when the direction string is neither weights_to_diff nor diff_to_weights

DIFF_TO_WEIGHTS = 'diff_to_weights'
WEIGHTS_TO_DIFF = 'weights_to_diff'
process_dxo(dxo: DXO, shareable: Shareable, fl_ctx: FLContext) None | DXO[source]

Called by runners to perform weight conversion.

  • dxo (DXO) – dxo to be processed.

  • shareable – the shareable that the dxo belongs to

  • fl_ctx (FLContext) – this context must include TASK_DATA, which is another shareable containing base weights. If not, the input shareable will be returned.

Returns: filtered result