Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 30, 2024
1 parent a20650b commit 6f2d162
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions project/fed/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
RNGStateTuple,
)
from project.utils.utils import obtain_device
import operator


def generic_set_parameters(
Expand All @@ -60,7 +61,9 @@ def generic_set_parameters(
-------
None
"""
sorted_dict = sorted(net.state_dict().items(), key=lambda x: x[0]) # Sort by keys
sorted_dict = sorted(
net.state_dict().items(), key=operator.itemgetter(0)
) # Sort by keys

params_dict = zip(
(keys for keys, _ in sorted_dict),
Expand Down Expand Up @@ -88,7 +91,7 @@ def generic_get_parameters(net: nn.Module) -> NDArrays:
The parameters of the network.
"""
state_dict_items = sorted(
net.state_dict().items(), key=lambda x: x[0]
net.state_dict().items(), key=operator.itemgetter(0)
) # Sort by keys
parameters = [val.cpu().numpy() for _, val in state_dict_items]

Expand Down

0 comments on commit 6f2d162

Please sign in to comment.