I haven’t been able to get it to work quite yet, I ran into trouble passing the opt_func
to language_model_learner
:
AttributeErrorTraceback (most recent call last)
<ipython-input-17-2b09e9261ef7> in <module>
----> 1 learn = language_model_learner(data_lm, AWD_LSTM, drop_mult=0.25, opt_func=lamb_opt)
/opt/conda/lib/python3.7/site-packages/fastai/text/learner.py in language_model_learner(data, arch, config, drop_mult, pretrained, pretrained_fnames, **learn_kwargs)
212 fnames = [list(model_path.glob(f'*.{ext}'))[0] for ext in ['pth', 'pkl']]
213 learn.load_pretrained(*fnames)
--> 214 learn.freeze()
215 if pretrained_fnames is not None:
216 fnames = [learn.path/learn.model_dir/f'{fn}.{ext}' for fn,ext in zip(pretrained_fnames, ['pth', 'pkl'])]
/opt/conda/lib/python3.7/site-packages/fastai/basic_train.py in freeze(self)
217 "Freeze up to last layer group."
218 assert(len(self.layer_groups)>1)
--> 219 self.freeze_to(-1)
220 self.create_opt(defaults.lr)
221
/opt/conda/lib/python3.7/site-packages/fastai/basic_train.py in freeze_to(self, n)
212 if not self.train_bn or not isinstance(l, bn_types): requires_grad(l, False)
213 for g in self.layer_groups[n:]: requires_grad(g, True)
--> 214 self.create_opt(defaults.lr)
215
216 def freeze(self)->None:
/opt/conda/lib/python3.7/site-packages/fastai/basic_train.py in create_opt(self, lr, wd)
198 def create_opt(self, lr:Floats, wd:Floats=0.)->None:
199 "Create optimizer with `lr` learning rate and `wd` weight decay."
--> 200 self.opt = OptimWrapper.create(self.opt_func, lr, self.layer_groups, wd=wd, true_wd=self.true_wd, bn_wd=self.bn_wd)
201
202 def split(self, split_on:SplitFuncOrIdxList)->None:
/opt/conda/lib/python3.7/site-packages/fastai/callback.py in create(cls, opt_func, lr, layer_groups, wd, true_wd, bn_wd)
22 split_params = split_no_wd_params(layer_groups)
23 opt = opt_func([{'params': p, 'lr':0} for p in split_params])
---> 24 opt = cls(opt, wd=wd, true_wd=true_wd, bn_wd=bn_wd)
25 opt.lr,opt.opt_func = listify(lr, layer_groups),opt_func
26 return opt
/opt/conda/lib/python3.7/site-packages/fastai/callback.py in __init__(self, opt, wd, true_wd, bn_wd)
11 def __init__(self, opt:optim.Optimizer, wd:Floats=0., true_wd:bool=False, bn_wd:bool=True):
12 self.opt,self.true_wd,self.bn_wd = opt,true_wd,bn_wd
---> 13 self.opt_keys = list(self.opt.param_groups[0].keys())
14 self.opt_keys.remove('params')
15 self.read_defaults()
AttributeError: 'list' object has no attribute 'keys'
Going to try to trace through and find where the mismatch in expected format is tomorrow.