Lesson 1 In-Class Discussion ✅

Oxford-IIIT Pet Dataset is downloaded very slowly. The server I am using is easyaiforum, which I suppose is in China.

The solution is here:
https://bbs.easyaiforum.cn/thread-1613-1-1.html

My “throw wet toliet paper at the wall” first try at ML!

I briefly looked at the Fast.AI course last year, real life got in the way, but now I’m back. Going to actually finish it this time.

So I got my Paperspace account running, ran through the first lesson notebook, watched the video, made my own notes etc. Challenged myself to make my own classifier with my own data.

The simplest and quickest thing I could think of was to use the ‘People’ feature in iPhotos to select pictures of my family. I just trusted Apple’s deep learning was correct, (it isn’t) exported the files, made a tar file, then used the ‘Upload’ button on my noteboook. This took about 3 hours with a 330Mb file, so if anyone knows a better way…

I duplicated the lesson 1 book again, then deleted some of the notes

The results are hopeless, as expected, although better than chance, ( a 0.66 error rate?) with a rate of 0.44 ish

It all seemed pretty straightforward really. Fun if not particularly useful.
Even this daft example seems to be able to recognize my daughter apart from her parents. I won’t be submitting this to Kaggle anytime soon, I found it help me understand what was going on much better than just watching the video and clicker Shift-Enter a few times :wink:

2 Likes

@jeremy sir have to save the model in .pt format… i want to build an android app…but can’t do it with .pth format…so please any help??

Hi masudbarki Hope all is well and you are having a jolly day!

I suggest you search this forum using “android” and do some research as many people have asked or researched this question before. It is likely you will have to create .pkl file, convert your .pkl file using ONYX and use TensorFlow before using it Android. This is just one approach.

Cheers mrfabulous1 :smiley: :smiley:

1 Like

Ok sir

Hi masudbarki I saw this link in my travels just now it may be useful.


It may have useful ideas!

Cheers mrfabulous! :smiley: :smiley:

1 Like

I was going to develop a classifier for android using flutter… thanks sir… i converted it to .pt with this tutorial…

1 Like

In <<Lesson 1 - Image Recognition>>, I find "In part 1 of the course, we are always going to be making images square shapes. Part 2, we will learn how to use rectangles as well. ”
Would you please tell me where I can find it? Because the image that I have are all rectangles 1100 * 800.
Thank you!

Hi, I’m following your course and thank you very much for explaining the core concepts of NN in a simple way. I’m currently following the graddesc excel file ( part 1 lecture 5) to understand the momentum and adam. I have a question on calculating the derivatives on “basic SGD” tab. Could you please explain how did you decide the following formulas for derivatives.

de/db=2(ax+b-y)
de/da=x*2(ax+b-y)

Cheers!

lr_find_resnet34

Can anyone tell me the range to choose for learning rate from this image?

I say 8e-6

Depends, feel free to run the lr_finder a second time to get a better idea if you are unsure. lr_finder works by doing 100 samples of learning rates between min and max learning rate. You can get a bit of variation on the graph due to each point on the graph being one batch. Feel free to run lr_finder 5 times or so, as this particular graph is a bit unclear. You will get more of an idea of what to look for as you look at more of these graphs.

One thing that may help you understand is that NNs kind of have to head in the direction that they previously went. So a mistake in learning can affect the next few predictions as well. Your model may have found the wrong direction in the beginning,

Though feel free to just try a bunch of learning rates out when you are learning. It is a valuable learning experience.

What is your batch size? Increasing the batch size may make the lr_finder a bit more stable(just as an idea).

1 Like

Thanks, marri. I run it few times and was able to choose the right learning rates.

Hi folks! I’m running into some trouble following along with the first lecture (using Google Colab).
Here’s what I used to train the model (lecture uses ConvNet, which it seems has been deprecated for cnn_learner):

learn = cnn_learner(data, models.resnet34, metrics=error_rate)

The error rate I get after training one cycle is 0.081191, not 0.061211 like in the lecture. I suppose this could be explained by how the validation set is selected – if it’s random, maybe this is an insignificant difference?

learn_1

However, the confusion matrix also looks completely off:

Thanks for reading this, let me know if you know what I might be missing, or what I could try next to debug?

Hi Nish,

Could you please share your code where you create the data bunch? Also, did you use .show_batch() and check the input images?

1 Like

Thanks, here’s the code from the beginning to where the data bunch is created. I did do show_batch() and it displayed pictures of cats and dogs, but they weren’t the exact same ones in the lecture.

%reload_ext autoreload
%autoreload 2
%matplotlib inline

from fastai.vision import *
from fastai.metrics import error_rate


bs = 64
path = untar_data(URLs.PETS); path
path_anno = path/'annotations'
path_img = path/'images'
fnames = get_image_files(path_img)
np.random.seed(2)
pat = r'/([^/]+)_\d+.jpg$'
data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=bs).normalize(imagenet_stats)```

Hmm. The result and the matrix seem contradictory.
We can live with the fact that the model does not give a 0.06% error rate with just the initial 4 epochs. We can get the error rate down by fine tuning. Also your train_loss <valid_loss implies that the model is likely underfitting and the error rate can come down with a bit of fine tuning.

But your confusion matrix does not support your error rates at all. Share the entire code here and let’s take a look at what’s happening. And yea, the valid sets are randomly chosen so your error rates might not be similar to the one that Jeremy showed. More concerning is the confusion matrix.

Also try using plot_top_losses and check if that matches with your confusion matrix. Or if you have the top losses images please post them here and let’s take a look at what’s happening

I adopted the exact same approach. I downloaded a bunch of faces from google that depicted various emotions and tried to train it to detect emotions. As expected, it was a hilarious disaster :stuck_out_tongue:

However, playing around with the code and exploring it did make me a better learner. Every time I visit the lectures, I understand a bit more about what’s going on. An nice journey I would say :slight_smile:

Thanks for looking! So…I tried to re-run the exact same notebook, and the error didn’t reproduce. ¯\_(ツ)_/¯

In any case, here’s the notebook I used. It should be the same code that produced the matrix in my previous comment but…it’s not doing that anymore.