Skip to content

Commit

Permalink
test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chancejohnstone committed Oct 21, 2024
1 parent 48130eb commit 9053f49
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions baselines/fedht/fedht/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _aggregate_n_closest_weights(
# calls hardthreshold function for each list element in weights_all
def hardthreshold_list(weights_all, num_keep: int) -> NDArrays:
"""Call hardthreshold."""
params = [hardthreshold(each, num_keep) for each in weights_all]
params: NDArrays = [hardthreshold(each, num_keep) for each in weights_all]
return params


Expand Down Expand Up @@ -461,8 +461,7 @@ def aggregate_hardthreshold(
reduce(np.add, layer_updates) / num_examples_total
for layer_updates in zip(*weighted_weights2)
]
params = [hardthreshold_list(layer_updates, num_keep) for layer_updates in hold]

result: NDArrays = params

result: NDArrays = [hardthreshold_list(layer_updates, num_keep) for layer_updates in hold]

return result
2 changes: 1 addition & 1 deletion baselines/fedht/fedht/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main(cfg: DictConfig):
# initialize global model to all zeros
weights = np.zeros((num_classes, num_features))
bias = np.zeros(num_classes)
init_params: NDArrays = (weights, bias)
init_params: NDArrays = [weights, bias]
init_params = ndarrays_to_parameters(init_params)

# define strategy: fedht
Expand Down
1 change: 1 addition & 0 deletions baselines/fedht/fedht/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ def test(model, testloader: DataLoader) -> None:

loss /= len(testloader)
accuracy = correct / total

return loss, accuracy
2 changes: 1 addition & 1 deletion baselines/fedht/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository = "https://github.com/adap/flower"
documentation = "https://flower.ai"

[tool.poetry.dependencies]
python = ">=3.10.0, <3.11.0"
python = ">=3.10.0,<4.0"
flwr = { extras = ["simulation"], version = ">=1.11.0" }
flwr-datasets = { extras = ["vision"], version = ">=0.3.0" }
scikit-learn =">=1.1.1"
Expand Down

0 comments on commit 9053f49

Please sign in to comment.