Hi Everyone,
Special thanks to Jeremy for the great class.
I am new to the data science world (started on December 2018), so I decided to dive inside the fastai library, to really understand what’s going on under the hood.
It turns out that if eventually you want to create your own model, or prepare your own data in a non-default way (imagenet style for example), you will need to get to know with datablock API, custom ItemList, create_head(), create_body(), and adaptiveconcatpooling()… And once you start to play with the low level API, you will be shocked how powerful fastai is. 
I want to eventually create my own Siamese network using fastai, (or TripleItemList with anchor / positive / negative). Based on my understanding, this is essential because if you have thousands of classes, Resent accuracy wont be good enough. 1/1000 is a very low probability for guessing, and if you have imbalanced and small dataset,you will have more problem.
(Currently still working on Siamese, and it is far from done and polished to share
)
I used MNIST as my first step to understand custom Item List, so I would like to share to the folks like me new to the fastai and thinking custom Item List is really some advanced stuff (labeled ‘advanced tutorial’ in the doc
, it is really not, and it is very easy to use)
Here is the kaggle kernel for the traditional MNIST dataset
MNIST with transfer learning
The reason I am using MNIST is following:
- It’s a very simple dataset, and very easy to understand
- We talked a lot in the class (lesson 5 and 7)
- It doesn’t work with default fastai transfer learning style (the data is not img file, it is tabular formatted)
If you ever wondering,
Lesson 5, we did use the pixel value as input, but we create dense net from scratch, no transfer learning involved. We pretty much prepared data in Pytorch style: ‘dataloader, dataset’
Lesson 7, we created our own Resnet CNN model, but the data is in img format, not pixel anymore.
What if I want to use ItemList with pixel input so I can take advantage of transfer learning / argumentation and other cool method like predict with TTA?
We will have to create own ItemList.
For the vision part, the call flow like the following:
from_folder(), from_csv(), from_df() all looking for a filename, then eventually calling get(), the get() will call open() to get single Image (Itembase), then you can start split(), label(), transform(), databunch(), normalize()…
In the MNIST example, if you follow the above path, the custom ItemList is simple, you only need to override open(), and leave the rest part to the ImageItemList(), your super() class. (You don’t even need a init() for your custom class).
Another point I would like to share is how easy add_test() can be used instead of add_test_folder()
add_test() takes an ItemList iterator, when you want to add the test-set after training, you can simply call add_test(CustomItemList.from_df()), you don’t need to override anything, fastai takes care for you.
The computer vision path seems fascinating to me at the moment,
Identify cat / dog -> Identify Species --> Identify Large class (1000+) —> Identify Large class with multiple items in one image
Really looking for part 2 for the bounding box explanation, so I can further my identification project to more than 1 item in single image 