fedn.utils.helpers.plugins package
Submodules
fedn.utils.helpers.plugins.androidhelper module
- class fedn.utils.helpers.plugins.androidhelper.Helper[source]
Bases:
HelperBaseFEDn helper class for android json model weights.
- get_tmp_path()[source]
Return a temporary output path compatible with save_model, load_model.
- Returns:
Path to file.
- increment_average(model, model_next, num_examples, total_examples)[source]
Incremental weighted average of model weights.
- Parameters:
- Returns:
Incremental weighted average of model weights.
- Return type:
list of numpy arrays.
- increment_average_add(model, model_next, num_examples, total_examples)[source]
Incremental weighted average of model weights.
- Parameters:
- Returns:
Incremental weighted average of model weights.
- Return type:
list of numpy arrays.
fedn.utils.helpers.plugins.binaryhelper module
- class fedn.utils.helpers.plugins.binaryhelper.Helper[source]
Bases:
HelperFEDn helper class for models weights/parameters that can be transformed to numpy ndarrays.
- load(path, file_type='raw_binary')[source]
Load weights from file or filelike.
- Parameters:
path – file path, filehandle, filelike.
- Returns:
List of weights in numpy format.
- save(model, path=None, file_type='raw_binary')[source]
Serialize weights to file. The serialized model must be a single binary object.
- Parameters:
weights – List of weights in numpy format.
path – Path to file.
file_type – File type to save to. Can be ‘npz’ or ‘raw_binary’. Default is ‘npz’.
- Returns:
Path to file.
fedn.utils.helpers.plugins.numpyhelper module
- class fedn.utils.helpers.plugins.numpyhelper.Helper[source]
Bases:
HelperBaseFEDn helper class for models weights/parameters that can be transformed to numpy ndarrays.
- get_tmp_path(suffix='.npz')[source]
Return a temporary output path compatible with save_model, load_model.
- Parameters:
suffix – File suffix.
- Returns:
Path to file.
- load(path, file_type='npz')[source]
Load weights from file or filelike.
- Parameters:
path – file path, filehandle, filelike.
- Returns:
List of weights in numpy format.
- save(weights, path=None, file_type='npz')[source]
Serialize weights to file. The serialized model must be a single binary object.
- Parameters:
weights – List of weights in numpy format.
path – Path to file.
file_type – File type to save to. Can be ‘npz’ or ‘raw_binary’. Default is ‘npz’.
- Returns:
Path to file.
fedn.utils.helpers.plugins.splitlearninghelper module
- class fedn.utils.helpers.plugins.splitlearninghelper.Helper[source]
Bases:
HelperBaseFEDn helper class for models weights/parameters that can be transformed to numpy ndarrays.
- get_tmp_path(suffix='.npz')[source]
Return a temporary output path compatible with save_model, load_model.
- Parameters:
suffix – File suffix.
- Returns:
Path to file.
- increment_average(embedding1, embedding2)[source]
Concatenates two embeddings of format {client_id: embedding} into a new dictionary
- Parameters:
embedding1 – First embedding dictionary
embedding2 – Second embedding dictionary
- Returns:
Concatenated embedding dictionary