Lesson 2 In-Class Discussion ✅

Hi,

The video and notes supposed to be this but the latest notebook gone astray hence I do not understand anything aboutt he codes as per image. I’m just showing that it’s different.

Why is there a difference?

from fastai.widgets import *

losses,idxs = interp.top_losses()
top_loss_paths = data.valid_ds.x[idxs]
fd = FileDeleter(file_paths=top_loss_paths)
1 Like

Looks like lesson2-download.ipynb is not accessbale at the moment

I didn’t understand this, can someone fix this…

Same problem here :woman_shrugging:

Looks like one of the latest commit screwed up the file.
The June 17th version works fine, you can get it
here

Hello, first post (on Lesson 2) hope it’s in the right place.

Subject: extra ‘meta’ category

In the original notebook for lesson2-download, there are 3 classes [‘teddys’,‘grizzly’,‘black’].

I did something similar for birds [‘chickadee’,‘titmouse’,‘squirrel’]. The first time I worked through the notebook, everything went fine and it was able to correctly recognize my own image of a squirrel.

Today, I re-ran everything from scratch, and the line…

    data.classes, data.c, len(data.train_ds), len(data.valid_ds)

…outputs 4 classes including ‘birds’ as follows:

    (['birds', 'chickadee', 'squirrel', 'titmouse'], 4, 668, 166)

I’m trying to figure out where the 4th class ‘birds’ is coming from. My image folders are in a parent folder named ‘birds’ and I see that the function ImageDataBunch.from_folder() seems to work from a folder hierarchy. So I’m assuming it’s coming from that. But I am unable to pinpoint the exact cause.

Any thoughts as to why it’s picking up the additional class?

thanks…

Hi tlo hope you are well.
Have you checked the number of directories in your birds directory.
I had a similar error when I created an extra directory by mistake.
This could have occurred if the path was set to birds already when you ran the folder creation sections of the notebook.

Hope this helps.

Cheers mrfabulous1 :smiley::smiley:

Hello,

I’ve downloaded a set of images and run the learner on them. I was wondering if anybody can offer advice on interpreting my output, please?

For example, the error_rate is a lot higher than Jeremy achieves in the video:

epoch train_loss valid_loss error_rate time
0 0.951382 0.608161 0.320000 05:52
1 0.694428 0.545576 0.226667 06:02
2 0.588916 0.507074 0.186667 05:38
3 0.515374 0.431648 0.160000 05:44

My learning rate looks iffy too:

Are my images of poor quality or too similar? I would be very grateful for any assistance.

Cheers.

I don’t know if this will be helpful to anyone, but I had some hiccups downloading images (I’m running a Pixelbook so that may be the cause) with the provided javascript, and figured out a fix.
I was hitting: Not allowed to navigate top frame to data URL: which I believe is coming from some chrome security for XSS or the like. I ended up modifying the script like so:

function debugBase64(base64URL){
    var win = window.open();
    win.document.write('<iframe src="' + base64URL  + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
}


urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
debugBase64('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));

Source of debugBase64 function

1 Like

I used the techniques from lesson 2 to create https://floret-finder.onrender.com/ to help those of use who can’t distinguish between broccoli, cauliflower, and romanesco (my favorite). Enjoy!

I am getting this error:
AttributeError: ‘NoneType’ object has no attribute ‘detach’
on every epoch end with learn.fit()…
any suggestions? have been stuck for a while…

AttributeError Traceback (most recent call last)
in ()
----> 1 learn.fit(2)

6 frames
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in on_batch_end(self, last_output, last_target, **kwargs)
347 dist.all_reduce(val, op=dist.ReduceOp.SUM)
348 val /= self.world
–> 349 self.val += first_el(last_target).size(0) * val.detach().cpu()
350
351 def on_epoch_end(self, last_metrics, **kwargs):

AttributeError: ‘NoneType’ object has no attribute ‘detach’

I have the same problem and it really causes me to have a hard time understanding what is going on, feeling quite lost when notebook material is different from what is being taught at the lesson

They upgraded the cleaner so you can delete and change the label with just one widget.

It’s pretty much just two lines now.

ds, idxs = DatasetFormatter().from_toplosses(learn)
ImageCleaner(ds, idxs, path)

In case of too many epochs what’s happening is till a point of time the error rate will decrease but as your number of epochs is too high the model will unable to further decrease that error rate so after that it starts to learn the noises too which make the model less generalize which leads to overfitting.

I have a silly question which bothered me when I applied lesson 2 to my own dataset.

I was retraining the model many times on the same amount of data. I found that many times, the Learning rate finder gave different graphs. Sometimes they were straight forward, you could easily find out a long lasting downward slope of losses. Other times, the slope was not always decreasing, it either remained the same or kept increasing (as in , the loss either stayed the same or increased but it never decreased ).

My question is - If the data is the same, why should the Learning rate finder return a different curve ?

One thing to note is that, by retraining I actually mean re running the Notebook. So perhaps, a different set of images is grouped into the training and validation sets ? Is that right ?

Web service link for my classifier

Detailed blog post on my model published on Medium.com

Thanks,
Varun

Hi warun hope you are well!
I believe this occurs, as when you train a model in lesson 2, the data is randomly chosen from the training set to train the model. However the validation set data is kept constant by using a seed value. This random selection causes the learning rate to change in different ways, when you retrain the model.

Nice Medium Post
Cheers mrfabulous1 :smiley::smiley:

Hi @mrfabulous1, thanks for your answer. :slight_smile:

Hi,
I was trying to deploy web app to Heroku[free-tier]. After compilation my slug size is 936MB.
Which is more than maximum limit 500MB. Pytorch is taking about 734MB. If anyone has successfully deployed his/her web app in Heroku please share your experience.

1 Like

A lot of the time your error will be a good amount higher than what jeremy achieves in the video, partially depending on your data. But it also looks like the time it is taking is really long, 5-6 minutes per epoch is a pretty long time, I would experiment with a higher learning rate to reduce the wait time. Also I would recommend running for more epochs, you should try to increase your number of epochs until your training loss is lower than your valid loss.