Not sure why I got this error.
index 3 is out of bounds for dimension 0 with size 3
epoch train_loss valid_loss error_rate time
0 0.721268 00:10
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in
1 learn = cnn_learner(dlsaug, resnet18, metrics=error_rate)
----> 2 learn.fine_tune(1)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/schedule.py in fine_tune(self, epochs, base_lr, freeze_epochs, lr_mult, pct_start, div, **kwargs)
155 "Fine tune with `freeze` for `freeze_epochs` then with `unfreeze` from `epochs` using discriminative LR"
156 self.freeze()
--> 157 self.fit_one_cycle(freeze_epochs, slice(base_lr), pct_start=0.99, **kwargs)
158 base_lr /= 2
159 self.unfreeze()
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/schedule.py in fit_one_cycle(self, n_epoch, lr_max, div, div_final, pct_start, wd, moms, cbs, reset_opt)
110 scheds = {'lr': combined_cos(pct_start, lr_max/div, lr_max, lr_max/div_final),
111 'mom': combined_cos(pct_start, *(self.moms if moms is None else moms))}
--> 112 self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
113
114 # Cell
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
193 try:
194 self.epoch=epoch; self('begin_epoch')
--> 195 self._do_epoch_train()
196 self._do_epoch_validate()
197 except CancelEpochException: self('after_cancel_epoch')
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in _do_epoch_train(self)
166 try:
167 self.dl = self.dls.train; self('begin_train')
--> 168 self.all_batches()
169 except CancelTrainException: self('after_cancel_train')
170 finally: self('after_train')
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in all_batches(self)
144 def all_batches(self):
145 self.n_iter = len(self.dl)
--> 146 for o in enumerate(self.dl): self.one_batch(*o)
147
148 def one_batch(self, i, b):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in one_batch(self, i, b)
149 self.iter = i
150 try:
--> 151 self._split(b); self('begin_batch')
152 self.pred = self.model(*self.xb); self('after_pred')
153 if len(self.yb) == 0: return
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in __call__(self, event_name)
125 def ordered_cbs(self, event): return [cb for cb in sort_by_run(self.cbs) if hasattr(cb, event)]
126
--> 127 def __call__(self, event_name): L(event_name).map(self._call_one)
128 def _call_one(self, event_name):
129 assert hasattr(event, event_name)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
370 else f.format if isinstance(f,str)
371 else f.__getitem__)
--> 372 return self._new(map(g, self))
373
374 def filter(self, f, negate=False, **kwargs):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
321 @property
322 def _xtra(self): return None
--> 323 def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
324 def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
325 def copy(self): return self._new(self.items.copy())
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
39 return x
40
---> 41 res = super().__call__(*((x,) + args), **kwargs)
42 res._newchk = 0
43 return res
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
312 if items is None: items = []
313 if (use_list is not None) or not _is_array(items):
--> 314 items = list(items) if use_list else _listify(items)
315 if match is not None:
316 if is_coll(match): match = len(match)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in _listify(o)
248 if isinstance(o, list): return o
249 if isinstance(o, str) or _is_array(o): return [o]
--> 250 if is_iter(o): return list(o)
251 return [o]
252
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
214 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
215 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 216 return self.fn(*fargs, **kwargs)
217
218 # Cell
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in _call_one(self, event_name)
128 def _call_one(self, event_name):
129 assert hasattr(event, event_name)
--> 130 [cb(event_name) for cb in sort_by_run(self.cbs)]
131
132 def _bn_bias_state(self, with_bias): return bn_bias_params(self.model, with_bias).map(self.opt.state)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in <listcomp>(.0)
128 def _call_one(self, event_name):
129 assert hasattr(event, event_name)
--> 130 [cb(event_name) for cb in sort_by_run(self.cbs)]
131
132 def _bn_bias_state(self, with_bias): return bn_bias_params(self.model, with_bias).map(self.opt.state)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/core.py in __call__(self, event_name)
22 _run = (event_name not in _inner_loop or (self.run_train and getattr(self, 'training', True)) or
23 (self.run_valid and not getattr(self, 'training', False)))
---> 24 if self.run and _run: getattr(self, event_name, noop)()
25 if event_name=='after_fit': self.run=True #Reset self.run to True at each end of fit
26
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/schedule.py in begin_batch(self)
84 def __init__(self, scheds): self.scheds = scheds
85 def begin_fit(self): self.hps = {p:[] for p in self.scheds.keys()}
---> 86 def begin_batch(self): self._update_val(self.pct_train)
87
88 def _update_val(self, pct):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/schedule.py in _update_val(self, pct)
87
88 def _update_val(self, pct):
---> 89 for n,f in self.scheds.items(): self.opt.set_hyper(n, f(pct))
90
91 def after_batch(self):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/callback/schedule.py in _inner(pos)
67 if pos == 1.: return scheds[-1](1.)
68 idx = (pos >= pcts).nonzero().max()
---> 69 actual_pos = (pos-pcts[idx]) / (pcts[idx+1]-pcts[idx])
70 return scheds[idx](actual_pos.item())
71 return _inner