The package ptbfla comprises the following two FL frameworks:
- Python TestBed for Federated Learning Algorithms (PTB-FLA) on a localhost.
- MicroPython testbed for Federated Learning Algorithms (MPT-FLA) on a (W)LAN of PCs and IoTs like RPi Pico W boards.
Project team: Miroslav Popovic, Marko Popovic, Ivan Kastelan, Miodrag Djukic.
Project description:
- For the introduction to PTB-FLA, including the examples 1, 2, and 3, see ZINC 2023 paper.
- For the development paradigm, including the examples 4 and 5, see ECBS 2023 paper 1.
- For the formal verification of PTB-FLA generic algorithms, see ECBS 2023 paper 2.
- For the introduction to MPT-FLA, and the "mpasync" examples, see the paper and the video.
Directories (under the directory src):
- ptbfla_pkg: PTB-FLA (ptbfla.py, mpapi.py), MPT-FLA (mp_async_ptbfla.py, mp_async_mpapi.py), launcher.py (shared by both).
- examples: both PTB-FLA examples (without the prefix "mpasync") and MPT-FLA (with the prefix).
- examplesrp2_board: the modules config.py and main.py to install on RPi Pico W boards to run "mp_async" examples.
Notes on launching the examples:
- Remember to change the working directory to "src/examples".
- You must replace the IP addresses in the launch commands for the "mpasync" examples with your IP address!
- When running PTB-FLA apps on Windows with many instances e.g., ODTS for 170 satellites (launch example6_odts.py 170 id 1 25), Windows may start protecting itself by throwing the exception "WinError 10061" to some of the processes, this is as expected, PTB-FLA should be able to cope with this and make the recovery, you should not do anything but be patient and wait.
Warning: this project is work in progress.
- Clone the ptbfla project into the directory src
- Create the venv:
py -m venv venv_ptbfla
- Activate the
venv_ptbfla
:venv_ptbfla\Scripts\activate
- PIP-install the package
ptbfla_pkg
("-e" means editable install):py -m pip install -e src
- Run example 1:
launch src\examples\example1_fedd_mean.py 3 id 0
Notes:
- If for some reason you want to uninstall the pacakage, type:
pip uninstall venv_ptbfla
- To deactivate the
venv_ptbfla
on Windows type:venv_ptbfla\Scripts\deactivate.bat
- Clone the ptbfla project into the directory src
- Create the venv:
python3 -m venv venv_ptbfla
- Source the
venv_ptbfla
:source venv_ptbfla/bin/activate
- PIP-install the package
ptbfla_pkg
("-e" means editable install):python3 -m pip install -e src
- Run example 1:
launch src/examples/example1_fedd_mean.py 3 id 0
Note: To deactivate the venv_ptbfla
on Ubuntu type: deactivate
- If not already acive, activate the
venv_ptbfla
:venv_ptbfla\Scripts\activate
- Upgrade PIP:
py -m pip install --upgrade pip
- PIP-install the package numpy:
py -m pip install numpy
- PIP-install the package pandas:
py -m pip install pandas
- PIP-install the package matplotlib:
py -m pip install matplotlib
- PIP-install the package scikit-learn:
py -m pip install -U scikit-learn
- Chage directory to examples:
cd src\examples
- Run example 4:
launch example4_logistic_regression.py 3 id 2
- Run example 5:
launch example5_dec_log_regression.py 2 id
- If not already sourced, source the
venv_ptbfla
:source venv_ptbfla/bin/activate
- Upgrade PIP:
python3 -m pip install --upgrade pip
- PIP-install the package numpy:
python3 -m pip install numpy
- PIP-install the package pandas:
python3 -m pip install pandas
- PIP-install the package matplotlib:
python3 -m pip install matplotlib
- PIP-install the package scikit-learn:
python3 -m pip install -U scikit-learn
- Chage directory to examples:
cd src/examples
- Run example 4:
launch example4_logistic_regression.py 3 id 2
- Run example 5:
launch example5_dec_log_regression.py 2 id
If you wish to make MPT-FLA application testing on multiple PCs easier, see the Distributed Launcher for MPT-FLA repository
If you wish to use PTB-FLA accross multiple devices, see the PTB-FLA plug in adapter for Babel repository