Skip to content

MNIST example client of the federated learning platform

Notifications You must be signed in to change notification settings

DLR-KI/fl-demonstrator-mnist

Repository files navigation

Federated Learning Demonstrator MNIST Example

DOI

This repository contains an example client of a Federated Learning platform. The example shows how to create a client which trains a model based on the popular MNIST dataset. This repository also include many scripts to show how to interact with the Federated Learning platform directly.

The code of this MNIST example is based on the example from PyTorch.

This project is a component of the Federated Learning (FL) platform, serving as a proof of concept for the Catena-X project. The FL platform aims to demonstrate the potential of federated learning in a practical, real-world context.

For a comprehensive understanding of the FL platform, please refer to the official FL platform documentation.

A complete list of all repositories relevant to the FL platform can be found here.

Get Started

The code of this repository is part of the MNIST example client tutorial for the Federated Learning platform. The MNIST client implementation is based on the provided Federated Learning platform client base package.

This README.md is primarily intended for developers and contributors, providing necessary information for setup, installation, and contribution guidelines. If you're interested in using or testing this project, we recommend starting with the GitHub pages. They offer a more user-friendly interface and comprehensive guides to get you started.

Requirements

  • python 3.10 or later
    which python
  • virtualenv or venv
    pip install -U virtualenv
  • jq command for JSON parsing inside bash
    sudo apt-get install jq

Install

# create virtual environment
virtualenv -p $(which python3.10) .venv
# or
# python -m venv .venv

# activate our virtual environment
source .venv/bin/activate

# update pip (optional)
python -m pip install -U pip

# install
./dev install -U -e ".[all]"

Helpers

$ ./dev --help
usage: ./dev <action> [options]

positional arguments:
  {clean,coverage,coverage-report,doc,doc-build,docker-build,help,install,licenses,licenses-check,lint,lint-code,lint-doc,lint-scripts,mypy,safety-check,start,test,version,versions}
                        Available sub commands
    help                Show this help message and exit
    start               Run the application
    docker-build        Build docker images for local development
    test                Run all tests
    lint                Run all linter
    lint-code           Run code linter
    lint-doc            Run documentation linter
    lint-scripts        Run bash script linter
    mypy                Run type checker
    coverage            Run unit tests
    coverage-report     Generate test coverage report
    doc                 Start documentation server
    doc-build           Build documentation
    licenses            Generate licenses
    licenses-check      Check licenses
    safety-check        Check dependencies for known security vulnerabilities
    install             Install package
    clean               Clean up local files
    version             Show package version
    versions            Show versions

options:
  --no-http-serve       Do not serve the action result via HTTP

Contribution

  • Type-Save and linting with mypy+flake8
  • Scripts and examples for linux, wsl (bash)

Documentation

This projects is using the Docstring style from Google. At least public classes, methods, fields, ... should be documented.

"""
This is the single line short description.

This is the multiline or long description.
Note, that the whole Docstring support markdown styling.

The long description can also contains multiple paragraphs.

Args:
    log_filepath (str): Log file path.
    ensure_log_dir (bool, optional): Create directory for the log file if not exists. Defaults to True.

Returns:
    Dict[str, Any]: logging configuration dict
"""

Credits

DLR DLR
Catena-X Catena-X
European Union European Union BMWK