flwr-nightly 1.10.0.dev20240717__py3-none-any.whl → 1.10.0.dev20240719__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flwr/cli/new/templates/app/code/client.hf.py.tpl +7 -3
- flwr/cli/new/templates/app/code/client.mlx.py.tpl +10 -8
- flwr/cli/new/templates/app/code/client.pytorch.py.tpl +7 -1
- flwr/cli/new/templates/app/code/client.sklearn.py.tpl +2 -1
- flwr/cli/new/templates/app/code/client.tensorflow.py.tpl +9 -2
- flwr/cli/new/templates/app/pyproject.hf.toml.tpl +1 -0
- flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +5 -0
- flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +1 -0
- flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +3 -0
- flwr/cli/run/run.py +1 -1
- {flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/METADATA +1 -1
- {flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/RECORD +15 -15
- {flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/entry_points.txt +0 -0
|
@@ -30,7 +30,11 @@ class FlowerClient(NumPyClient):
|
|
|
30
30
|
|
|
31
31
|
def fit(self, parameters, config):
|
|
32
32
|
self.set_parameters(parameters)
|
|
33
|
-
train(
|
|
33
|
+
train(
|
|
34
|
+
self.net,
|
|
35
|
+
self.trainloader,
|
|
36
|
+
epochs=int(self.context.run_config["local-epochs"]),
|
|
37
|
+
)
|
|
34
38
|
return self.get_parameters(config={}), len(self.trainloader), {}
|
|
35
39
|
|
|
36
40
|
def evaluate(self, parameters, config):
|
|
@@ -45,8 +49,8 @@ def client_fn(context: Context):
|
|
|
45
49
|
CHECKPOINT, num_labels=2
|
|
46
50
|
).to(DEVICE)
|
|
47
51
|
|
|
48
|
-
partition_id = int(context.node_config[
|
|
49
|
-
num_partitions = int(context.node_config[
|
|
52
|
+
partition_id = int(context.node_config["partition-id"])
|
|
53
|
+
num_partitions = int(context.node_config["num-partitions"])
|
|
50
54
|
trainloader, valloader = load_data(partition_id, num_partitions)
|
|
51
55
|
|
|
52
56
|
# Return Client instance
|
|
@@ -20,17 +20,19 @@ from $import_name.task import (
|
|
|
20
20
|
# Define Flower Client and client_fn
|
|
21
21
|
class FlowerClient(NumPyClient):
|
|
22
22
|
def __init__(self, data):
|
|
23
|
-
num_layers =
|
|
24
|
-
hidden_dim =
|
|
23
|
+
num_layers = int(self.context.run_config["num-layers"])
|
|
24
|
+
hidden_dim = int(self.context.run_config["hidden-dim"])
|
|
25
25
|
num_classes = 10
|
|
26
|
-
batch_size =
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
batch_size = int(self.context.run_config["batch-size"])
|
|
27
|
+
learning_rate = float(self.context.run_config["lr"])
|
|
28
|
+
num_epochs = int(self.context.run_config["local-epochs"])
|
|
29
29
|
|
|
30
30
|
self.train_images, self.train_labels, self.test_images, self.test_labels = data
|
|
31
|
-
self.model = MLP(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
self.model = MLP(
|
|
32
|
+
num_layers, self.train_images.shape[-1], hidden_dim, num_classes
|
|
33
|
+
)
|
|
34
|
+
self.optimizer = optim.SGD(learning_rate=learning_rate)
|
|
35
|
+
self.loss_and_grad_fn = nn.value_and_grad(self.model, loss_fn)
|
|
34
36
|
self.num_epochs = num_epochs
|
|
35
37
|
self.batch_size = batch_size
|
|
36
38
|
|
|
@@ -23,7 +23,13 @@ class FlowerClient(NumPyClient):
|
|
|
23
23
|
|
|
24
24
|
def fit(self, parameters, config):
|
|
25
25
|
set_weights(self.net, parameters)
|
|
26
|
-
results = train(
|
|
26
|
+
results = train(
|
|
27
|
+
self.net,
|
|
28
|
+
self.trainloader,
|
|
29
|
+
self.valloader,
|
|
30
|
+
int(self.context.run_config["local-epochs"]),
|
|
31
|
+
DEVICE,
|
|
32
|
+
)
|
|
27
33
|
return get_weights(self.net), len(self.trainloader.dataset), results
|
|
28
34
|
|
|
29
35
|
def evaluate(self, parameters, config):
|
|
@@ -67,10 +67,11 @@ class FlowerClient(NumPyClient):
|
|
|
67
67
|
|
|
68
68
|
return loss, len(self.X_test), {"accuracy": accuracy}
|
|
69
69
|
|
|
70
|
-
fds = FederatedDataset(dataset="mnist", partitioners={"train": 2})
|
|
71
70
|
|
|
72
71
|
def client_fn(context: Context):
|
|
73
72
|
partition_id = int(context.node_config["partition-id"])
|
|
73
|
+
num_partitions = int(context.node_config["num-partitions"])
|
|
74
|
+
fds = FederatedDataset(dataset="mnist", partitioners={"train": num_partitions})
|
|
74
75
|
dataset = fds.load_partition(partition_id, "train").with_format("numpy")
|
|
75
76
|
|
|
76
77
|
X, y = dataset["image"].reshape((len(dataset), -1)), dataset["label"]
|
|
@@ -20,7 +20,13 @@ class FlowerClient(NumPyClient):
|
|
|
20
20
|
|
|
21
21
|
def fit(self, parameters, config):
|
|
22
22
|
self.model.set_weights(parameters)
|
|
23
|
-
self.model.fit(
|
|
23
|
+
self.model.fit(
|
|
24
|
+
self.x_train,
|
|
25
|
+
self.y_train,
|
|
26
|
+
epochs=int(self.context.run_config["local-epochs"]),
|
|
27
|
+
batch_size=int(self.context.run_config["batch-size"]),
|
|
28
|
+
verbose=bool(self.context.run_config.get("verbose")),
|
|
29
|
+
)
|
|
24
30
|
return self.model.get_weights(), len(self.x_train), {}
|
|
25
31
|
|
|
26
32
|
def evaluate(self, parameters, config):
|
|
@@ -34,7 +40,8 @@ def client_fn(context: Context):
|
|
|
34
40
|
net = load_model()
|
|
35
41
|
|
|
36
42
|
partition_id = int(context.node_config["partition-id"])
|
|
37
|
-
|
|
43
|
+
num_partitions = int(context.node_config["num-partitions"])
|
|
44
|
+
x_train, y_train, x_test, y_test = load_data(partition_id, num_partitions)
|
|
38
45
|
|
|
39
46
|
# Return Client instance
|
|
40
47
|
return FlowerClient(net, x_train, y_train, x_test, y_test).to_client()
|
flwr/cli/run/run.py
CHANGED
{flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/RECORD
RENAMED
|
@@ -14,13 +14,13 @@ flwr/cli/new/templates/app/README.md.tpl,sha256=_qGtgpKYKoCJVjQnvlBMKvFs_1gzTcL9
|
|
|
14
14
|
flwr/cli/new/templates/app/__init__.py,sha256=DU7QMY7IhMQyuwm_tja66xU0KXTWQFqzfTqwg-_NJdE,729
|
|
15
15
|
flwr/cli/new/templates/app/code/__init__.py,sha256=EM6vfvgAILKPaPn7H1wMV1Wi01WyZCP_Eg6NxD6oWg8,736
|
|
16
16
|
flwr/cli/new/templates/app/code/__init__.py.tpl,sha256=olwrBeJemHNBWvjc6gJURloFRqW40dAy7FRQA5pDqHU,21
|
|
17
|
-
flwr/cli/new/templates/app/code/client.hf.py.tpl,sha256=
|
|
17
|
+
flwr/cli/new/templates/app/code/client.hf.py.tpl,sha256=_x-V6EcSgX2nPo-0ODHaKFgt9n_aONNrWpkbQPrTxE0,1727
|
|
18
18
|
flwr/cli/new/templates/app/code/client.jax.py.tpl,sha256=i_SZykD42vqEvv2ZyX655szuikXJXLc6uV1T-LWiYLU,1479
|
|
19
|
-
flwr/cli/new/templates/app/code/client.mlx.py.tpl,sha256=
|
|
19
|
+
flwr/cli/new/templates/app/code/client.mlx.py.tpl,sha256=rrRXIU-jrx4FuzbMjqlMCrWi9ctEmtI9UCwol-U0oPg,2513
|
|
20
20
|
flwr/cli/new/templates/app/code/client.numpy.py.tpl,sha256=ov9mtWJGjaQ9ZVlQ5jsuCjHDeETf13GFla5jbP3KimE,561
|
|
21
|
-
flwr/cli/new/templates/app/code/client.pytorch.py.tpl,sha256=
|
|
22
|
-
flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=
|
|
23
|
-
flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=
|
|
21
|
+
flwr/cli/new/templates/app/code/client.pytorch.py.tpl,sha256=CJXi89YbOEirevOSy-VmfCpN59vV5Q3iM2TwCTgWkGc,1472
|
|
22
|
+
flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=44NQwBGHT1hTunUXQIvmv1EWDvKLw4Z40J1QnFRqIao,2986
|
|
23
|
+
flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=Rb0St2Hp-ftQyYR_Ao6okT8lkiQto76M66fp_y3Etgo,1664
|
|
24
24
|
flwr/cli/new/templates/app/code/flwr_tune/__init__.py,sha256=JgNgBtKdm1jKM9625WxappCAVUGtYAmcjKSsXJ1u3ZQ,748
|
|
25
25
|
flwr/cli/new/templates/app/code/flwr_tune/app.py.tpl,sha256=p5ImtKbFXw3x64n9xehvMwqXUmjLcwYfUPvRqKK2owU,2655
|
|
26
26
|
flwr/cli/new/templates/app/code/flwr_tune/client.py.tpl,sha256=MvQ5tt1r7CBUR8y-nBcZs4as2m1YimxegLYw_nHmXzc,4048
|
|
@@ -42,15 +42,15 @@ flwr/cli/new/templates/app/code/task.mlx.py.tpl,sha256=nrfZ1aGOs_ayb70j7XdAmwFYa
|
|
|
42
42
|
flwr/cli/new/templates/app/code/task.pytorch.py.tpl,sha256=TU4uNtJ9wtxeVvoHD3_K89EFWmrIvdECdASzRX-4Uvk,3694
|
|
43
43
|
flwr/cli/new/templates/app/code/task.tensorflow.py.tpl,sha256=cPOUUS07QbblT9PGFucwu9lY1clRA4-W4DQGA7cpcao,1044
|
|
44
44
|
flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl,sha256=XBcU_XPYt7GecNjeBmD915fZGsF189QMb_IzFl4ATTA,777
|
|
45
|
-
flwr/cli/new/templates/app/pyproject.hf.toml.tpl,sha256=
|
|
45
|
+
flwr/cli/new/templates/app/pyproject.hf.toml.tpl,sha256=kU2cAmlxC_DuJXU6zbNcXy2RmyjEsNTjyXDyeeHClnY,776
|
|
46
46
|
flwr/cli/new/templates/app/pyproject.jax.toml.tpl,sha256=njY9toiCCaKCM2yqPsAytlD-jgWF3-aUQmg3vBjbTi0,651
|
|
47
|
-
flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=
|
|
47
|
+
flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=ztZC5kQhjzVUUnvlfhOPebn1dx9QJOHRP4JARuZ_5EQ,750
|
|
48
48
|
flwr/cli/new/templates/app/pyproject.numpy.toml.tpl,sha256=5KiJUl6gm7rmW4xIBgF5qK5s2YMnMkouHBdOHuWUmcw,604
|
|
49
|
-
flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=
|
|
49
|
+
flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=Ur0D2S98AnoiVcy_pTQnxSuLssioQe6yzGWQ1rLkTU8,692
|
|
50
50
|
flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl,sha256=lOi7R32xbO6MF5_BF6-bUbjWoC_z3XtJhRj1REHmL5w,653
|
|
51
|
-
flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=
|
|
51
|
+
flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=svb0YkuTACGh_PWn_tbiH8T05xrnn0MyVEnuQsQH4h0,730
|
|
52
52
|
flwr/cli/run/__init__.py,sha256=oCd6HmQDx-sqver1gecgx-uMA38BLTSiiKpl7RGNceg,789
|
|
53
|
-
flwr/cli/run/run.py,sha256=
|
|
53
|
+
flwr/cli/run/run.py,sha256=DnABj0eJMNj_05nxzP8CCodocHe-EmDlAZhylGceauY,6983
|
|
54
54
|
flwr/cli/utils.py,sha256=l65Ul0YsSBPuypk0uorAtEDmLEYiUrzpCXi6zCg9mJ4,4506
|
|
55
55
|
flwr/client/__init__.py,sha256=wzJZsYJIHf_8-PMzvfbinyzzjgh1UP1vLrAw2_yEbKI,1345
|
|
56
56
|
flwr/client/app.py,sha256=jobLLjUGV3pkSYpd2wGyzG8e1KZPk2_O47IjTsXnk6Y,26106
|
|
@@ -270,8 +270,8 @@ flwr/superexec/exec_grpc.py,sha256=vYbZyV89MuvYDH1XzVYHkKmGfOcU6FWh8rTcIJk2TIQ,1
|
|
|
270
270
|
flwr/superexec/exec_servicer.py,sha256=4R1f_9v0vly_bXpIYaXAeV1tO5LAy1AYygGGGNZmlQk,2194
|
|
271
271
|
flwr/superexec/executor.py,sha256=5ua0AU2cfisyD79dosP-POF3w0FRH2I5Wko_PPKLWqU,2153
|
|
272
272
|
flwr/superexec/simulation.py,sha256=yOykF9zqFwHwkEN5gKHf7dMYdc1BVOysKpFPwlXIoOY,4663
|
|
273
|
-
flwr_nightly-1.10.0.
|
|
274
|
-
flwr_nightly-1.10.0.
|
|
275
|
-
flwr_nightly-1.10.0.
|
|
276
|
-
flwr_nightly-1.10.0.
|
|
277
|
-
flwr_nightly-1.10.0.
|
|
273
|
+
flwr_nightly-1.10.0.dev20240719.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
274
|
+
flwr_nightly-1.10.0.dev20240719.dist-info/METADATA,sha256=uUxTicfl_cj9_CQEFdvVvyjl06EphWU1db1jvN8cO48,15672
|
|
275
|
+
flwr_nightly-1.10.0.dev20240719.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
276
|
+
flwr_nightly-1.10.0.dev20240719.dist-info/entry_points.txt,sha256=7qBQcA-bDGDxnJmLd9FYqglFQubjCNqyg9M8a-lukps,336
|
|
277
|
+
flwr_nightly-1.10.0.dev20240719.dist-info/RECORD,,
|
{flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/LICENSE
RENAMED
|
File without changes
|
{flwr_nightly-1.10.0.dev20240717.dist-info → flwr_nightly-1.10.0.dev20240719.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|