Using learning and setting optim parameters

I am trying to set some custom parameters in my optimizer with the Learning class.

So I have:

model_train = Learner(data=data, model=model, opt_func = torch.optim.Adam(lr=0.001, weight_decay=0.0005), loss_func=criterion)

I get:

TypeError: __init__() missing 1 required positional argument: 'params'

as according to the pytorch docs, the first part of call to Adam should be params?

As its name indicates, opt_func should be an function, not an optimizer. Here you should pass

opt_func = partial(optim.Adam, lr=0.001, weight_decay=0.0005)
2 Likes

thanks! works