Dog Breed Identification challenge

Thanks @KevinB will report it.

yeah works fine now after that fix Thanks @rob

Can someone help me with this error. Iā€™m not able to find any post related to this. Iā€™m trying to replicate the dogbreed notebook. Iā€™m trying to run this on AWS p2 instance.

Get rid of that line I believe is what Jeremy told somebody else. Other thing you could try is setting it to 0 but I think thatā€™s the default.

Thanks I just saw it in the beginner forum

Oh apologies I didnā€™t realize that itā€™s not in 0.2. Iā€™ll revert.

1 Like

The tqdm progress bar seems to be broken for me.
Is anyone facing this formatting issue?

1 Like

That just means you need to restart your kernel. Itā€™s a bug in tqdm, or probably actually in the jupyter console code.

2 Likes

Damn! Works like a charm now :sweat_smile:

That was quick! It works fine now :slight_smile:

Trying to understand if this conversation is about how to train with the entire data and all of the intelligence of the resnext model - what is meant by not ā€œremoving the last layer from pretrianed modelsā€ and " they are using the fully connected layers where we take those off and calculate our own"?

How can I do what is being talked about here - what is it that we do that removes the last layer, what can we do that preserves it?

Also, how can we retain all of the data to train with?

If you just want to remove the last layer you may need to do a little bit of extra work. One possibility is what I did here.

https://github.com/yanneta/pytorch-tutorials/blob/master/modified_VGG.ipynb

This could be simplified with the new API that Jeremy just wrote. See an example here.

https://github.com/fastai/fastai/blob/master/courses/dl1/cifar10.ipynb

I am happy to help if you have any questions. My example work for vgg16 you would have to understand the network that you are trying to change.

Iā€™ve got an example of how to cut layers off custom models that Iā€™ll be pushing soon-ish. Weā€™ll be discussing it later in the course.

2 Likes

OK this is at the more advanced end for now - but for those interested in understanding fastai more deeply:

I just added nasnet.ipynb . It shows how to use a new pretrained model type thatā€™s not already in fastai. (This particularly one is really slow BTW, although it should be better with 0.3).

Note that I also changed fastai.models.nasnet to optionally skip that classifier section.

10 Likes

wow nasnet, thats awesomeā€¦Thanks @jeremy !

For anyone interested in learning more about itā€¦

6 Likes

Actually I am quite confused about what is being discussed here.

What I was asking here was for someone to explain exactly what were these guys getting at when they said that the (I presumed standard) approach is ā€œremoving the last layer from pretrianed modelsā€ - because the guys that are NOT doing that are getting better results. I was not asking how to remove the last layer - but how to understand what the contributors @bushaev, @jamesrequa and @KevinB meant that we should NOT be removing it, and that they (the better scoring people) are ā€œusing the fully connected layers where we take those off and calculate our ownā€. Do they mean that we shouldnā€™t set precompute to false? It didnā€™t make sense to meā€¦

I was asking for clarification, but if I understand it correctly, they are doing well because the data is literally being trained on the same images that are in the test set. So this would be comparable to training using our validation set. It would give us a very good score, but it doesnā€™t really help in any real-world scenario. They are basically exploiting the fact that they know what data the set comes from and choosing a model that starts with that and keeping those activations. I was and still am asking for clarification on whether I actually understand why they are doing so well, but that is what I was asking in my post.

I have tried this, and val_idxs = 0, and also val_idxs = get_cv_idxs(n, val_pct=0.01), but I continue to get an error (below). Does anyone know how to do this reliably?

Should we have one image per class in our validation set?

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-24-0708a7145fb8> in <module>()
----> 1 learn = ConvLearner.pretrained(arch, data, precompute=True, ps=0.5)

~/fastai/courses/dl1/fastai/conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, **kwargs)
     92     def pretrained(cls, f, data, ps=None, xtra_fc=None, xtra_cut=0, **kwargs):
     93         models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg, ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut)
---> 94         return cls(data, models, **kwargs)
     95 
     96     @property

~/fastai/courses/dl1/fastai/conv_learner.py in __init__(self, data, models, precompute, **kwargs)
     85         elif self.metrics is None:
     86             self.metrics = [accuracy_multi] if self.data.is_multi else [accuracy]
---> 87         if precompute: self.save_fc1()
     88         self.freeze()
     89         self.precompute = precompute

~/fastai/courses/dl1/fastai/conv_learner.py in save_fc1(self)
    132         self.fc_data = ImageClassifierData.from_arrays(self.data.path,
    133                 (act, self.data.trn_y), (val_act, self.data.val_y), self.data.bs, classes=self.data.classes,
--> 134                 test = test_act if self.data.test_dl else None, num_workers=8)
    135 
    136     def freeze(self):

~/fastai/courses/dl1/fastai/dataset.py in from_arrays(cls, path, trn, val, bs, tfms, classes, num_workers, test)
    296             ImageClassifierData
    297         """
--> 298         datasets = cls.get_ds(ArraysIndexDataset, trn, val, tfms, test=test)
    299         return cls(path, datasets, bs, num_workers, classes=classes)
    300 

~/fastai/courses/dl1/fastai/dataset.py in get_ds(fn, trn, val, tfms, test, **kwargs)
    264     def get_ds(fn, trn, val, tfms, test=None, **kwargs):
    265         res = [
--> 266             fn(trn[0], trn[1], tfms[0], **kwargs), # train
    267             fn(val[0], val[1], tfms[1], **kwargs), # val
    268             fn(trn[0], trn[1], tfms[1], **kwargs), # fix

~/fastai/courses/dl1/fastai/dataset.py in __init__(self, x, y, transform)
    160     def __init__(self, x, y, transform):
    161         self.x,self.y=x,y
--> 162         assert(len(x)==len(y))
    163         super().__init__(transform)
    164     def get_x(self, i): return self.x[i]

AssertionError:

Can you post your data variable generation too?

PATH = "data/dogbreed/"
arch=resnext101_64
sz=224
bs=64
tfms = tfms_from_model(arch, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
data = ImageClassifierData.from_csv(PATH, ā€˜trainā€™, fā€™{PATH}labels.csvā€™, bs=bs, tfms=tfms,
val_idxs=val_idxs, suffix = ā€˜.jpgā€™, test_name = ā€˜testā€™,
num_workers=4)