Hi
I am trying to implement Mixup in TabularLearner.
Here is the code I wrote:
from fastai.callbacks import *
learn = tabular_learner(data, layers=[1000,500], metrics=accuracy, ps=[0.3,0.2], callback_fns=[MixUpCallback],emb_drop=0.04)
But the error I am getting is as follows:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-36-399ce5aa3598> in <module>
----> 1 learn.lr_find()
2 learn.recorder.plot(suggestion=True)
/opt/conda/lib/python3.6/site-packages/fastai/train.py in lr_find(learn, start_lr, end_lr, num_it, stop_div, wd)
30 cb = LRFinder(learn, start_lr, end_lr, num_it, stop_div)
31 epochs = int(np.ceil(num_it/len(learn.data.train_dl)))
---> 32 learn.fit(epochs, start_lr, callbacks=[cb], wd=wd)
33
34 def to_fp16(learn:Learner, loss_scale:float=None, max_noskip:int=1000, dynamic:bool=True, clip:float=None,
/opt/conda/lib/python3.6/site-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
197 callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
198 if defaults.extra_callbacks is not None: callbacks += defaults.extra_callbacks
--> 199 fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
200
201 def create_opt(self, lr:Floats, wd:Floats=0.)->None:
/opt/conda/lib/python3.6/site-packages/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
98 cb_handler.on_epoch_begin()
99 for xb,yb in progress_bar(learn.data.train_dl, parent=pbar):
--> 100 xb, yb = cb_handler.on_batch_begin(xb, yb)
101 loss = loss_batch(learn.model, xb, yb, learn.loss_func, learn.opt, cb_handler)
102 if cb_handler.on_batch_end(loss): break
/opt/conda/lib/python3.6/site-packages/fastai/callback.py in on_batch_begin(self, xb, yb, train)
277 self.state_dict.update(dict(last_input=xb, last_target=yb, train=train,
278 stop_epoch=False, skip_step=False, skip_zero=False, skip_bwd=False))
--> 279 self('batch_begin', mets = not self.state_dict['train'])
280 return self.state_dict['last_input'], self.state_dict['last_target']
281
/opt/conda/lib/python3.6/site-packages/fastai/callback.py in __call__(self, cb_name, call_mets, **kwargs)
249 if call_mets:
250 for met in self.metrics: self._call_and_update(met, cb_name, **kwargs)
--> 251 for cb in self.callbacks: self._call_and_update(cb, cb_name, **kwargs)
252
253 def set_dl(self, dl:DataLoader):
/opt/conda/lib/python3.6/site-packages/fastai/callback.py in _call_and_update(self, cb, cb_name, **kwargs)
239 def _call_and_update(self, cb, cb_name, **kwargs)->None:
240 "Call `cb_name` on `cb` and update the inner state."
--> 241 new = ifnone(getattr(cb, f'on_{cb_name}')(**self.state_dict, **kwargs), dict())
242 for k,v in new.items():
243 if k not in self.state_dict:
/opt/conda/lib/python3.6/site-packages/fastai/callbacks/mixup.py in on_batch_begin(self, last_input, last_target, train, **kwargs)
18 lambd = np.random.beta(self.alpha, self.alpha, last_target.size(0))
19 lambd = np.concatenate([lambd[:,None], 1-lambd[:,None]], 1).max(1)
---> 20 lambd = last_input.new(lambd)
21 shuffle = torch.randperm(last_target.size(0)).to(last_input.device)
22 x1, y1 = last_input[shuffle], last_target[shuffle]
**AttributeError: 'list' object has no attribute 'new'**
Am I doing something which I should not do or there are some problems in the codes/implementation?