Hey everyone,
I am just getting started with FastAI and am trying to implement what we learned in lesson 1 on Digit Recognizer competition on Kaggle. I am currently in top 22%. I am using Resnet18 with 30 epochs and learning rate of 1e-6.
How can I improve it?
Below is the link to my Notebook. Any suggestions would be really appreciated.
@sinsji
Update 1: Tried Resnet34, 15 epochs with lr = 4e-7. The training took about 30 minutes on Kaggle GPU. The score increased by 2 positions, no percentage change. Will try 20 epochs next
UPDATE 2: Reached 99.10% with ResNet34, 20 epochs, lr = 4e-6. I have reached 99.428% using TensorFlow implementing custom Neural Net architecture. I am trying to beat that.
Moving to ResNet50 now.
UPDATE 3: Tried Resnet50 with 15 epochs, LR = 4e-6 The score fell down to 97.5%. This architecture takes longer to train and might be an overkill.
UPDATE 4: MAJOR UPDATE. I cracked top 13%. Used Resnet34 with 30 epochs, batch size of 256, learning range of slice(1e-3,1e-2). I normalized the data not with mnist_stats but with imagenet_stats
Okay interesting.
I’m thinking about useful transformations myself.
With the large number of training images, I doubt whether transformations are very useful.
Good luck.
Why the 256 batch size? Any reasoning behind it why it could make a difference?
Do you use a continues run of 20-30 epochs or do you run fit_one_cycle multiple times?
I tend to do run it a few times, based on the course examples although I don’t know if it makes a difference. Further, many Kaggle examples just run it once for many epochs.
I saw that batch sizes in another kernel which reminded me that in the fit_one_cycle paper, the author found that higher batch sizes led to better results. I don’t recall the reasoning but it is a complicated and lengthy paper which I will have to read a few more time.
I run fit_one_cycle twice. Once to set up the learning rate_finder. Then I ran 20-30 epochs by specifying that parameter in the fit_one_cycle function
TypeError: argument of type ‘PosixPath’ is not iterable
and I noticed that I’ve found this error in your kaggle kernel and commented on it before. Did you do something to resolve it, or did it go away on it’s own?
It’s really strange but it keeps coming up now and then for me and I can’t figure out why!
James,
I think that the pathlib library in Fastai conflicts with that of Kaggle. It is probably different Python versions. You might be getting that error when you are building your ImageDataBunch object. If so, replace your code to match the following as needed:
Looks like you’re doing everything right - but I’m new to fastai too.
If you’re interested, I’ve written a web app to make it easy to create your own MNIST style images (and make predictions on them) https://github.com/pete88b/data-science/tree/master/myohddac
I’m guessing you can’t train on additional data for the competition but it’s been good for me to see what the model predicts when I feed it my hand writing.