Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gubertoli committed Sep 20, 2023
1 parent 3ed88ad commit 9c6c9e3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions baselines/fedavgm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,13 @@ poetry run python -m fedavgm.main server.reporting_fraction=0.2 client.local_epo
:warning: _Your baseline implementation should replicate several of the experiments in the original paper. Please include here the exact command(s) needed to run each of those experiments followed by a figure (e.g. a line plot) or table showing the results you obtained when you ran the code. Below is an example of how you can present this. Please add command followed by results for all your experiments._

```bash
# it is likely that for one experiment you need to sweep over different hyperparameters. You are encouraged to use Hydra's multirun functionality for this. This is an example of how you could achieve this for some typical FL hyperparameteres

poetry run python -m fedavgm.main --multirun client.local_epochs=1,5 noniid.concentration=100,10,1,0.5,0.2,0.1,0.05,0 strategy=fedavgm,fedavg server.reporting_fraction=0.05,0.1,0.4 num_rounds=10000 num_clients=100
poetry run python -m fedavgm.main --multirun client.local_epochs=1 noniid.concentration=10,1,0.1,0.01 strategy=fedavgm,fedavg server.reporting_fraction=0.05,0.4 num_rounds=1000 num_clients=100 dataset=fmnist

# the above command will run a total of 6 individual experiments (because 3client_configs x 2datasets = 6 -- you can think of it as a grid).

[Now show a figure/table displaying the results of the above command]

poetry run python -m fedavgm.main --multirun client.local_epochs=1,5 noniid.concentration=100,10,1,0.5,0.2,0.1,0.05,0 strategy=fedavgm,fedavg server.reporting_fraction=0.05,0.1,0.4 num_rounds=10000 dataset=fmnist num_clients=100
poetry run python -m fedavgm.main --multirun client.local_epochs=1 noniid.concentration=10,1,0.1 strategy=fedavgm,fedavg server.reporting_fraction=0.05,0.4 num_rounds=10000 num_clients=100 dataset=cifar10

# add more commands + plots for additional experiments.
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion baselines/fedavgm/fedavgm/conf/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ client:
defaults:
- strategy: fedavgm
- model: cnn
- dataset: cifar10
- dataset: cifar10
2 changes: 1 addition & 1 deletion baselines/fedavgm/fedavgm/conf/model/cnn.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
_target_: fedavgm.models.cnn
input_shape: ${dataset.input_shape}
num_classes: ${dataset.num_classes}
num_classes: ${dataset.num_classes}
4 changes: 2 additions & 2 deletions baselines/fedavgm/fedavgm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def cnn(input_shape, num_classes):
keras.layers.Dense(num_classes, activation="softmax"),
]
)
optimizer = SGD(learning_rate=0.1)
optimizer = SGD(learning_rate=0.01)
model.compile(
loss="categorical_crossentropy", optimizer=optimizer, metrics=["accuracy"]
)
Expand Down Expand Up @@ -108,7 +108,7 @@ def tf_example(input_shape, num_classes):
keras.layers.Dense(num_classes, activation="softmax"),
]
)
optimizer = SGD(learning_rate=0.1)
optimizer = SGD(learning_rate=0.01)
model.compile(
loss="categorical_crossentropy", optimizer=optimizer, metrics=["accuracy"]
)
Expand Down
4 changes: 2 additions & 2 deletions baselines/fedavgm/fedavgm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def plot_concentrations_cifar10():
num_clients = 30

# Simulated different concentrations for partitioning
concentration_values = [np.inf, 100, 1, 1e-12]
concentration_values = [np.inf, 100, 1, 0.1, 0.01, 1e-12]
color = plt.get_cmap("RdYlGn")(np.linspace(0.15, 0.85, num_classes))
num_plots = len(concentration_values)
fig, axs = plt.subplots(1, num_plots, figsize=(15, 5), sharey=True)
Expand Down Expand Up @@ -53,7 +53,7 @@ def plot_concentrations_cifar10():

fig.text(0, 0.5, "Client", va="center", rotation="vertical")
plt.tight_layout()
plt.savefig("../docs/concentration_cifar10.png")
plt.savefig("../docs/concentration_cifar10_v2.png")
print(">>> Concentration plot created")
return None

Expand Down

0 comments on commit 9c6c9e3

Please sign in to comment.