Skip to content

Commit

Permalink
minort tweaks to make client.py compatible w/ Flower and Flower Nex…
Browse files Browse the repository at this point in the history
…t; updates to README
  • Loading branch information
jafermarq committed Apr 2, 2024
1 parent 8aad445 commit 4d69136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
24 changes: 5 additions & 19 deletions examples/quickstart-tensorflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand All @@ -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
```
6 changes: 3 additions & 3 deletions examples/quickstart-tensorflow/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,7 +36,7 @@


# Define Flower client
class CifarClient(NumPyClient):
class FlowerClient(NumPyClient):
def get_parameters(self, config):
return model.get_weights()

Expand Down

0 comments on commit 4d69136

Please sign in to comment.