Models

The API reference for available models in Metalhead.jl.

Metalhead.VGGType
VGG(imsize::Dims{2}; config, inchannels, batchnorm = false, nclasses, fcsize, dropout_rate)

Construct a VGG model with the specified input image size. Typically, the image size is (224, 224).

Keyword Arguments:

  • config : VGG convolutional block configuration. It is defined as a vector of tuples (output_channels, num_convolutions) for each block
  • inchannels: number of input channels
  • batchnorm: set to true to use batch normalization after each convolution
  • nclasses: number of output classes
  • fcsize: intermediate fully connected layer size (see Metalhead.vgg_classifier_layers)
  • dropout_rate: dropout level between fully connected layers
source
Metalhead.ResNetType
ResNet(depth::Integer; pretrain::Bool = false, inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a ResNet model with the specified depth. ((reference)[https://arxiv.org/abs/1512.03385])

Arguments

  • depth: one of [18, 34, 50, 101, 152]. The depth of the ResNet model.
  • pretrain: set to true to load the model with pre-trained weights for ImageNet
  • inchannels: The number of input channels.
  • nclasses: the number of output classes

Advanced users who want more configuration options will be better served by using resnet.

source
Metalhead.WideResNetType
WideResNet(depth::Integer; pretrain::Bool = false, inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a Wide ResNet model with the specified depth. The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same. ((reference)[https://arxiv.org/abs/1605.07146])

Arguments

  • depth: one of [18, 34, 50, 101, 152]. The depth of the Wide ResNet model.
  • pretrain: set to true to load the model with pre-trained weights for ImageNet
  • inchannels: The number of input channels.
  • nclasses: the number of output classes

Advanced users who want more configuration options will be better served by using resnet.

source
Metalhead.GoogLeNetType
GoogLeNet(; pretrain::Bool = false, inchannels::Integer = 3, nclasses::Integer = 1000)

Create an Inception-v1 model (commonly referred to as GoogLeNet) (reference).

Arguments

  • pretrain: set to true to load the model with pre-trained weights for ImageNet
  • nclasses: the number of output classes
Warning

GoogLeNet does not currently support pretrained weights.

See also googlenet.

source
Missing docstring.

Missing docstring for Inception-v3. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Inception-v4. Check Documenter's build log for details.

Missing docstring.

Missing docstring for InceptionResNet-v2. Check Documenter's build log for details.

Metalhead.SqueezeNetType
SqueezeNet(; pretrain::Bool = false, inchannels::Integer = 3,
       nclasses::Integer = 1000)

Create a SqueezeNet (reference).

Arguments

  • pretrain: set to true to load the pre-trained weights for ImageNet
  • inchannels: number of input channels.
  • nclasses: the number of output classes.

See also squeezenet.

source
Metalhead.DenseNetType
DenseNet(config::Integer; pretrain::Bool = false, nclasses::Integer = 1000)
DenseNet(transition_configs::NTuple{N,Integer})

Create a DenseNet model with specified configuration. Currently supported values are (121, 161, 169, 201) (reference). Set pretrain = true to load the model with pre-trained weights for ImageNet.

Warning

DenseNet does not currently support pretrained weights.

See also Metalhead.densenet.

source
Metalhead.ResNeXtType
ResNeXt(depth::Integer; pretrain::Bool = false, cardinality::Integer = 32,
        base_width::Integer = 4, inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a ResNeXt model with the specified depth, cardinality, and base width. ((reference)[https://arxiv.org/abs/1611.05431])

Arguments

  • depth: one of [18, 34, 50, 101, 152]. The depth of the ResNet model.
  • pretrain: set to true to load the model with pre-trained weights for ImageNet. Supported configurations are:
    • depth 50, cardinality of 32 and base width of 4.
    • depth 101, cardinality of 32 and base width of 8.
    • depth 101, cardinality of 64 and base width of 4.
  • cardinality: the number of groups to be used in the 3x3 convolution in each block.
  • base_width: the number of feature maps in each group.
  • inchannels: the number of input channels.
  • nclasses: the number of output classes

Advanced users who want more configuration options will be better served by using resnet.

source
Metalhead.MobileNetv1Type
MobileNetv1(width_mult = 1; inchannels::Integer = 3, pretrain::Bool = false,
            nclasses::Integer = 1000)

Create a MobileNetv1 model with the baseline configuration (reference). Set pretrain to true to load the pretrained weights for ImageNet.

Arguments

  • width_mult: Controls the number of output feature maps in each block (with 1.0 being the default in the paper; this is usually a value between 0.1 and 1.4)
  • inchannels: The number of input channels.
  • pretrain: Whether to load the pre-trained weights for ImageNet
  • nclasses: The number of output classes

See also Metalhead.mobilenetv1.

source
Metalhead.MobileNetv2Type
MobileNetv2(width_mult = 1.0; inchannels::Integer = 3, pretrain::Bool = false,
            nclasses::Integer = 1000)

Create a MobileNetv2 model with the specified configuration. (reference). Set pretrain to true to load the pretrained weights for ImageNet.

Arguments

  • width_mult: Controls the number of output feature maps in each block (with 1.0 being the default in the paper; this is usually a value between 0.1 and 1.4)
  • pretrain: Whether to load the pre-trained weights for ImageNet
  • inchannels: The number of input channels.
  • nclasses: The number of output classes

See also Metalhead.mobilenetv2.

source
Metalhead.MobileNetv3Type
MobileNetv3(config::Symbol; width_mult::Real = 1, pretrain::Bool = false,
            inchannels::Integer = 3, nclasses::Integer = 1000)

Create a MobileNetv3 model with the specified configuration. (reference). Set pretrain = true to load the model with pre-trained weights for ImageNet.

Arguments

  • config: :small or :large for the size of the model (see paper).
  • width_mult: Controls the number of output feature maps in each block (with 1.0 being the default in the paper; this is usually a value between 0.1 and 1.4)
  • pretrain: whether to load the pre-trained weights for ImageNet
  • inchannels: The number of channels in the input.
  • nclasses: the number of output classes

See also Metalhead.mobilenetv3.

source
Metalhead.EfficientNetType
EfficientNet(config::Symbol; pretrain::Bool = false)

Create an EfficientNet model (reference). See also efficientnet.

Arguments

  • config: name of default configuration (can be :b0, :b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8)
  • pretrain: set to true to load the pre-trained weights for ImageNet
source
Metalhead.MLPMixerType
MLPMixer(config::Symbol; patch_size::Dims{2} = (16, 16), imsize::Dims{2} = (224, 224),
         inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a model with the MLPMixer architecture. (reference).

Arguments

  • config: the size of the model - one of small, base, large or huge
  • patch_size: the size of the patches
  • imsize: the size of the input image
  • drop_path_rate: Stochastic depth rate
  • inchannels: the number of input channels
  • nclasses: number of output classes

See also Metalhead.mlpmixer.

source
Metalhead.ResMLPType
ResMLP(config::Symbol; patch_size::Dims{2} = (16, 16), imsize::Dims{2} = (224, 224),
       inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a model with the ResMLP architecture. (reference).

Arguments

  • config: the size of the model - one of small, base, large or huge
  • patch_size: the size of the patches
  • imsize: the size of the input image
  • inchannels: the number of input channels
  • nclasses: number of output classes

See also Metalhead.mlpmixer.

source
Metalhead.gMLPType
gMLP(config::Symbol; patch_size::Dims{2} = (16, 16), imsize::Dims{2} = (224, 224),
     inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a model with the gMLP architecture. (reference).

Arguments

  • config: the size of the model - one of small, base, large or huge
  • patch_size: the size of the patches
  • imsize: the size of the input image
  • inchannels: the number of input channels
  • nclasses: number of output classes

See also Metalhead.mlpmixer.

source
Metalhead.ViTType
ViT(config::Symbol = base; imsize::Dims{2} = (256, 256), inchannels::Integer = 3,
    patch_size::Dims{2} = (16, 16), pool = :class, nclasses::Integer = 1000)

Creates a Vision Transformer (ViT) model. (reference).

Arguments

  • config: the model configuration, one of [:tiny, :small, :base, :large, :huge, :giant, :gigantic]
  • imsize: image size
  • inchannels: number of input channels
  • patch_size: size of the patches
  • pool: pooling type, either :class or :mean
  • nclasses: number of classes in the output

See also Metalhead.vit.

source
Metalhead.ConvNeXtType
ConvNeXt(config::Symbol; inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a ConvNeXt model. (reference)

Arguments

  • config: The size of the model, one of tiny, small, base, large or xlarge.
  • inchannels: The number of channels in the input.
  • nclasses: number of output classes

See also Metalhead.convnext.

source
Metalhead.ConvMixerType
ConvMixer(config::Symbol; inchannels::Integer = 3, nclasses::Integer = 1000)

Creates a ConvMixer model. (reference)

Arguments

  • config: the size of the model, either :base, :small or :large
  • inchannels: The number of channels in the input.
  • nclasses: number of classes in the output
source