p2pfl.node_state moduleΒΆ

Node state.

class p2pfl.node_state.NodeState(addr)[source]ΒΆ

Bases: object

Class to store the main state of a learning node.

addrΒΆ

The address of the node.

statusΒΆ

The status of the node.

learnerΒΆ

The learner of the node.

models_aggregatedΒΆ

The models aggregated by the node.

nei_statusΒΆ

The status of the neighbors.

train_setΒΆ

The train set of the node.

train_set_votesΒΆ

The votes of the train set.

train_set_votes_lockΒΆ

The lock for the train set votes.

start_thread_lockΒΆ

The lock for the start thread.

wait_votes_ready_lockΒΆ

The lock for the wait votes ready.

model_initialized_lockΒΆ

The lock for the model initialized.

Parameters:

addr (str) – The address of the node.

clear()[source]ΒΆ

Clear the state.

Return type:

None

property exp_name: str | NoneΒΆ

Get the actual experiment name.

increase_round()[source]ΒΆ

Increase the round number.

Raises:

ValueError – If the experiment is not initialized.

Return type:

None

property round: int | NoneΒΆ

Get the round.

set_experiment(exp_name, total_rounds, dataset_name=None, model_name=None, aggregator_name=None, framework_name=None, learning_rate=None, batch_size=None, epochs_per_round=None)[source]ΒΆ

Start a new experiment.

Parameters:
  • exp_name (str) – The name of the experiment.

  • total_rounds (int) – The total rounds of the experiment.

  • dataset_name (str | None) – The name of the dataset.

  • model_name (str | None) – The name of the model.

  • aggregator_name (str | None) – The name of the aggregator.

  • framework_name (str | None) – The name of the framework.

  • learning_rate (float | None) – The learning rate.

  • batch_size (int | None) – The batch size.

  • epochs_per_round (int | None) – The number of epochs per round.

Return type:

None

property total_rounds: int | NoneΒΆ

Get the total rounds.