From d40a6544b2418b4a806a032a70dc96f9906b1663 Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Sat, 14 Jan 2023 02:54:47 +0100 Subject: [PATCH] Fix mxnet quickstart example (#1574) --- examples/quickstart_mxnet/.gitignore | 1 + examples/quickstart_mxnet/client.py | 4 ++-- examples/quickstart_mxnet/pyproject.toml | 1 + examples/quickstart_mxnet/server.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 examples/quickstart_mxnet/.gitignore diff --git a/examples/quickstart_mxnet/.gitignore b/examples/quickstart_mxnet/.gitignore new file mode 100644 index 000000000000..10d00b5797e2 --- /dev/null +++ b/examples/quickstart_mxnet/.gitignore @@ -0,0 +1 @@ +*.gz diff --git a/examples/quickstart_mxnet/client.py b/examples/quickstart_mxnet/client.py index 099572f7f3f7..6c2b2e99775d 100644 --- a/examples/quickstart_mxnet/client.py +++ b/examples/quickstart_mxnet/client.py @@ -38,7 +38,7 @@ def model(): # Flower Client class MNISTClient(fl.client.NumPyClient): - def get_parameters(self): + def get_parameters(self, config): param = [] for val in model.collect_params(".*weight").values(): p = val.data() @@ -54,7 +54,7 @@ def fit(self, parameters, config): self.set_parameters(parameters) [accuracy, loss], num_examples = train(model, train_data, epoch=2) results = {"accuracy": float(accuracy[1]), "loss": float(loss[1])} - return self.get_parameters(), num_examples, results + return self.get_parameters(config={}), num_examples, results def evaluate(self, parameters, config): self.set_parameters(parameters) diff --git a/examples/quickstart_mxnet/pyproject.toml b/examples/quickstart_mxnet/pyproject.toml index cf325466526f..f1c494b9870a 100644 --- a/examples/quickstart_mxnet/pyproject.toml +++ b/examples/quickstart_mxnet/pyproject.toml @@ -13,3 +13,4 @@ python = "^3.7" flwr = "^0.17.0" # flwr = { path = "../../", develop = true } # Development mxnet = "^1.7.0" +numpy = "1.23.1" diff --git a/examples/quickstart_mxnet/server.py b/examples/quickstart_mxnet/server.py index 204657694b5e..871aa4e8ec99 100644 --- a/examples/quickstart_mxnet/server.py +++ b/examples/quickstart_mxnet/server.py @@ -5,5 +5,5 @@ if __name__ == "__main__": fl.server.start_server( server_address="0.0.0.0:8080", - config={"num_rounds": 3}, + config=fl.server.ServerConfig(num_rounds=3), )