-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding readme and refactoring client code
- Loading branch information
1 parent
a976201
commit d31cb6a
Showing
5 changed files
with
85 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
FEDn Project: MNIST (PyTorch) | ||
----------------------------- | ||
|
||
This is an example FEDn Project that runs the federated self-supervised learning algorithm FedSimSiam on | ||
the CIFAR-10 dataset. This is a standard example often used for benchmarking. To be able to run this example, you | ||
need to have GPU access. | ||
|
||
**Note: We recommend all new users to start by following the Quickstart Tutorial: https://fedn.readthedocs.io/en/stable/quickstart.html** | ||
|
||
Prerequisites | ||
------------- | ||
|
||
- `Python 3.8, 3.9, 3.10 or 3.11 <https://www.python.org/downloads>`__ | ||
- `A FEDn Studio account <https://fedn.scaleoutsystems.com/signup>`__ | ||
- Change the dependencies in the 'client/python_env.yaml' file to match your cuda version. | ||
|
||
Creating the compute package and seed model | ||
------------------------------------------- | ||
|
||
Install fedn: | ||
|
||
.. code-block:: | ||
pip install fedn | ||
Clone this repository, then locate into this directory: | ||
|
||
.. code-block:: | ||
git clone https://github.com/scaleoutsystems/fedn.git | ||
cd fedn/examples/mnist-pytorch | ||
Create the compute package: | ||
|
||
.. code-block:: | ||
fedn package create --path client | ||
This should create a file 'package.tgz' in the project folder. | ||
|
||
Next, generate a seed model (the first model in a global model trail): | ||
|
||
.. code-block:: | ||
fedn run build --path client | ||
This will create a seed model called 'seed.npz' in the root of the project. This step will take a few minutes, depending on hardware and internet connection (builds a virtualenv). | ||
|
||
FEDn Studio | ||
----------- | ||
|
||
Follow the instructions to register for FEDN Studio and start a project (https://fedn.readthedocs.io/en/stable/studio.html). | ||
|
||
In your Studio project: | ||
|
||
- Go to the 'Sessions' menu, click on 'New session', and upload the compute package (package.tgz) and seed model (seed.npz). | ||
- In the 'Clients' menu, click on 'Connect client' and download the client configuration file (client.yaml) | ||
- Save the client configuration file to the FedSimSiam example directory (fedn/examples/FedSimSiam) | ||
|
||
To connect a client, run the following command in your terminal: | ||
|
||
.. code-block:: | ||
fedn client start -in client.yaml --secure=True --force-ssl | ||
Running the example | ||
------------------- | ||
|
||
After everything is set up, go to 'Sessions' and click on 'New Session'. Click on 'Start run' and the example will execute. You can follow the training progress on 'Events' and 'Models', where you | ||
can monitor the training progress. The monitoring is done using a kNN classifier that is fitted on the feature embeddings of the training images that are obtained by | ||
FedSimSiam's encoder, and evaluated on the feature embeddings of the test images. This process is repeated after each training round. | ||
|
||
This is a common method to track FedSimSiam's training progress, as FedSimSiam aims to minimize the distance between the embeddings of similar images. | ||
A high accuracy implies that the feature embeddings for images within the same class are indeed close to each other in the | ||
embedding space, i.e., FedSimSiam learned useful feature embeddings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters