DEV Community

Cover image for EfficientNet for Beginners
Rohit Gupta
Rohit Gupta

Posted on

EfficientNet for Beginners

A very brief introduction of EfficientNet for beginners without much technical details.

Considering the problems faced by the older networks, Google released a paper in 2019 that dealt with a new family of CNNs i.e EfficientNet . These CNNs not only provide better accuracy but also improve the efficiency of the models by reducing the parameters and FLOPS (Floating Point Operations Per Second) manifold in comparison to the state of art models

What is new in this ? : In Efiicient Net : We perform scaling on 1.depth 2. width 3.resolution

1.Depth Scaling : It means keep on increasing the depth of network. We all know that more layers means more powerful network and hence better results but more layers results in exploding/vanishing gradient problem. To resolve this issue of exploding/vanishing gradient we did have ResNet but ResNet is computationally expensive.

2.Resolution Scaling : Low resolution images are mostly blurry. High Reso has more pixel and has more info. Network learns on more complex features and fine grained patterns. Learning gets better and accuracy increases.

Image description

3.Width : Increasing number of Feature Maps/ Channels. Increasing the number of feature maps. To get each and every feature of image, we need more feature maps. More fine grained features needed to be extracted.

If the input image is bigger(resolution), than there is more complex features and fine-grained patterns.

Why Depth Scaling : we have done Resolution Scaling, hence we have more data or more information in our input image which needs to be processed. So we need more layers.

But how much Depth Scaling for particular increment in the resolution of images? How many layers we need ?

Also from the paper :

1.Scaling up any dimension of network width, depth or resolution improves accuracy but the accuracy gain diminishes for bigger models.

2.In order to pursue better accuracy and efficiency, it is critical to balance all dimensions of network width, depth and resolution during scaling.

The main contributions of this paper are: a.Designing a simple mobile-size baseline architecture: EfficientNet-B0 b.Providing an effective compound scaling method for increasing the model size to achieve maximum accuracy gains.

How to do Scaling in the balanced way ? Compound Scaling helps in choosing the right value so that accuracy gains didn't diminishes. For Compound Scaling, we need a baseline model (Efficientnet-B0). Before continuing, we should know that EfficientNet-B0 is developed by Neural Architecture Search which is used for automating the design of ANNs and the networks designed by NAS are on par and outperform hand designed architectures.

EfficientNet-B0. It achieves 77.3% accuracy on ImageNet with only 5.3M parameters and 0.39B FLOPS. (Resnet-50 provides 76% accuracy with 26M parameters and 4.1B FLOPS).

Image description
Image description

On Efficientnet-B0, we will do Compound Scaling, to upscale the methods. Compound Scaling is done in the following way:

STEP 1: we first fix φ = 1, assuming twice more resources available, and do a small grid search of α, β, γ (by using equations 1 and 2 given in paper). In particular, we find the best values for EfficientNet-B0 are α = 1.2, β =1.1, γ = 1.15, under constraint of
α ·β2· γ2 ≈ 2

• STEP 2: we then fix α, β, γ as constants and scale up baseline network with different φ using Equation 3, to obtain EfficientNet-B1 to B7. Notably, it is possible to achieve even better performance by searching for α, β, γ directly around a large model, but the search cost becomes prohibitively more expensive on larger models. Our method solves this issue by only doing search once on the small baseline network (step 1), and then use the same scaling coefficients for all other models (step 2)

α = 1.2, β =1.1, γ = 1.15 simply means that if resolution is enhanced by 15%, than depth should be increased by 20% and width should be increased by 10%.

Results:This technique allowed the authors to produce models that provided accuracy higher than the existing ConvNets and that too with a monumental reduction in overall FLOPS and model size.

Original Paper
Google Blog

That's all folks.

If you have any doubt ask me in the comments section and I'll try to answer as soon as possible.
If you love the article follow me on Twitter: [https://twitter.com/guptarohit_kota]
If you are the Linkedin type, let's connect: www.linkedin.com/in/rohitgupta24

Happy Coding and Have an awesome day ahead 😀!

Top comments (0)