Part 1 (2020) - Weekly Beginner Only Review and Q&A

Hi! I am also experimenting with binder. Locally it works perfectly. I could even load my classifier.pkl from a gdrive-folder. But when I try to use binder my requirements.txt seem to be a problem.

aiofiles==0.4.0
aiohttp==3.6.2
-e git+https://github.com/fastai/fastai2@4ac2d8913a5094fb15489f4b80296b9429330b8e#egg=fastai2
ipykernel==5.1.4
ipython==7.12.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
torch==1.3.1
torchvision==0.4.2

When I run the notebook on binder, this error occures:

ModuleNotFoundError: No module named ā€˜fastai2.callback.coreā€™

How do you install the fastai framework for binder?

I think you need to include fastai2 in your requirements file. something like

fastai2==0.0.15

ā€¦ or whatever version you built your model against.

1 Like

Put it in between three backticks (look top-left on your keyboard most likely) = ```

You want to put them on one line

Next line(s) is your code

Last line is another of the three backticks

1 Like

Thanks Wayde. Iā€™m trying this now on paperspace, which may not work. Is this the right way to interpret your postā€¦?

I usually just run them locally (Iā€™m on a macbook pro) and then I upload them to my dl-rig.

If paperspace allows you to upload files, Iā€™d go that route.

1 Like

I am hitting the same issue, Were you able to get this to work? If so, please share your approach that worked ?

2 Likes

Thanks! Now it works! But I can only access the notebook itself. When I use the url /voila/render/saab-classifier-voila.ipynb I get a 404 error page. Did anyone manage to run the voila app?

1 Like

Below are some questions which I haveā€¦

  1. What was the reason behind creation of class L . If it is only behaving like list of items, its getting used at multiple places.

  2. how many augmented images are created by function batch_tfms=aug_transforms.

  3. After randomly splitting dev and train set. I did ImageClassifierCleaner on my cnn_learner and validation set had a white bear marked as black.
    My question is ā€œHow big will be the impact if we donā€™t curate our validation set correctly.ā€ ?
    We are not training our model on validation set but since loss is computed on validation set.

  4. I am getting error ā€œAttributeError: Canā€™t pickle local object ā€˜Learner.get_predsā€¦ā€™ā€
    on learn.export(), did anyone encounter the same ?

Just an update:

  1. Added the week 3 video link above.

  2. Posted my inaugural 2020 article on how cross-entropy loss works here. Was going to cover this last Thursday but we ran out of time. Anyways, given that weā€™re learning about loss functions I figured it would be good to do an intro on how the one weā€™ve been using since week 1 works. Itā€™s meant to run in colab so you can tinker with it ā€¦ I just havenā€™t figured out how to get the collab badge to show up yet :slight_smile:

-wg

1 Like

Lmk if this is still outstanding or if youā€™ve solved the issue based on the replies above. If itā€™s the former, Iā€™ll try walking through the binder steps myself.

I having a similar issue, it would be great next time to make this deployment demo if possible with git lfs @wgpubs if possible. looking forward to next week

1 Like

Jeremy did talk about DataBlock and DataLoaders. However, the basic concept of other mid level APIs are not very clear to me. I would like to know understand the concepts behind Transforms, TfmdList, Pipeline, DataSource etc. I understand there is a Mid-Level API thread ā€“ however most discussions there seem to be for non beginners. Are there intro tutorials behind the basic idea re these constructs. I tried following Jeremyā€™s Walk Through tutorials on Youtube ā€“ but they are often very long and difficult to filter down to the information we might need. Any explanations / pointers to blogs / notebooks will be very helpful.

2 Likes

This question is re increasing the dataset size. I recall Jeremy mentioned in the 2nd / 3rd lesson one way to improve accuracy was to increase the training data size by using low resolution / subsampled images of the training data and train the first few layers of the CNN using those. And then use the actual training images on top of that. Are there examples of such ? Does FastAI already have libraries to increase the training set size. I know there is a aug_transform ā€“ which is supposed to Augment the size of the data by generating different transforms at different epochs. But is it the same thing ? Or is my understanding of this concept not right ?

2 Likes

Thatā€™s a great idea for this Thursdays study group.

In addition to going over deployment, Iā€™ll walk thru the entire data stack. If you are new to fastai then I wouldnā€™t spend much time on the early walk thrus Jeremy did last year (itā€™s likely to be more confusing and distracting at this point). What we go over Thursday will be encapsulated in a blog post as well as recorded.

1 Like

I think he was referencing the idea of increasing the size of the images progressively, not their number.

We can look at this on Thursday as well, but the idea here is that you can start with small images so you can train your network fast and get better than random weights. From there you can increase your image size (for example, go from 64x64 to 128x128) and use your already trained model just like any other pretrained model. Keep doing this until you get the desired results or reach the limitations of your gpu.

muchas gracias!

Does that mean running a full training / eval cycle with say 64x64 and use that as the base model for transfer learning for the 128x128 full training cycle and then progressively keep on using 256x256 and so on ?
Thanks for your help!

1 Like

Yup, you got it.

Just a reminder that weā€™ll be starting at 6:30pm PST.

Looking at the posts on this thread and in the official discussions, it seems that there is a lot of confusion and interest about these two topics in particular:

  1. Deployment

  2. The DataBlock API (how it works, how it relates to the low and mid-level data APIs, the differences between them, which you should choose, and so forth).

Weā€™ll start with the later as its foundational to everything, including deployment. I plan on providing a preview of the first installment of my updated ā€œFinding DataBlock Nirvanaā€ and walking though a bunch of code that you too will be able to run once this beast of an article is published.

See yā€™all soon.

-wg

1 Like

This came up in tonightā€™s session so thought Iā€™d share the answer here:

What is the difference between collate_fn and item_tfms?

A function can be passed to the collate_fn argument of a DataLoader. According to the PyTorch docs, ā€œthe function passed as the collate_fn argument is used to collate lists of samples into batches.ā€

So as someone said in the study, yes, the collate_fn is responsible for creating a mini-batch given a list of items. So whatā€™s the difference?

item_tfms are applied whenever we get ā€œanā€ item ā€¦ whereas the collate_fn operates on a ā€œlistā€ of items. Not 100% sure, but I think that is the primary difference.

So ā€¦

Iā€™m not sure, but I donā€™t see any reason why the resize operation, usually specified as an item_tfm, couldnā€™t be done in a custom collate_fn.

Am I right on that? Assuming I am, what are the pros and cons of each approach when it comes to things like resizing images?

For text modeling, I know we use the collate_fn because the text documents only need to be the same size per batch (made the size of the longest document via padding). This can only happen once you have a ā€œlistā€ of items to work with and so it makes sense to do that for text data.

Thoughts?