Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bl0nder/simfed
A federated learning simulation coded from scratch in PyTorch
https://github.com/bl0nder/simfed
federated-learning from-scratch machine-learning python pytorch
Last synced: 17 days ago
JSON representation
A federated learning simulation coded from scratch in PyTorch
- Host: GitHub
- URL: https://github.com/bl0nder/simfed
- Owner: bl0nder
- Created: 2024-12-11T08:03:10.000Z (28 days ago)
- Default Branch: main
- Last Pushed: 2024-12-11T08:20:58.000Z (28 days ago)
- Last Synced: 2024-12-21T18:14:51.737Z (17 days ago)
- Topics: federated-learning, from-scratch, machine-learning, python, pytorch
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimFed 👾
A simple from-scratch implementation of a framework that simulates a federated learning environment to train ML models. It simulates client objects using disjoint data shards and has a server object controlling the training of the global model. Currently, the data shards are created from the MNIST dataset although I do want to add the option to use other, more diverse, datasets as well in the future.### Instructions to Run Code
Make sure the file structure looks like this:```
SimFed
├── Dataset
│ ├── MNIST
│ | ├── raw
├── logs
│ ├── *.log
├── plots
│ ├── *.png
├── client.py
├── config.py
├── model.py
├── nonFL.py
├── project.py
├── README.md
├── requirements.txt
└── server.py
```Install dependencies in requirements.txt using
```
pip install -r requirements.txt
```Run code using:
```
python project.py
```All hyperparameters are in config.py if you want to change them and experiment.
For each run of the program, a log will be created in ./logs. The naming convention for the logs is `runlog_[hour]_[minute]_[day]_[month]_[year].log`. The corresponding plots can be found in a similar way.Note that the code will train the models for two different numbers of clients (2 and 5) so that it can create some plots for comparison. In case you do not want that, change line 100 in `project.py` to
```
num_clients = [cfg.num_clients]
```
and re-run. In this case, however, it will only create empty plots (since no hyperparameter is changing) but you can check the results from the logs.