Project of Blockchain and cryptocurrencies, in this work it has been expanded the original project to the following link:https://github.com/AnaNSi-research/FederatedLearningBlockchain.
Additional features implemented:
- Implemented Federated Proximal [1]
- Insert the simulation of out of battery device (devices which do not send weights)
- Simulation of more devices (greater than 3)
- Adding a new dataset
- Make and analysis different experiments on both dataset
This setup is just for a simulation
- Ganache
- IPFS
- Miniconda
- eth-brownie
- cuda
- tensorflow
- opencv-python
- pandas
- scikit-learn
conda deactivate
conda create --name blockchain_project python=3.9
conda activate blockchain_project
python -m install pip --upgrade pip
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install "tensorflow<2.11"
pip install opencv-python
pip install pandas==1.5.3
pip install eth-brownie
pip install scikit-learn
https://trufflesuite.com/ganache/
https://github.com/ipfs/ipfs-desktop/releases
brownie networks add Ethereum fl-local host=http://127.0.0.1:7545 chainid=5777 timeout=3600
brownie networks list
This is just a simulation. For concurruncy problems on training on the same GPU, the collaborator.py script contains a loop that trains the different hospital model instances one at time in sequence. In a real time scenario, with more than one peer, it is possible to run the different learnings at the same time and it works in the same way.
It is possible to choose the dataset, inserting the parameter, "brain_tumor" it will be used the brain tumor dataset, if the dataset is not sepcify it will be used the Alzheimer dataset
For Brain Tumor:
brownie run .\scripts\setup.py main brain_tumor --network fl-local
For Alzheimer
brownie run .\scripts\setup.py main --network fl-local
brownie run .\scripts\setup.py --network fl-local
The number of devices is choosen by the constants
brownie run .\scripts\collaborator.py --network fl-local
It is possible to insert the parameter "out" to randomly select the option "devices out of battery". The number of devices out of battery can be selected by the constants, instead the device out of battery and the round which they do not send the weights is randomly select.
brownie run .\scripts\collaborator.py out --network fl-local
Notes: In this configuration you need to wait 3600 s to validate if a device send the weights or not, it possible to change the time to wait, changing the constants TIMEOUT_SECONDS and TIMEOUT_DEVICES for simulation purpose.
brownie run .\scripts\manager.py --network fl-local
It is possible to use the parameter FedProx to specify the using of Federated Prox technique.
brownie run .\scripts\manager.py FedProx --network fl-local
In the repo, the notebook experiments_analysis contains all the analysis/plot of the different simulations.
- Lorenzo Cassano
- Jacopo D'Abramo
[1]: Li, Tian, et al. "Federated optimization in heterogeneous networks." Proceedings of Machine learning and systems 2 (2020): 429-450.