Template Class MobileNetV1

Class Documentation

template<typename OutputLayerType = ann::CrossEntropyError<>, typename InitializationRuleType = ann::RandomInitialization>
class mlpack::models::MobileNetV1

Definition of a MobileNet V1 CNN.

tparam OutputLayerType

The output layer type used to evaluate the network.

tparam InitializationRuleType

Rule used to initialize the weight matrix.

Public Functions

MobileNetV1()

Create the MobileNet model.

MobileNetV1(const size_t inputChannel, const size_t inputWidth, const size_t inputHeight, const float alpha = 1.0, const size_t depthMultiplier = 1.0, const bool includeTop = true, const bool preTrained = false, const size_t numClasses = 1000)

MobileNetV1 constructor initializes input shape and number of classes.

Parameters
  • inputChannels – Number of input channels of the input image.

  • inputWidth – Width of the input image.

  • inputHeight – Height of the input image.

  • includeTop – Must be set to true if preTrained is set to true.

  • preTrained – True for pre-trained weights of ImageNet, default is false.

  • numClasses – Optional number of classes to classify images into, only to be specified if includeTop is true, default is 1000.

MobileNetV1(std::tuple<size_t, size_t, size_t> inputShape, const float alpha = 1.0, const size_t depthMultiplier = 1.0, const bool includeTop = true, const bool preTrained = false, const size_t numClasses = 1000)

MobileNetV1 constructor initializes input shape and number of classes.

Parameters
  • inputShape – A three-valued tuple indicating input shape. First value is number of channels (channels-first). Second value is input height. Third value is input width.

  • preTrained – True for pre-trained weights of ImageNet, default is false.

  • numClasses – Optional number of classes to classify images into, only to be specified if includeTop is true.

inline ann::FFN<OutputLayerType, InitializationRuleType> &GetModel()

Get Layers of the model.

void LoadModel(const std::string &filePath)

Load weights into the model and assumes the internal matrix to be named “MobileNetV1”.

void SaveModel(const std::string &filepath)

Save weights for the model and assumes the internal matrix to be named “MobileNetV1”.