Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update keras example #568

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading