Lesson 2: further discussion ✅

maybe your can try set your databunch again,increase ds

Hi everyone,

I am trying to create a classifier that differentiates between pics of Sachin and Virat. I am following the steps taught by Jeremy in Lecture 2. I have a doubt regarding one of the steps output:

When I unfreeze the resnet34 model and run lr_find() on the learner, I get #na# in the valid_loss (attaching a pic as well).

I have divided the dataset into 80% training, 20% validation (valid_ptc = 0.2). While running 4 epochs on the pretrained model using my dataset (228 training images, 56 validation), I get this:

54

When I unfreeze the model and run lr_find(), I get this type of output (#na# in the valid_loss):

Can someone please explain why this is happening?

I have the same problem, I am using kaggle and the files are on my pc

Hi,

When attempting to use plot_top_losses within the lesson 2 download notebook, I get the following error:

AttributeError: ‘ImageList’ object has no attribute ‘cat_names’

This error is detailed here: Plot_top_losses() throwing "AttributeError: 'ImageList' object has no attribute 'cat_names'"

Could anyone suggest solutions or work arounds?

Thanks!

I have some trouble using download_images when behind a proxy.
Looking at download_images source code, it looks like it is using urllib. I tried to setup my proxy but without any success.

Any help on that matter will be much appreciated :wink:

Here is an example of error message
Error https://www.nationalgeographic.com/content/dam/animals/pictures/mammals/a/american-black-bear/american-black-bear.JPG HTTPSConnectionPool(host='www.nationalgeographic.com', port=443): Read timed out. (read timeout=4)Error https://www.rei.com/dam/ygh_101016_006_backpacking_in_bear_country_lg.jpgHTTPSConnectionPool(host='www.rei.com', port=443): Read timed out. (read timeout=4)

And a test on proxy setup

import urllib.request
proxy_support = urllib.request.ProxyHandler({'http' : 'http://myproxy:80', 
                                         'https': 'https://myproxy:80'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
response = urllib.request.urlopen('https://python.org/')
html = response.read()
print(html)

Hello All,

I was wondering if its possible to do image classification in two stages similar to the problem discussed by @Rohitagarwal257 described here multi-level image classification.

Briefly, i’m trying to train a model in multi-stages where stage 1 model identifies an item to a category and base on the outcome

stage 2 proceeds to do a identification within each group seperated by stage 1 into sub-categories… i.e. the outcomes in stage one determines the outcome in stage 2.

Hi,
Need some help with lr_find function on Colab. I am trying to do lesson 2 of the fast ai course - https://course.fast.ai/videos/?lesson=2
I picked 3 items - forks ladles and spoons (attached). I ran the download images, stored and verified them. This is all fine.

Ran fit one cycle cnn through it, which gave some numbers.

The next steps ask you to unfreeze the model, and run a learning rate finder through it. Here is where I get stuck. Instead of giving me some numbers and a graph it gives me #na#.

I’ve tried below with start and end lr.

I’ve also removed those parameters, and tried just lr_find()
image

Please help :slight_smile:

Took the SGD part of Lesson 2 and expanded it to polynomials. Made a few minor changes nothing special, but I was kind of proud of myself. :sweat_smile:

Hi, i tried lesson 2 sgd and i get this error.
Someone please explain what is wrong?

How can I see the CV loss and error rate of my model after exporting (learn.export())? My desire is to see statistically how my model would perform (for e.g. on my CV set), instead of predicting with my model one picture at a time.

Hi All - I am a newbie here and am aware of the limitations of running the ImageCleaner on the JupyterLab code base. ImageCleaner appears to be an absolutely fantastic tool and I would love to run it in Jupyter Notebooks (proper).

However, I am running the Fastai library on the OnePanel platform to gain access to a GPU, and OnePanel seems to be firmly married to the JupyterLab code base.

I could not find an obvious way to launch a notebook session with the older widget-compatible “Jupiter Notebook” code that allegedly does support widgets properly and, hence, ImageCleaner.

I imagine mine is likely a rather naive question, but I have been trying to figure this out on my own, both within the Fastai forum and via StackOverflow and have hit a rather considerable wall.

Any help would be greatly appreciated.

After the training part I added these these lines to my code and I got the below error can someone please tell me what’s the issue here

learn.save(‘stage-2’)
learn_cln.load(‘stage-2’)
ds, idxs = DatasetFormatter().from_toplosses(learn_cln)
ImageCleaner(ds, idxs, path)


RuntimeError Traceback (most recent call last)
in
----> 1 learn_cln.load(‘stage-2’)
2 ds, idxs = DatasetFormatter().from_toplosses(learn_cln)
3 ImageCleaner(ds, idxs, path)

~/anaconda3/envs/object_rec/lib/python3.7/site-packages/fastai/basic_train.py in load(self, file, device, strict, with_opt, purge, remove_module)
271 model_state = state[‘model’]
272 if remove_module: model_state = remove_module_load(model_state)
–> 273 get_model(self.model).load_state_dict(model_state, strict=strict)
274 if ifnone(with_opt,True):
275 if not hasattr(self, ‘opt’): self.create_opt(defaults.lr, self.wd)

~/anaconda3/envs/object_rec/lib/python3.7/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
828 if len(error_msgs) > 0:
829 raise RuntimeError(‘Error(s) in loading state_dict for {}:\n\t{}’.format(
–> 830 self.class.name, “\n\t”.join(error_msgs)))
831 return _IncompatibleKeys(missing_keys, unexpected_keys)
832

RuntimeError: Error(s) in loading state_dict for Sequential:
size mismatch for 1.8.weight: copying a param with shape torch.Size([10, 512]) from checkpoint, the shape in current model is torch.Size([11, 512]).
size mismatch for 1.8.bias: copying a param with shape torch.Size([10]) from checkpoint, the shape in current model is torch.Size([11]).

How do you solve the problem when your downoad the url files?

I was trying to download “teddy bear” urls into file in chome. But it turned out that there is nothing in the file downloaded.

This didn’t work for me in Chrome too so I used Firefox. I believe had to change something in the about:config but I can’t remember why or what.

They removed FileDeleter. It’s now called ImageCleaner. But this widget doesn’t work in Colab. There is an alternative widget: The File_Deleter Widget

You can just install it with !git clone https://github.com/muellerzr/ClassConfusion.git in Colab.

But it’s also suboptimal because sometimes it works and sometimes it doesn’t show anything. :slight_smile:

2 Likes

Any chance you could provide an example of it not showing anything? I’ll gladly look into it :slight_smile: (or put an issue into the GitHub too :wink: )

Right now I moved on to image segmentation but I will put an issue into the GitHub if I find an example. And thanks for building this! :slight_smile:

On some paper (update: https://arxiv.org/pdf/1803.09820 ) I saw a picture that explained it very well. I’ll paste some here that provide the same message.

image
https://zahidhasan.github.io/img/bias_variance6.png


https://forums.fast.ai/uploads/default/original/2X/5/57b24adcaf41ec93767e692094f00369a4f2e6fb.jpg

image
https://www.researchgate.net/profile/Cristiano_Ballabio/publication/222344717/figure/fig3/AS:325003603136513@1454498305120/Training-error-and-cross-validation-error-as-a-function-of-model-complexity.png

Too little training: underfitting
Too much training: overfitting
But that is the case if the network is “deep” enough to learn from the data. With “deep” I mean of a suitable architecture to be able to perform well.

If the network is too small, it won’t be able to predict accurately.
If the network is too big, you will need to apply regularization as it will be very capable of just “memorizing” the training set.

(Just my view)

lr_find
It spits out the validation error (prediction error against the validation set).

If there is no validation set, then there is no error to calculate.

Most probably you loaded the images without specifying a % to be used for validation. We do that (0% validation) on the stage when we want to ‘clean’ the dataset, so we work with all the images, not just training.