p2pfl.learning.frameworks.learner moduleΒΆ

NodeLearning Interface - Template Pattern.

class p2pfl.learning.frameworks.learner.Learner(model=None, data=None, aggregator=None)[source]ΒΆ

Bases: ABC, NodeComponent

Template to implement learning processes, including metric monitoring during training.

Parameters:
  • model (P2PFLModel | None) – The model of the learner.

  • data (P2PFLDataset | None) – The data of the learner.

  • self_addr – The address of the learner.

  • aggregator (Aggregator | None)

add_callback_info_to_model()[source]ΒΆ

Add the additional information from the callbacks to the model.

Return type:

None

abstract evaluate()[source]ΒΆ

Evaluate the model with actual parameters.

Return type:

dict[str, float]

Returns:

The evaluation results.

abstract fit()[source]ΒΆ

Fit the model.

Return type:

P2PFLModel

get_data()[source]ΒΆ

Get the data of the learner.

Return type:

P2PFLDataset

Returns:

The data of the learner.

abstract get_framework()[source]ΒΆ

Retrieve the learner name.

Return type:

str

Returns:

The name of the learner class.

get_model()[source]ΒΆ

Get the model of the learner.

Return type:

P2PFLModel

Returns:

The model of the learner.

indicate_aggregator(aggregator)[source]ΒΆ

Indicate to the learner the aggregators that are being used in order to instantiate the callbacks.

Parameters:

aggregator (Aggregator) – The aggregator used in the learning process.

Return type:

None

abstract interrupt_fit()[source]ΒΆ

Interrupt the fit process.

Return type:

None

set_data(data)[source]ΒΆ

Set the data of the learner. It is used to fit the model.

Parameters:

data (P2PFLDataset) – The data of the learner.

Return type:

None

set_epochs(epochs)[source]ΒΆ

Set the number of epochs of the model.

Parameters:

epochs (int) – The number of epochs of the model.

Return type:

None

set_model(model)[source]ΒΆ

Set the model of the learner.

Parameters:

model (P2PFLModel | list[ndarray] | bytes) – The model of the learner.

Return type:

None

update_callbacks_with_model_info()[source]ΒΆ

Update the callbacks with the model additional information.

Return type:

None