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
I started using Ignite recently and i found it very interesting.
I would like to train a model using as an optimizer the LBFGS algorithm from the torch.optim module.
And the error that raises is: TypeError: step() missing 1 required positional argument: 'closure'
I know that is required to define a closure for the implementation of LBFGS, so my question is how can I do it using ignite? or is there another approach for doing this?
Thank you
The text was updated successfully, but these errors were encountered:
I do not know exactly how works LBFGS with closures, but with ignite it could be probably used like that:
fromignite.engineimportEnginemodel= ...
optimizer=torch.optim.LBFGS(model.parameters(), lr=1)
criterion=defupdate_fn(engine, batch):
model.train()
x, y=batch# pass to device if needed as here: https://github.com/pytorch/ignite/blob/40d815930d7801b21acfecfa21cd2641a5a50249/ignite/engine/__init__.py#L45defclosure():
y_pred=model(x)
loss=criterion(y_pred, y)
optimizer.zero_grad()
loss.backward()
returnlossoptimizer.step(closure)
trainer=Engine(update_fn)
# everything else is the same
Hi all,
I started using Ignite recently and i found it very interesting.
I would like to train a model using as an optimizer the LBFGS algorithm from the
torch.optim
module.This is my code:
And the error that raises is:
TypeError: step() missing 1 required positional argument: 'closure'
I know that is required to define a closure for the implementation of LBFGS, so my question is how can I do it using ignite? or is there another approach for doing this?
Thank you
The text was updated successfully, but these errors were encountered: