/ghostnet

TensorFlow keras implementation of GhostNet - More Features from Cheap Operations

Primary LanguageJupyter NotebookGNU General Public License v3.0GPL-3.0

GhostNet implementation in Keras

This work implements the building blocks and network of the GhostNet [1] in tensorflow keras. It follows the logic presented in [4] with some adaptions towards the used machine learning framework.

Network configuration

The authors of the GhostNet were inspired by MobilenetV3 [2] architecture, this work is implemented 2 architectures:

  • "large" that is according to the GhostNet paper (and follows the structure of MobilenetV3-Large).

  • "small" folows the MobileNetV3-Small from MobilenetV3 paper.

Architecture selection (use "small" or "large" tags in constructor):

# create the ghostnet model
ghost_net_model = ghost_net_obj.create_model("small")

The "width_multiplier" parameter can be used to scale up or down the GhostNet, which results in architectures with fewer parameters (i.e. width_multiplier=0.1) ~1.4M.

Block configuration and meaning: [16,16,0.25,2,3] - expansion, out_channels, Squeeze-Excitation[3] value, strides, kernel size.

Note: the original paper used the standard 224x224 input, smaller inputs can be applied, if the AveragePooling kernel is adjusted, or adjusting the Squeeze-Excitation module value.

GhostNet - small, SE=0.25

Comparation, tests

Model Parameters [M] FLOPS[G]
GhostNet (small) / SE - 0.25 1.47 0.103
ResNet [5] - custom 0.287 0.594

Resources

  1. GhostNet: More Features from Cheap Operations, Kai Han, et all
  2. Searching for MobileNetV3, Andrew Howard, et all
  3. Squeeze-and-Excitation Networks, Jie Hu, et all
  4. HUAWEI Noah's Ark Lab, Efficient-AI-Backbones
  5. fvilmos, ResNet_keras

/Enjoy.