In the note book 9_optimizer we created a generic optimizer that takes params as one param which if not passed then inside get runner we pass model.parameters().
def get_runner(model, data, lr=0.6, cbs=None, opt_func=None, groups=None,loss_func = F.cross_entropy):
if opt_func is None:
opt_func = optim.SGD
opt = opt_func(model.parameters(), lr=lr)
learn = Learner(model, opt, loss_func, data)
return learn, Runner(cb_funcs=listify(cbs))
when I try to pass to optiimzer class params
opt_func = partial(Optimizer, params=groups,steppers=[sgd_step])
then i get an error
,then i get an error saying
if opt_func is None: opt_func = optim.SGD
—> 38 opt = opt_func(model.parameters(), lr=lr)
39 learn = Learner(model, opt, loss_func, data)
40 return learn, Runner(cb_funcs=listify(cbs))
TypeError: init() got multiple values for argument ‘params’
Shouldnt we have one more param to get runner with name say params or groups which if not none or opt func not none then instead of all parameters ,params should be passed ??
secondly,
If i also want to pass in momentum then where should i include it
?
opt_func(model.parameters(), lr=lr,momentum=0.9) ??