I followed the instruction to setup gradient. however, I am not even able to run the 1st notebook.
# CLICK ME
from fastai.vision.all import *
path = untar_data(URLs.PETS)/‘images’
def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
I got this error AssertionError: self.recorder already registered, it happens on colab too. not sure what to do. any help will be greatly appreciated. thanks!
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-3-3244ec10e8a7> in <module>
8 label_func=is_cat, item_tfms=Resize(224))
9
---> 10 learn = cnn_learner(dls, resnet34, metrics=error_rate)
11 learn.fine_tune(1)
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/utils.py in _f(*args, **kwargs)
448 log_dict = {**func_args.arguments, **{f'{k} (not in signature)':v for k,v in xtra_kwargs.items()}}
449 log = {f'{f.__qualname__}.{k}':v for k,v in log_dict.items() if k not in but}
--> 450 inst = f(*args, **kwargs) if to_return else args[0]
451 init_args = getattr(inst, 'init_args', {})
452 init_args.update(log)
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/learner.py in cnn_learner(dls, arch, loss_func, pretrained, cut, splitter, y_range, config, n_out, normalize, **kwargs)
174 if y_range is None and 'y_range' in config: y_range = config.pop('y_range')
175 model = create_cnn_model(arch, n_out, ifnone(cut, meta['cut']), pretrained, y_range=y_range, **config)
--> 176 learn = Learner(dls, model, loss_func=loss_func, splitter=ifnone(splitter, meta['split']), **kwargs)
177 if pretrained: learn.freeze()
178 return learn
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/utils.py in _f(*args, **kwargs)
452 init_args.update(log)
453 setattr(inst, 'init_args', init_args)
--> 454 return inst if to_return else f(*args, **kwargs)
455 return _f
456
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/learner.py in __init__(self, dls, model, loss_func, opt_func, lr, splitter, cbs, metrics, path, model_dir, wd, wd_bn_bias, train_bn, moms)
91 self.loss_func = loss_func
92 self.path = Path(path) if path is not None else getattr(dls, 'path', Path('.'))
---> 93 self.add_cbs([(cb() if isinstance(cb, type) else cb) for cb in L(defaults.callbacks)+L(cbs)])
94 self.epoch,self.n_epoch,self.loss = 0,1,tensor(0.)
95
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/learner.py in add_cbs(self, cbs)
100
101 def _grab_cbs(self, cb_cls): return L(cb for cb in self.cbs if isinstance(cb, cb_cls))
--> 102 def add_cbs(self, cbs): L(cbs).map(self.add_cb)
103 def remove_cbs(self, cbs): L(cbs).map(self.remove_cb)
104 def add_cb(self, cb):
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
381 else f.format if isinstance(f,str)
382 else f.__getitem__)
--> 383 return self._new(map(g, self))
384
385 def filter(self, f, negate=False, **kwargs):
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
331 @property
332 def _xtra(self): return None
--> 333 def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
334 def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
335 def copy(self): return self._new(self.items.copy())
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
45 return x
46
---> 47 res = super().__call__(*((x,) + args), **kwargs)
48 res._newchk = 0
49 return res
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
322 if items is None: items = []
323 if (use_list is not None) or not _is_array(items):
--> 324 items = list(items) if use_list else _listify(items)
325 if match is not None:
326 if is_coll(match): match = len(match)
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in _listify(o)
258 if isinstance(o, list): return o
259 if isinstance(o, str) or _is_array(o): return [o]
--> 260 if is_iter(o): return list(o)
261 return [o]
262
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
224 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
225 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 226 return self.fn(*fargs, **kwargs)
227
228 # Cell
/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/learner.py in add_cb(self, cb)
104 def add_cb(self, cb):
105 old = getattr(self, cb.name, None)
--> 106 assert not old or isinstance(old, type(cb)), f"self.{cb.name} already registered"
107 cb.learn = self
108 setattr(self, cb.name, cb)
AssertionError: self.recorder already registered