You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
model = torch.nn.Linear(1, 1)
optimizer = mechanize(torch.optim.AdamW)(model.parameters(), lr=1e-5)
x = torch.ones([5, 1])
out = torch.sum(model(x))
out.backward()
optimizer.step()
print('done first step')
new_optimizer = mechanize(torch.optim.AdamW)(model.parameters(), lr=1e-5)
new_optimizer.load_state_dict(optimizer.state_dict())
out = torch.sum(model(x))
out.backward()
new_optimizer.step()
print('done new steps using new optimizer loaded')
The text was updated successfully, but these errors were encountered:
The issue is due to the fact that state_dict['state']['_mechanic'] has tensor pointers as keys, those does not have the same addresses when re-initializing new Mechanic optimizer
(other optimizers e.g AdamW has the indexes as keys for the state)
Welcome, I actually fixed that (will submit a PR next week, ) but it seems that on Windows the issue does not reproduce. (tried on my local machine and it worked)
The following simple script reproduces the issue:
The text was updated successfully, but these errors were encountered: