I had a breakthrough that turned a Deep Learning problem on its head!
Here is the story.
Here is the lesson I learned.
π§΅π
No, I did not cure cancer.
This story is about a classification problem βspecifically, computer vision.
I get images, and I need to determine the objects represented by them.
I have a ton of training data. I'm doing Deep Learning.
Life is good so far.
π
I'm using transfer learning.
In this context, transfer learning consists of taking a model that was trained to identify other types of objects and leverage everything that it learned to make my problem easier.
This way I don't have to teach a model from scratch!
π
I experimented with three different base models (all of them pre-trained on imagenet, which is a huge dataset):
(Now I'm doing everything I can to move to any of the other two, but that's another story.)
π
I also tried different architectures to extend that base model.
A couple of layers later and a few dozen experiments, the model started providing decent results.
Decent results aren't perfect results. But they were good enough.
π
If you have tried this before, there's been nothing surprising or different in this story.
I should have stopped at this point. (But then I wouldn't have this tweet to write!)
I didn't because sometimes, you don't want to be known as the "good enough" guy.
π
After a lot of tunning, I wasn't getting any substantial performance improvements so I decided to take some distance and look at the problem as a whole.
Users have a web interface to upload the images. These come as a set representing different angles of the object.
π
It turns out that the web interface requests images in a specific order:
1. Front of the object 2. Back of the object 3. Other
Users aren't forced to upload images that way, but 99% of them do.
A front picture of the object is usually very useful. A side picture is not.
π
Could I feed the order that these pictures were submitted as another feature to the model?
Would my Deep Learning model be able to pick up and use this information for better predictions?
π
I changed the model to add a second input. Now, besides the photo, I have an integer value representing the order.
I retrained the whole thing.
And... yes, it worked!
The improvement was phenomenal: 10%+ higher accuracy!
π
This is the end of a story that taught me an important lesson:
Open your mind. Look around. Think different.
Even more specific:
The magic is not in the architecture, the algorithm, or the parameters. The real magic is in you and your creativity.
Stay hungry!
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
When I heard about Duck Typing for the first time, I had to laugh.
But Python π has surprised me before, and this time was no exception.
This is another short thread 𧡠that will change the way you write code.
π
Here is the idea behind Duck Typing:
β«οΈIf it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
Taking this to Python's world, the functionality of an object is more important than its type. If the object quacks, then it's a duck.
π
Duck Typing is possible in dynamic languages (Hello, JavaScript fans π!)
Look at the attached example. Notice how "Playground" doesn't care about the specific type of the supplied item. Instead, it assumes that the item supports the bounce() method.