The framework is designed to train a neural network task on various fog nodes. The fog nodes consist of resources constrained devices such as Raspberry Pi.
The standard federated learning paradigm with fedAvg implementation is done on continuously generating datasets.
Firstly, the server starts training by initializing the model and asking connected nodes to train the model on their local datasets. The server waits for participating clients to return the model, thereafter it aggregates the updates. The training continues till the global model converges or the expected model is created.
The project contains code for the client and server that need to be run on respective devices. The clients are resource-constrained devices such as Raspberry Pi, and a server can be computers/laptops.
All participating nodes should have docker installed so that appropriate images can be downloaded. Otherwise, the user has to create a docker image with the code given in the project.
To connect to the client, the server need to have access to ip address of the participating clients.
Additionally, every client should have data in the data folder that will be used for training.
- Run requirement.txt
- Edit/create appropriate channels for available clients with respective ip addresses in server.py
- Define neural network in the createInitialModel() function.
- Run server.py
- Check/change docker image in docker-compose.yaml file
- Run docker-compose.yaml
The compose will download and execute images on the fog device.
In case of a given image is not working, then the image can be created with docker-compose.yaml file.
Edit compose file on the image tag with build code. Then run docker-compose.yaml.
build:
context: .
dockerfile: Dockerfile
The program is still menu driven. To start the execution, you need to hit start from the server end. In the current form, press 7, which will execute n(60) rounds of federated learning.
The server will have evaluation results(accuracy, loss) and latest global model in Models folder.
Similarly, every client will have locally trained results and latest model in the data folder.