Hi there all,
I am trying to get this model to work, but I don’t understand why it’s not working. What I am missing, what I understand is that the cnn_learning gets the # of classes automatically from data.c
Thanks.
data = ImageDataBunch.from_name_re(path_img,
fnames,
pat,
ds_tfms=get_transforms(),
size=224,
bs=32
).normalize(imagenet_stats)
learner = cnn_learner(data, models.WideResNet, metrics=error_rate)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-31-f65b131e20e0> in <module>
----> 1 learner = cnn_learner(data, models.WideResNet, metrics=error_rate)
/usr/local/lib/python3.6/dist-packages/fastai/vision/learner.py in cnn_learner(data, base_arch, cut, pretrained, lin_ftrs, ps, custom_head, split_on, bn_final, init, concat_pool, **kwargs)
99 meta = cnn_config(base_arch)
100 model = create_cnn_model(base_arch, data.c, cut, pretrained, lin_ftrs, ps=ps, custom_head=custom_head,
--> 101 bn_final=bn_final, concat_pool=concat_pool)
102 learn = Learner(data, model, **kwargs)
103 learn.split(split_on or meta['split'])
/usr/local/lib/python3.6/dist-packages/fastai/vision/learner.py in create_cnn_model(base_arch, nc, cut, pretrained, lin_ftrs, ps, custom_head, bn_final, concat_pool)
85 bn_final:bool=False, concat_pool:bool=True):
86 "Create custom convnet architecture"
---> 87 body = create_body(base_arch, pretrained, cut)
88 if custom_head is None:
89 nf = num_features_model(nn.Sequential(*body.children())) * (2 if concat_pool else 1)
/usr/local/lib/python3.6/dist-packages/fastai/vision/learner.py in create_body(arch, pretrained, cut)
57 def create_body(arch:Callable, pretrained:bool=True, cut:Optional[Union[int, Callable]]=None):
58 "Cut off the body of a typically pretrained `model` at `cut` (int) or cut the model as specified by `cut(model)` (function)."
---> 59 model = arch(pretrained)
60 cut = ifnone(cut, cnn_config(arch)['cut'])
61 if cut is None:
/usr/local/lib/python3.6/dist-packages/fastai/core.py in _init(self, *args, **kwargs)
64 def _init(self,*args,**kwargs):
65 self.__pre_init__()
---> 66 old_init(self, *args,**kwargs)
67 self.__post_init__()
68 x.__init__ = _init
TypeError: __init__() missing 2 required positional arguments: 'N' and 'num_classes'