From 4d691366b110634781d7dbcb66a2a23517160e58 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Tue, 2 Apr 2024 16:57:31 +0200 Subject: [PATCH] minort tweaks to make `client.py` compatible w/ Flower and Flower Next; updates to README --- examples/quickstart-tensorflow/README.md | 24 +++++------------------- examples/quickstart-tensorflow/client.py | 6 +++--- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/examples/quickstart-tensorflow/README.md b/examples/quickstart-tensorflow/README.md index 17405f1588bc..8b5899de1645 100644 --- a/examples/quickstart-tensorflow/README.md +++ b/examples/quickstart-tensorflow/README.md @@ -55,21 +55,19 @@ ______________________________________________________________________ Afterward, you are ready to start the Flower server as well as the clients. You can simply start the server in a terminal as follows: ```shell -poetry run python3 server.py +python3 server.py ``` Now you are ready to start the Flower clients which will participate in the learning. To do so simply open two more terminals and run the following command in each: ```shell -poetry run python3 client.py +python3 client.py --partition-id 0 ``` -Alternatively, you can run all of it in one shell as follows: +Start client 2 in the second terminal: ```shell -poetry run python3 server.py & -poetry run python3 client.py & -poetry run python3 client.py +python3 client.py --partition-id 1 ``` You will see that Keras is starting a federated training. Have a look at the [code](https://github.com/adap/flower/tree/main/examples/quickstart-tensorflow) for a detailed explanation. You can add `steps_per_epoch=3` to `model.fit()` if you just want to evaluate that everything works without having to wait for the client-side training to finish (this will save you a lot of time during development). @@ -86,7 +84,7 @@ flower-superlink --insecure ### 2. Start the long-running Flower clients (SuperNodes) -Start 2 long-running Flower clients in 2 separate terminal windows, using: +Start 2 Flower \`SuperNodes in 2 separate terminal windows, using: ```bash flower-client-app client:app --insecure @@ -99,15 +97,3 @@ With both the long-running server (SuperLink) and two clients (SuperNode) up and ```bash flower-server-app server:app --insecure ``` - -Or, to try the workflow example, run: - -```bash -flower-server-app server_workflow:app --insecure -``` - -Or, to try the custom server function example, run: - -```bash -flower-server-app server_custom:app --insecure -``` diff --git a/examples/quickstart-tensorflow/client.py b/examples/quickstart-tensorflow/client.py index 87fc154bd5e3..6ef11898f0b0 100644 --- a/examples/quickstart-tensorflow/client.py +++ b/examples/quickstart-tensorflow/client.py @@ -14,11 +14,11 @@ "--partition-id", type=int, choices=[0, 1, 2], - required=True, + default=0, help="Partition of the dataset (0,1 or 2). " "The dataset is divided into 3 partitions created artificially.", ) -args = parser.parse_args() +args, _ = parser.parse_known_args() # Load model and data (MobileNetV2, CIFAR-10) model = tf.keras.applications.MobileNetV2((32, 32, 3), classes=10, weights=None) @@ -36,7 +36,7 @@ # Define Flower client -class CifarClient(NumPyClient): +class FlowerClient(NumPyClient): def get_parameters(self, config): return model.get_weights()