Lesson 1 In-Class Discussion ✅

sir iam working on image classification project. it will see the hand gestures and will tell the the number the hand is showing. suppose if there is an image of hand with three fingers then it will tell us 3. have my own dataset in my a folder called HANDS. In That folder there are 10 folders.
folder 1 contains hand images related to gesture 1. Folder 2 contains hand images related to gesture 2. and so on upto 10 folders. So please tell me how can i provide folders the path to the jupyter notebook.

hello @colawhite ,
I think the heatmap option is set to “True” which is a default option.You can turn it off like the example below,
interp.plot_top_losses(9, figsize=(15,11),heatmap=False)

Why is more efficient for calculation

it takes too long time to train 5 GB dataset (food 101) on google colab. I don’t know if it’s okay speed of a training. Is there a way to check it?

Hi @amallya, did you fix this?

I compressed my dataset by 7z on a tar and then on a gzip, the path of my file stayed like this: https://s3-sa-east-1.amazonaws.com/amazons3meurango/fastai/dataset.tar.gz

And when I run

url = “https://s3-sa-east-1.amazonaws.com/amazons3meurango/fastai
path2 = untar_data(url)

I encounter the same issue: ReadError: not a gzip file

Hi @amiaram, Short answer is no. But these links might help you - Untar_data requires .tgz file ending
and https://github.com/fastai/fastai/issues/1130
I was working on a sagemaker notebook instance at that time. And in couple of days, that somehow stopped opening and I ended up working on different dataset in different notebook instance.

1 Like

Hi, thanks for the reply.

I found a solution in the Kishore Iyer post link Untar_data requires .tgz file ending

He had been missing many hours in that. One more time, thank you.

1 Like

Hi, Is there a way to retrieve the digits dataset in Kaggle with ImageDataBunch?
train.csv :

Hi I created a classifier and i use the learn.predict() to get the prediction.
If i try to predict a garbage photo of something not of one of the classes it still returns an answer.
I can see that the output losses is vector that sums to 1.
Is there a way to know if the classifier has chosen a class, but has very low confidence that it is right?

Hi,

predict” gives you the predicted probabilities (not the losses), which is why they sum to 1. So, yes, it should hopefully give you low values (i.e. low confidence) for class predictions if you input a garbage photo that is not of any of your model classes. Assuming your model was decently trained, of course : )

See the docs (I linked to it above) for more info.

Yijin

Hi, I just started working through lesson 1 and am confused by something in the notebook https://github.com/fastai/course-v3/blob/master/nbs/dl1/lesson1-pets.ipynb

after the first call to learn.fit_one_cycle(4), the first valid_loss is .357608 and after

learn.unfreeze()
learn.fit_one_cycle(1)

the notebook has a valid_loss of 0.314579 . now isn’t the valid_loss better after unfreezing? If so, I dont understand since unfreezing would loose all the resnet weights as described in about 1hr 20m of https://course.fast.ai/videos/?lesson=1?

1 Like

Hi all,

What is the SOTA accuracy for the Oxford Pet dataset?

I am not sure if I am correct, but unfreezing logically should not change the weights to random numbers. It should make it possible to use the RESNET weights as a base point and then retrain the model (so, even after one epoch you may see improvement).

1 Like

Hello fastai community,
I am struggling around this issue. I have looked up in the forums but don’t seem to find a solution for that.
I have trained a model which I properly saved in ‘/data/models/’ folder. Restarting the kernel and attempting to load the saved model: learn.load(‘model_name’) tells me: NameError: name ‘learn’ is not defined .

How to load that model without retraining it from the very start ?

Thank you in advance.

I finally came across a solution for this here. I reloaded my data paths, created a learn object which allowed me to load the previously saved weights.

I trained “food 101” on Google Cloud Platform (Tesla P4 GPU). Took like ~7,5 min/epoch.

Hi, I am struggling about how to upload and prepare my dataset. I tried a few different ways but encountered different problems. Can anyone tell me how to solve these?

Q1) When I use another link from fastai dataset, an attribute error showed up. I tried untar_data(url=‘http…food-101.tgz’) but another error (not a gzip file) appeared.

SOLVED by removing .tgz at the back , referring to untar-data-requires-tgz-file-ending

https://colab.research.google.com/drive/1EFZDzaOECuZ23WPbJkBxzLuTh3Tbj-ov#scrollTo=BBHv5M-AKjtw

https://colab.research.google.com/drive/1EFZDzaOECuZ23WPbJkBxzLuTh3Tbj-ov#scrollTo=GDIMUGk19cO8&line=2&uniqifier=1

FOODS=‘https://s3.amazonaws.com/fast-ai-imageclas/food-101.tgz
path = untar_data(URLs.FOODS)
path

AttributeError Traceback (most recent call last)

<ipython-input-4-1bee2d7d1f5a> in <module>() 1 FOODS=‘https://s3.amazonaws.com/fast-ai-imageclas/food-101.tgz’ ----> 2 path = untar_data(URLs.FOODS) 3 path

AttributeError: type object ‘URLs’ has no attribute ‘FOODS’

Q2) I prepared my own dataset with google image download as suggested in another thread. But i had a hard time uploading it to Colab. After uploading the file to google drive, I tried the code snippet in colab to import data from google drive. I ended up with a GoogleDriveFile which is not directly usable. What should I do next?

I used path = Path(root_dir + ‘Colab Notebooks/CatCategoryDS’) to solve the problem. But i would love to know if anyone know how to handle GoogleDriveFile. Thanks!

https://colab.research.google.com/drive/1MqXO3LphjIUAEtNmI3LTm7Bsf7W_-l-A#scrollTo=rlei-h2bYcSQ&line=8&uniqifier=1

Q3) I feel like I need a lot of practice and learning in data preparation and handling. But I cant find much resources online. Any recommendations??

Thank you so much for the advice!

I have training data in an NPY file whose shape is (814, 440, 440, 1), which consist of 814 images of size 440 x 440 x 1, and the label is an (814, 1) NPY file containing ones and zeroes.
image
image
I used to train this with Keras, using model.fit
image
Is there a way to create a data bunch with the fastai library from these data?

Thank you in advance!

Hello! I am new to lesson 1.

My configuration is Win10+anaconda+python3.7+torch1.0.1+fastai1.0.50.post1+cuda80

After I trained ResNet34 successfully, i try to continue with ResNet50.

By checking the nvidia-smi, the memory is not used:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 398.35                 Driver Version: 398.35                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 960M   WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   47C    P8    N/A /  N/A |     40MiB /  4096MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

But I still came across the following CUDA out of memory

and

Tried to allocate 1024.00 KiB (GPU 0; 4.00 GiB total capacity; 3.08 GiB already allocated; 588.80 KiB free; 12.20 MiB cached)

I tried to reboot and it doesn’t work!

How can i do next? thanks in advance~

Hi, I’m having same issue, implementing a custom metrics about F1 score.
I have
len(data.train_ds) = 750,
len(data.valid_ds) = 250.

In my metrics function, I have at the bottom:
precision = TP/(P + 1e-12)
recall = TP/(CP + 1e-12)
print('prec: ', precision.shape)
print('recall: ', recall.shape)
F1 = 2 * (precision * recall) / (precision + recall + 1e-12)
return torch.Tensor(F1)

During fit_one_cycle() it prints:
prec: (12,)
recall: (12,)
prec: (12,)
recall: (12,)
prec: (11,)
recall: (11,)

And this is the ending part of the output:

/opt/conda/lib/python3.6/site-packages/fastai/callback.py in on_batch_end(self, last_output, last_target, **kwargs)
343 dist.all_reduce(val, op=dist.ReduceOp.SUM)
344 val /= self.world
–> 345 self.val += last_target[0].size(0) * val.detach().cpu()
346
347 def on_epoch_end(self, last_metrics, **kwargs):

RuntimeError: The size of tensor a (12) must match the size of tensor b (13) at non-singleton dimension 0

Any suggestion about how to solve it? ^^