Skip to content

Commit

Permalink
fix issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
SarodYatawatta committed Jan 16, 2022
1 parent 6c229b9 commit 32f875e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lbfgsnew.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def _gather_flat_grad(self):
if p.grad is None:
view = p.data.new(p.data.numel()).zero_()
elif p.grad.data.is_sparse:
view = p.grad.data.to_dense().view(-1)
view = p.grad.data.to_dense().contiguous().view(-1)
else:
view = p.grad.data.view(-1)
view = p.grad.data.contiguous().view(-1)
views.append(view)
return torch.cat(views, 0)

Expand All @@ -105,7 +105,7 @@ def _copy_params_out(self):
new_params = []
for p in self._params:
numel = p.numel()
new_param1=p.data.clone().view(-1)
new_param1=p.data.clone().contiguous().view(-1)
offset += numel
new_params.append(new_param1)
assert offset == self._numel()
Expand Down

0 comments on commit 32f875e

Please sign in to comment.