Skip to content

Commit

Permalink
Update keras example
Browse files Browse the repository at this point in the history
  • Loading branch information
ahellander authored Apr 8, 2024
1 parent 1f72449 commit 70f0943
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions examples/mnist-keras/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# MNIST (TensorFlow/Keras version)

This is a mimimalistic TF/Keras version of the Quickstart Tutorial (PyTorch). For more detailed explaination including a Jupyter Notebook with
This is a TF/Keras version of the [Quickstart Tutorial (PyTorch)](https://fedn.readthedocs.io/en/stable/quickstart.html). For more detailed explaination including a Jupyter Notebook with
examples of API usage for starting and interacting with federated experiments, refer to that tutorial.

## Prerequisites
- [Python 3.8, 3.9 or 3.10](https://www.python.org/downloads)
- [Python >=3.8, <=3.11](https://www.python.org/downloads)
- [Docker](https://docs.docker.com/get-docker)
- [Docker Compose](https://docs.docker.com/compose/install)

## Running the example (pseudo-distributed)
## Running the example

Clone FEDn and locate into this directory.
```sh
git clone https://github.com/scaleoutsystems/fedn.git
Expand All @@ -17,12 +18,38 @@ cd fedn/examples/mnist-keras

### Preparing the environment, the local data, the compute package and seed model

Start by initializing a virtual enviroment with all of the required dependencies.
Build a virtual environment (note that you might need to install the 'venv' package):

#### Ubuntu

```sh
bin/init_venv.sh
```

Then, to get the data you can run the following script.
#### MacOS with M1 or M2 processors
you need another Tensorflow package, as specified in 'requirements-macos.txt'

```sh
bin/init_venv_macm1.sh
```

Activate the virtual environment:

```sh
source .mnist-keras/bin/activate
```

Make the compute package (to be uploaded to FEDn):
```sh
tar -czvf package.tgz client
```

Create the seed model (to be uploaded to FEDn):
```sh
python client/entrypoint init_seed
```

Then, to get the data we will use for the clients (MNIST), you can run the following script.
```sh
bin/get_data
```
Expand All @@ -33,11 +60,20 @@ bin/split_data
```
> **Note**: run with `--n_splits=N` to split in *N* parts.
Create the compute package and a seed model that you will be asked to upload in the next step.
```
bin/build.sh
```
> The files location will be `package/package.tgz` and `seed.npz`.

Next, you will upload the compute package and seed model to a FEDn network. Here you have two main options:
using FEDn Studio (recommended for new users), or a pseudo-local deployment on your own machine.

### If you are using FEDn Studio (recommended):

Follow instructions here to register for Studio and start a project: https://fedn.readthedocs.io/en/stable/studio.html.

In your Studio project:

- From the "Sessions" menu, upload the compute package and seed model.
- Register a client and obtain the corresponding 'client.yaml'.



### Deploy FEDn
Now we are ready to deploy FEDn and two clients with `docker-compose`.
Expand Down

0 comments on commit 70f0943

Please sign in to comment.