p2pfl.learning.frameworks.tensorflow.keras_model moduleΒΆ

Keras model abstraction for P2PFL.

class p2pfl.learning.frameworks.tensorflow.keras_model.KerasModel(model, params=None, num_samples=None, contributors=None, additional_info=None)[source]ΒΆ

Bases: P2PFLModel

P2PFL model abstraction for TensorFlow/Keras.

Parameters:
  • model (Model) – The Keras model to encapsulate.

  • params (Union[List[ndarray], bytes, None]) – Optional initial parameters (list of NumPy arrays or bytes).

  • num_samples (Optional[int]) – Optional number of samples used for training.

  • contributors (Optional[List[str]]) – Optional list of contributor nodes.

  • additional_info (Optional[Dict[str, Any]]) – Optional dictionary for extra information.

get_framework()[source]ΒΆ

Retrieve the model framework name.

Return type:

str

Returns:

The name of the model framework.

get_parameters()[source]ΒΆ

Get the parameters of the model.

Return type:

List[ndarray]

Returns:

The parameters of the model

set_parameters(params)[source]ΒΆ

Set the parameters of the model.

Parameters:

params (Union[List[ndarray], bytes]) – The parameters of the model.

Raises:

ModelNotMatchingError – If parameters don’t match the model.

Return type:

None

class p2pfl.learning.frameworks.tensorflow.keras_model.MLP(*args, **kwargs)[source]ΒΆ

Bases: Model

Multilayer Perceptron (MLP) for MNIST classification using Keras.

call(inputs)[source]ΒΆ

Forward pass of the MLP.

get_framework()[source]ΒΆ

Retrieve the model name.

Return type:

str

Returns:

The name of the model class.

exception p2pfl.learning.frameworks.tensorflow.keras_model.ModelNotBuiltError[source]ΒΆ

Bases: Exception

Raised when a model is not built.