Implementation of federated learning on Android devices.
fl-android |-- preprocess: Data preprocess, written in matlab |-- client: Android client to perform on-device learning, written in android, built by Gradle |-- server: server to aggregate weights updated by clients, written in java, built by Gradle |-- README.md: readme
We are going to implement the federated learning in realistic manner so that we can measure energy consumptions on real mobile devices. In particular, the training process happens at the end devices (i.e., clients), such as mobile phones, tablets with their local stored or generated data. Then the updated weights of machine learning model are uploaded to a central server, who performs weights aggregation periodically, for example, averages the weights according to FedAvg algorithm. The updated model is then pushed to end users. The procedure goes on with higher model accuracy for end users and preserving their privacy.
- Gradle
- JDK
- Intellij IDEA (for sever project)
- Android Studio (for client project)
- Dropbox (for both server and clients)
Firstly, clone the repo as follows:
git clone https://github.com/zouyu4524/fl-android.git
Make sure Dropbox is installed and logged in on the server.
Using Intellij IDEA to import the sever-side project.
import project
→ Locate build.gradle
under server/
→ Click Ok → Leave all the settings default and click OK.
In Intellij IDEA, build the project first then you can run HARClassifierNNAverageWeights
as one instance of model averaging.
Before you run HARClassifierNNAverageWeights
, you should check three final String
given at the top of Class, i.e., updatedModel
, originModel
and onDeviceModelPath
:
updatedModel
: location of the updated model is storedoriginModel
: location of the original model is storedonDeviceModelPath
: path where on-device trained models stored, which should beDropsyncFiles
underDropbox
in realistic deployment
PS: updatedModel
and originModel
should be the same one in realistic deployment and under Dropbox/DropsyncFiles/
On any participated android device, install Dropbox and DropSync apps first.
By default, there should be a synchronizing folder created after DropSync installed, named as DropsyncFiles
.
Using Android Studio to import the client-side project.