Slicing Pre-Trained models in Keras. Part (II.A)

Slicing Pre-Trained models in Keras. Part (II.A)

Hi again!

So this is the second part of this series, in which we will understand how to split or slice a pre-trained vision model.


First of all, I selected DenseNet169 pre-trained on ImageNet data as an example for two reasons:

  1. This was the architecture that was exploited during my MSc studies.
  2. The architecture follows a dense connectivity pattern, which created a challenging task to split the blocks without violating the original computational graph.

let's begin!

what is DenseNets?

DenseNet is a family of Convolutional Neural networks (CNN) that was built upon the idea of connecting layers using dense connections. It was introduced in 2016 by Gao Huang et al [1] in a paper under the title "Densely Connected Convolutional Networks". He and his team mentioned, "DenseNets have several compelling advantages: they alleviate the vanishing gradient problem, strengthen feature propagation, encourage feature reuse, and substantially reduce the number of parameters.", For my MSc problem DenseNet achieved good results with faster inference and training time. Let's move to the structure of the network.

Network's configuration

It consists of mainly two major blocks:

  • Dense Block (DB)
  • Transition Block (TB)

DenseNet169 design, where each Dense block is followed by Transition block. Note: I removed the end classifier to clarify the concept of slicing.

The objective now is to slice this network at any location, so anyone can use a part of this pre-trained model or any other model. What we will do here can be transferred to another network's architecture such as Inception and ResNets.

As an example, I just want this part of the network to be exploited as a generic feature extractor in your new architecture.

No alt text provided for this image


Dealing with the architecture as a Lego brick offers more flexibility if you want to test new ideas.


The steps we will follow:

  1. Check the original computational graph.
  2. Understand the architectural design.
  3. Start splitting your model into smaller blocks.
  4. Reconnect the blocks again and verify that after reconnection it remains the same as the original one.

Happy learning!?

Thank you.

References

要查看或添加评论,请登录

Mohamed Ibrahim的更多文章

  • Slicing Pre-Trained models in Keras. Part (II.B)

    Slicing Pre-Trained models in Keras. Part (II.B)

    Hi again everyone! Today we will see a practical example regarding slicing a pre-trained model. We will focus on…

    4 条评论
  • Slicing Pre-Trained models in Keras. Part (I)

    Slicing Pre-Trained models in Keras. Part (I)

    Today we will discuss how to slice the pre-trained models provided by the Keras framework for deep learning(DL)…

  • Neural Networks 3D Visulaization

    Neural Networks 3D Visulaization

    It is an amazing thing when you are able to visualize the concepts that you didn't understand well, Neural Networks are…

    2 条评论

社区洞察

其他会员也浏览了