Lesson 1 In-Class Discussion ✅

I tried it with clouderizer, it worked well…

Yes, this is what is suggested in"returning to work" page of FastAI.

1 Like

I’ve done lesson 1 so the model is sufficiently trained around 6% error rate and thought it would be fun to throw in a picture of my own cat, to see what race the NN think she is.

How would I do this? I don’t want to retrain the network or anything, but rather put the pretrained model to practical use.

Hi @imago,
You’ll be doing exactly that in Lesson 2 (see section on putting it in production)
but for a quick preview you can run the following in a cell

img = open_image(path/to/your/cat/image)
img # to show your cat image
pred_class,pred_idx,outputs = learn.predict(img)
pred_class # what breed your cat is 

HTH.
Best regards,
Butch

1 Like

Hi, I am running through a lesson 1 notebook using the latest version and I see strange images when I run interp.plot_top_losses, see attached. These look like they could be augmented images. But then I would expect that augmentation would not be applied to these as they are validation images?

Ah got it, there is a parameter ‘heatmap’.

Thanks @Saeedeh it worked, I had that line before but didn’t seem to work then

@jeremy, hi, I have a question, why are we interested in training a whole RESNET34 model, when our model was working already good before?

Hey everyone,

I have a doubt about 1Cycle, this part in special:

learn.fit_one_cycle(2, max_lr=slice(1e-6,1e-4))
You use this keyword in Python called slice and that can take a start value and a stop value and basically what this says is train the very first layers at a learning rate of 1e-6, and the very last layers at a rate of 1e-4, and distribute all the other layers across that (i.e. between those two values equally).

Could someone explain what @jeremy meant by that?

From what I have read (from the paper and here https://sgugger.github.io/the-1cycle-policy.html#the-1cycle-policy) the range applies to the entire network, and not just some layers. The learning rate will increase from time to time on the first step, then will decrease on the second. Am I missing something?

Thanks!

Hey, my guess that he is trying to

  1. show that was possible
  2. show how to fine tune it and
  3. is trying to fit the whole resnet34 model for this specific problem (i.e trying to detect breeds of dogs and cats), since it is really generic (i.e can detect a lot of shapes).

Hope it helps

In the lesson its said that it takes 2 minutes to train the data set using fastai for 4 epochs im using google colab and its been 30 minutes and still my first epoch is not finished :frowning:

Sorry, I forgot to enable GPU in the run time, Now its fast! <3

Hi,

I just did lesson 1 and I am trying to apply the learn.predict() function to some self-made images to test the model.
I tried to understand how the predict function works but it is really complicated. What does the reconstruct function exactly do? And what is an Itembase?

Thanks for your answer!

Hi Emma,

You should try the second lesson (which I didn’t finish it yet). It will answer some of your questions.

Hope it helps.

-Mario

When I print ImageDataBunch, I get the following:

ImageDataBunch;

Train: LabelList (5912 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
great_pyrenees,keeshond,yorkshire_terrier,keeshond,pug
Path: /notebooks/course-v3/nbs/dl1/data/oxford-iiit-pet/images;

Valid: LabelList (1478 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
Abyssinian,Siamese,Siamese,american_pit_bull_terrier,samoyed
Path: /notebooks/course-v3/nbs/dl1/data/oxford-iiit-pet/images;

Test: None

What is a Category List? Why are there only 5 images in each?

Where is the error_rate defined and what does this mean?

&lt;function fastai.metrics.error_rate(input:torch.Tensor, targs:torch.Tensor) -&gt; &lt;function NewType.&lt;locals&gt;.new_type at 0x7fbdee5831e0&gt;&gt;

After running this interp.plot_top_losses(9, figsize=(15,11)) and looking at the docs, it says probability of predicted class…what does that mean?

Hi Timothy,

On your first question: The category list seems to be the classes (in this case the breed). I don’t think it prints the whole list, my guess it is just a preview.

About the error_rate, I think this topic is covered in lesson two. He will talk about the metrics and etc.

If I am not mistaken, the top losses cover the images in which the net predict to be another class. The output of the net, in this example, is the probability that an image belongs to each class. A loss occurs when the net predict the wrong class for an image, i.e. outputs a higher probability to the wrong class.

You should move on to the next lesson, as it will clarify many of theses topics.

Hope it helps.

-Mario

Hey y’all, so I know Jeremy wants us to get straight to the meat of this and start running models (but I don’t know how to code (yet!) and while I’m in the process of teaching myself, I’m trying to understand the basics of this course).

Essentially this is what my basic understanding is. I know it’s not completely correct, hence this post to ask for y’alls feedback to try and correct it and fill in the blanks.

So we’re loading up a pretrained model by calling one of the resnets (generally starting with 34) and using its pretrained weights (i.e. taking advantage of transfer learning). Then we are taking another set of images that we have (in this case the animal pics given), and dividing them out into a training set and validation set (generally 20% is what we use for our validation set). We take the training set, which should have correct labels / classifiers identifying the images, and run those through our model. We assign a set number of epochs to it; let’s say 4. So in running the model through these epochs, after the first epoch, the model has gone through all of the images once and tried to guess what they are based on what it already knows from its pretrained resnet info.

This is where I think I’m not really clear what happens… I don’t think the below is correct but I’ll put one of my guesses and if someone could clarify I’d truly appreciate it!

The model then compares what it guessed against what the images actually are (based on the fed image’s given labels – in this case the animal pics that we have) and that is how we are able to calculate our training loss. Knowing what it got right and wrong after the first epoch, our model then adjusts its weights to try and autocorrect, and then runs through the second epoch. It compares its findings again with what the images are actually labeled, rates its performance by spitting out its training loss, adjusts its weights and then runs through the 3rd epoch. It does the same thing until its done running through all of its epochs in the training set. After all the epochs of the training set have been run, the validation set is then run through the model.

I’m going to stop there now as I guess my biggest question is if the model is being given the correct labels after each epoch to self-correct…

What you described is correct. 1 epoch is 1 forward propagation + 1 back propagation. The model based on its weights in each layer outputs a label which can be right/wrong. During back propagation, our model adjusts the weights based on the output.

Based on what I understand from this, yes we are giving the data which is labelled by us. That means the correctness of the training data depends on the accuracy of our labelling.