This example has been moved here: https://github.com/scaleoutsystems/examples/tree/main/Casa-IoT-keras
This classsic example of Human Daily Activity Recognition (HDAR) is well suited both as a lightweight test when learning FEDn and developing on FEDn in psedo-distributed mode. A normal high-end laptop or a workstation should be able to sustain at least 15 clients. The example is also useful for general scalability tests in fully distributed mode.
For large data transfer reason we uploaded a data folder in this use case to archive.org. To test this use-case you need to download prepared data that composed 27 apartments (casa's), each apartment data are distributed over 11 clients, using this link: https://archive.org/download/data_20210225/data.zip
- Unzip the file
- Copy the content of the unzipped Archive to the data folder under casa directory
We have made it possible to configure a couple of settings to vary the conditions for the training. These configurations are expsosed in the file 'client/settings.yaml':
# Parameters for local training
test_size: 0.25
batch_size: 32
epochs: 3
To train a model in FEDn you provide the client code (in 'client') as a tarball (you set the name of the package in 'settings-reducer.yaml'). For convenience, we ship a pre-made package. Whenever you make updates to the client code (such as altering any of the settings in the above mentioned file), you need to re-package the code (as a .tar.gz archive) and copy the updated package to 'packages'. From 'test/casa':
tar -zcvf casa.tar.gz client
cp casa.tar.gz packages/
The baseline LSTM is specified in the file 'client/init_model.py'. This script creates an untrained neural network and serialized that to a file, which is uploaded as the seed model for federated training. For convenience we ship a pregenerated seed model in the 'seed/' directory. If you wish to alter the base model, edit 'client/models/casa_model.py' and regenerate the seed file:
We provide the 'generate_clients.sh' bash file to generate all the configuration yaml files (docker_compose.clients.yaml, fedn-network.yal, extra-hosts.yaml) to run casa benckmark in the easiest way.
bash generate_clients.sh
The easiest way to start clients for quick testing is to use shell script.The following shell script will configure and start a client on a blank Ubuntu 20.04 LTS VM:
#!/bin/bash
# Install Docker and docker-compose
sudo apt-get update
sudo snap install docker
# clone the nlp_imdb example
git clone https://github.com/scaleoutsystems/FEDn-client-casa-keras.git
cd FEDn-client-casa-keras
# if no available data, download it from archive
# wget https://archive.org/download/data_20210225/data.zip
# sudo apt install unzip
# unzip -o data.zip
# sudo rm data.zip
# Make sure you have edited extra-hosts.yaml to provide hostname mappings for combiners
# Make sure you have edited fedn-network.yaml to provide hostname mappings for reducer
sudo docker-compose -f docker-compose.clients.yaml -f extra-hosts.yaml up --build
Apache-2.0 (see LICENSE file for full information).