Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix argument order & renaming" #236

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fedscale/cloud/internal/torch_model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def set_weights(self, weights: List[np.ndarray]):
Set the model's weights to the numpy weights array.
:param weights: numpy weights array
"""
last_grad_weights = [param.data.clone() for param in self.model.state_dict().values()]
current_grad_weights = [param.data.clone() for param in self.model.state_dict().values()]
new_state_dict = {
name: torch.from_numpy(np.asarray(weights[i], dtype=np.float32))
for i, name in enumerate(self.model.state_dict().keys())
Expand All @@ -34,7 +34,7 @@ def set_weights(self, weights: List[np.ndarray]):
if self.optimizer:
weights_origin = copy.deepcopy(weights)
weights = [torch.tensor(x) for x in weights_origin]
self.optimizer.update_round_gradient(last_grad_weights, weights, self.model)
self.optimizer.update_round_gradient(weights, current_grad_weights, self.model)

def get_weights(self) -> List[np.ndarray]:
"""
Expand Down
Loading