The only real trick I used was to sample an equal number of images from each class, and resampling between fits.
Even though I got 80% accuracy in validation, I only got around 50% in the real world. One reason for this is my photos are different to professionally taken photos from the internet (lighting, obstructions, etc), another is that not all cars are equally likely to be seen. Something to keep in mind if your production data is going to be different to your training data.
Hi fellow course-mates and @jeremy ,
Has anyone seen this weird error while running Jeremy’s Collab nb? I updated all of the packages before running the notebook, but it still gives this error.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-86fc5648604f> in <module>
----> 1 data = CollabDataBunch.from_df(ratings, seed=42)
NameError: name 'CollabDataBunch' is not defined
Hi @avinashj,
thanks for the compliment! I actually did work a bit further on the project, specifically on the leaves from the category “NaturalBackground” which would be similar to your dataset.
My idea is to use the model I trained on the “SheetAsBackground” data with fastai and apply transfer learning to it, in order to train the model with the “NaturalBackground” images.
This seems not to work out of the box with fast.ai, as there are not 124 classes but instead 51 classes in the new dataset. I found a way to solve this problem with the help of @PierreO, see how it is done here.
I guess you could take my model and use transfer learning with your own dataset. Let me know how it goes!
Thanks for the detailed explanation and the notebook. Yes, that was what I was thinking of.
I along with my friends trying to come up with a model to identify native Indian plants which will be helpful for ecologist working in India.
I’ll post here once I proceed further with my work.
Regards
@sparalic I think you should simply re-run the cell where you have from fastai.collab import * to import everything in there including CollabDataBunch.
Thank you @bachir, but it seems like my symlinks are all messed up so my nb was not pulling the fastai modules from the correct path. Unfortunately, I went around it using the annoying sys.path.append('../fastai') trick.
I wrote a few words answering the questions “what are pretrained models?” In some sense, I have taken pretrained models for granted to the point where when someone asked me what they were, I miserably stumbled.
I am not sure this can be very useful to anyone taking this course but having been asked the question made me realize that hey, probably for people who have not taken this course or who are not planning to write code but would be interested in learning about the field, this could be quite helpful.
Anyhow, there is also a bit of chewbacca vs yoda classification going on and again I am amazed at how much one can do with the fastai library with so little code!
I used jupyter nbconvert (it can also convert notebooks to other formats, such as pdf). Here is a bit more information on the exact steps that I took (there is also serving from github pages involved).
For the object verification problem with new category I have posted last time, I change the technique used from binarizing the last layer to multi variate gaussian anomaly detection and the results is so much better. I have written it here: Object verification with new category added to model
The idea is we can based on the statistic of the features vector to calculate the probability of matching object. The multivariate gaussian anomaly detection is introduced in Andrew Ng course and summarized here: gaussian anomaly detection . I have changed a little bit from the original algorithms that I calculate the logarithm of probability because with high number of variables (128), the results can be too big or too small. Ex: Ex: 48 variables with 0.1 probability for each. The multivariate probability is 0.1⁴⁸ — Very small number
The histogram of probability of number 7 (which have the worst result from last time) and number 9 are below:
Number 7
The probability of number 9 is much higher than number 7 this time. (I don’t know why the probability calculated by multivariate_normal . pdf in python > 1 , but I think the concept is the same so it is not a big deal)
p/s: I haven’t tried the auto-encoder yet. I still think that the classification training will create a better feature vector to differentiate different object
I trained a Language Model for arabic on a subset of sentences (I think 100000) from Wikipedia dump. the total dump is around 5GB, I trained on one file of 160MB, I couldn’t do more as even such small dataset collab kernel was on the edge! Also even with such small dataset the training took 3h!!
Unfortunately, the dataset is highly biased. I used the default data augmentation settings + vertical flipping to mitigate these issues. More work can be done here.
nv 67%
mel 11%
bkl 11%
bcc 5%
Other (3) 6%
get_transforms(flip_vert=True)
I had it train overnight (roughly 7 hours) on resnet-50.
I’ve been reading the fastai library source code during my Thanksgiving trip both in the old school way (a decent-sized printout) and using VScode to navigate it. As a minor project I decided to visualize the key dependencies in a simplified way, and I’ve found the output helpful:
I built a language model on 26 works of fiction from Project Gutenberg. Here’s the notebook.
To train the model, I used paragraphs of text as observational units. Then I looked at how well the model was able to determine which work of fiction each of the paragraphs in the validation set belonged to. There was some class imbalance, so the final accuracy score of 71% may be a bit misleading. But looking at the confusion matrix, it does seem like the model performs well above chance, even for under-represented texts. The model’s most frequent source of error was due to misattribution of a different text written by the same author (e.g. one Charles Dickens book sounds a lot like another).
Two handy coding tips I learned:
plot_confusion_matrix() creates a plt object which can be manipulated directly (for relabeling ticks and axes, for example). This is nice because the method itself doesn’t return a Pyplot object - but once you know that the plt space is currently representing the confusion matrix plot, you can adjust it as needed.
The ClassificationInterpretation class in fastai.vision (which includes most_confused, plot_confusion_matrix, etc) can be used for text classifiers, too. Super handy.
^ Apologies if those were already noted in class, I’m a bit behind on my lectures.
I wrote a blogpost about the inner workings of CNN. My aim is to put together a post series that guides the reader through the network - from an input image to the parameter optimisation - and thereby providing a introductory resource for those not familiar with the maths behind CNN yet. In doing so, the goal is to be as comprehensive as possible on the one hand and concise on the other.
The post is the first part in the planned series. And there will be more to come in the coming days and weeks.
As I started dealing with CNN and deep learning in general a few months ago, I’m sure there is room for improvement and I would be more than happy to get feedback.