Wojciech Michaluk
Stephan Klein
Goal of the project is to compare centralised and federated learning for image classification. We used Pytorch and Tensorflow.
CIFAR10 https://www.cs.toronto.edu/~kriz/cifar.html 10 classes, 6000 img/class
Usage of Tensorflow Federated Learning Library (https://www.tensorflow.org/federated) with a simple CNN architecture:
- Conv2D Layer: 20 filters of size 5x5, ReLU activation, input shape (32, 32, 3).
- MaxPooling2D Layer: Pooling size 2x2.
- Conv2D Layer: 50 filters of size 5x5, ReLU activation.
- MaxPooling2D Layer: Pooling size 2x2.
- Flatten Layer: Converts the 2D feature maps to 1D feature vectors.
- Dense Layer: 500 neurons, ReLU activation.
- Dense Layer: 10 neurons, Softmax activation for classification.
We tried alternative frameworks (pysyft) which can be found under alternative_architectures with their own README
- Comparing Federated Learning to Centralised Learning
- With different Optimizers
- With different Hyperparameters (Federated Batch Size and Nr of Federated Clients)
- Differential Privacy (https://www.tensorflow.org/federated/tutorials/federated_learning_with_differential_privacy)
- Model and Update Compression (https://www.tensorflow.org/federated/tutorials/tff_for_federated_learning_research_compression)
Requirements: Python 3.11
-
Prepare Virtual Environment
python3.11 -m venv .venv source .venv/bin/activate pip install -r requirements.txt -
Run the Notebooks
With your favourite IDE or jupyter.
-
Options
All Notebooks provide Hyperparameters in the second cell which can be changed to reproduce the experiments.
Settings for Additional Experiments are marked in commented out code with the comment "EXPERIMENT"
-
Reporting
All Notebooks provide logging to WANDB (https://wandb.ai/) which is turned off by default
If using vscode it might throw the error on executing a cell: The file '.venv/lib/python3.11/site-packages/typing_extensions.py' seems to be overriding built in modules and interfering with the startup of the kernel. Consider renaming the file and starting the kernel again. Click here for more info.
Instead of renaming,pip install -U typing-extensions also suffices
Tensorflow Federated has a Serialisation Limit of 100 MB by default.
If data to federated client is increased (e.g by reducing nr of workers below 10) the error ValueError: Serialized size of Dataset (537613688 bytes) exceeds maximum allowed might be thrown.
This can be fixed by changing the limit in file <pythonenv>/lib/python3.11/site-packages/tensorflow_federated/python/core/impl/executors/value_serialization.py