How to add new classes to your ML model? 🍏🍎🍊... 🍌?

You have a large multi-class NN in production.

You discover a new important class and want to add support for it *quickly* and with *low* risk.

Example: traffic signs recognition for self-driving cars πŸ›‘πŸš—

Thread πŸ‘‡
The naive approach πŸ€·β€β™‚οΈ

Collect examples of the new class (for example a new traffic sign), label them and retrain the whole NN.

βœ… It will probably work

❌ It will be time consuming, especially for big models.
❌ Risk for unintended regressions
Freezing the first layers πŸ₯Ά

Typical CNNs learn generic image features in the initial layers and they will likely apply to the new sign as well.

You can freeze the weights of the initial layers and only retrain the last fully connected layer(s).
βœ… Faster retrain, because only the last layers are updated
βœ… Lower risk for regressions

❌ For signs that look very differently, the CNN may lack the required features, leading to poor performance
❌ Still some risk for regression, because we touch all classes.
Extracting high-level features ⭕️βšͺ️6⃣

Train the NN to extract high-level features suitable for traffic signs, like shape, color, text or digits.

Define rules to classify each sign based on these features.

(Special credits to @ernestomancebo and @KwasiRansom for this idea)
βœ… No need to retrain
βœ… Low risk because classes can be separated well
βœ… Will work well for speed limits

❌ Won't work for some sign categories, like for example warning signs that only differ by their pictogram
❌ Won't work for signs with new shapes
One-shot learning πŸ›‘β–ΆοΈπŸ”’

Transform sign images into a latent space, where they can be compared. Each class image is then described by a feature vector.

Siamese NNs can trained to transform images of the same class to very similar feature vectors in a latent space.
How it works?

1⃣ Choose examples for the known classes and precompute their feature vectors
2⃣ Transform new images to the latent space and find the best match to a known class
3⃣ When a new class is found, simply add an example image to the set of known classes.
βœ… No retrain needed
βœ… Low risk for regression
βœ… Only few examples of the new class needed

❌ May not work well if the new sign is very different and not supported well by the encoder
And finally some examples of traffic signs that you may not think exist until you encounter them... 😁

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Vladimir Haltakov

Vladimir Haltakov Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @haltakov

28 Jan
Is this formula difficult? πŸ€”

This is the formula for Gradient Descent with Momentum as presented in Wikipedia.

It may look intimidating at first, but I promise you that by the end of this thread it will be easy to understand!

Thread πŸ‘‡ Image
The Basis ◻️

Let's break it down! The basis is this simple formula describing an iterative optimization method.

We have some weights (parameters) and we iteratively update them in some way to reach a goal.

Iterative methods are used when we cannot compute the solution directly Image
Gradient Decent Update πŸ“‰

We define a loss function describing how good our model is. We want to find the weights that minimize the loss (make the model better).

We compute the gradient of the loss and update the weights by a small amount (learning rate) against the gradient. Image
Read 7 tweets
26 Jan
Machine Learning Interview Question #7 πŸ€–πŸ§ πŸ§

This is a more difficult and more open question...

❓ You are developing a traffic signs detector for a self-driving car.

How would you design it in a way that you can quickly add support for new signs, you didn't see before ❓
🌟 BONUS QUESTION 🌟:

Can you do this with minimal retrain of your neural network?
Looking forward to some creative answers! πŸ˜ƒ

Answer in the replies. Read the rules πŸ‘‡

Read 4 tweets
12 Jan
What are typical challenges when training a deep neural networks ⁉️

β–ͺ️ Overfitting
β–ͺ️ Underfitting
β–ͺ️ Lack of training data
β–ͺ️ Vanishing gradients
β–ͺ️ Exploding gradients
β–ͺ️ Dead ReLUs
β–ͺ️ Network architecture design
β–ͺ️ Hyperparameter tuning

How to solve them πŸ‘‡
Overfitting 🐘

Your model performs well during training, but poorly during test.

Possible solutions:
- Reduce the size of your model
- Add more data
- Increase dropout
- Stop the training early
- Add regularization to your loss
- Decrease batch size
Underfitting 🐁

You model performs poorly both during training and test.

Possible solutions:
- Increase the size of your model
- Add more data
- Train for a longer time
- Start with a pre-trained network
Read 11 tweets
28 Dec 20
You are feeling overwhelmed when learning something new? 😫

There is so much information out there and you don't know where to start? πŸ₯΄

Here is my strategy to learn new concepts that has helped me a lot in my career...

πŸ‘‡ Thread πŸ‘‡
The problem with complex topics? πŸ€”

Today, the problem is not the availability of the information, but its discovery! πŸ”­

You need to avoid going down the rabbit whole, before you are sure this is the right rabbit hole πŸ˜€

Learn to focus and prioritize how to spend your time!
Get a rough overview πŸ—ΊοΈ

Research about the topic you are trying to learn and get a rough idea of the existing concepts. Don't try to understand everything yet!

The goal is to only have an overview of what is out there.

Survey papers about a specific topic are a good example.
Read 7 tweets
27 Dec 20
Artificial Intelligence and Machine Learning trends in 2020 πŸ§ πŸ€–

Short overview of the fields where AI and ML is growing fast.

πŸ‘‡ Thread πŸ‘‡
Robotics πŸ€–

Traditional robotics algorithms like localization, mapping, path planning and vehicle/robot control are being successfully replaced by AI versions.

Reinforcement learning is also a big topic here!
Computer Vision πŸ“·

Computer vision grew massively in the last years after great improvements in deep learning. This is one of the fields that benefited most from CNNs.

While computer vision problems start getting commoditized now, there are still many interesting challengec.
Read 6 tweets
9 Nov 20
Self-driving car engineer roles - Big Data Engineer πŸ’½

Self-driving cars have lots of cameras, lidars and radars. Waymo currently has 29 cameras on a single vehicle! The cars generate huge amounts of data, easily more than 1 GB/s. This data needs to be processed...

Thread πŸ‘‡
Problems to work on πŸ€”

The big data engineer needs to design and implement efficient storage and data processing pipelines to handle such large amounts of data.

The data also needs to be made available to the developers in a way that they can efficiently get to what they need.
Data πŸ’Ύ

Imagine that the self-driving car is recording data at a rate of 1 GB/s. Going on a test drive for 4 hours means that you'll collect more than 14 TB of data!

There are specialized loggers that can handle such rates, like this beast for example: vigem.de/en/content/pro…
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!