Other models
This is the API reference for some of the models supported by Metalhead.jl that do not fit into the other categories.
The higher-level model constructors
Metalhead.AlexNet — TypeAlexNet(; pretrain::Bool = false, inchannels::Integer = 3,
nclasses::Integer = 1000)Create a AlexNet. (reference).
Arguments
pretrain: set totrueto load pre-trained weights for ImageNetinchannels: The number of input channels.nclasses: the number of output classes
AlexNet does not currently support pretrained weights.
See also alexnet.
Metalhead.VGG — TypeVGG(depth::Integer; pretrain::Bool = false, batchnorm::Bool = false,
inchannels::Integer = 3, nclasses::Integer = 1000)Create a VGG style model with specified depth. (reference).
VGG does not currently support pretrained weights for the batchnorm = true option.
Arguments
depth: the depth of the VGG model. Must be one of [11, 13, 16, 19].pretrain: set totrueto load pre-trained model weights for ImageNetbatchnorm: set totrueto use batch normalization after each convolutioninchannels: number of input channelsnclasses: number of output classes
See also vgg.
Metalhead.SqueezeNet — TypeSqueezeNet(; pretrain::Bool = false, inchannels::Integer = 3,
nclasses::Integer = 1000)Create a SqueezeNet (reference).
Arguments
pretrain: set totrueto load the pre-trained weights for ImageNetinchannels: number of input channels.nclasses: the number of output classes.
See also squeezenet.
Metalhead.UNet — TypeUNet(imsize::Dims{2} = (256, 256), inchannels::Integer = 3, outplanes::Integer = 3,
encoder_backbone = Metalhead.backbone(DenseNet(121)); pretrain::Bool = false)Creates a UNet model with an encoder built of specified backbone. By default it uses DenseNet backbone, but any ResNet-like Metalhead model can be used for the encoder. (reference).
Arguments
imsize: size of input imageinchannels: number of channels in input imageoutplanes: number of output feature planes.encoder_backbone: The backbone layers of specified model to be used as encoder. For example,Metalhead.backbone(Metalhead.ResNet(18))can be passed to instantiate a UNet with layers of resnet18 as encoder.pretrain: Whether to load the pre-trained weights for ImageNet
UNet does not currently support pretrained weights.
See also Metalhead.unet.
The mid-level functions
Metalhead.alexnet — Functionalexnet(; dropout_prob = 0.5, inchannels::Integer = 3, nclasses::Integer = 1000)Create an AlexNet model (reference).
Arguments
dropout_prob: dropout probability for the classifierinchannels: The number of input channels.nclasses: the number of output classes
Metalhead.vgg — Functionvgg(imsize::Dims{2}; config, batchnorm::Bool = false, fcsize::Integer = 4096,
dropout_prob = 0.0, inchannels::Integer = 3, nclasses::Integer = 1000)Create a VGG model (reference).
Arguments
imsize: input image width and height as a tupleconfig: the configuration for the convolution layers (seeMetalhead.vgg_convolutional_layers)inchannels: number of input channelsbatchnorm: set totrueto use batch normalization after each convolutionnclasses: number of output classesfcsize: intermediate fully connected layer size (seeMetalhead.vgg_classifier_layers)dropout_prob: dropout level between fully connected layers
Metalhead.squeezenet — Functionsqueezenet(; dropout_prob = 0.5, inchannels::Integer = 3, nclasses::Integer = 1000)Create a SqueezeNet model. (reference).
Arguments
dropout_prob: dropout probability for the classifier head. Set tonothingto disable dropout.inchannels: number of input channels.nclasses: the number of output classes.
Metalhead.unet — Functionunet(encoder_backbone, imgdims, outplanes::Integer, final::Any = unet_final_block,
fdownscale::Integer = 0)Creates a UNet model with specified convolutional backbone. Backbone of any Metalhead ResNet-like model can be used as encoder (reference).
Arguments
- `encoder_backbone`: The backbone layers of specified model to be used as encoder.
For example, `Metalhead.backbone(Metalhead.ResNet(18))` can be passed
to instantiate a UNet with layers of resnet18 as encoder.
- `inputsize`: size of input image
- `outplanes`: number of output feature planes
- `final`: final block as described in original paper
- `fdownscale`: downscale factorBlock-level functions
Metalhead.vgg_block — Functionvgg_block(ifilters, ofilters, depth, batchnorm)A VGG block of convolution layers (reference).
Arguments
ifilters: number of input feature mapsofilters: number of output feature mapsdepth: number of convolution/convolution + batch norm layersbatchnorm: set totrueto include batch normalization after each convolution
Metalhead.vgg_convolutional_layers — Functionvgg_convolutional_layers(config, batchnorm, inchannels)Create VGG convolution layers (reference).
Arguments
config: vector of tuples(output_channels, num_convolutions)for each block (seeMetalhead.vgg_block)batchnorm: set totrueto include batch normalization after each convolutioninchannels: number of input channels
Metalhead.vgg_classifier_layers — Functionvgg_classifier_layers(imsize, nclasses, fcsize, dropout_prob)Create VGG classifier (fully connected) layers (reference).
Arguments
imsize: tuple(width, height, channels)indicating the size after the convolution layers (seeMetalhead.vgg_convolutional_layers)nclasses: number of output classesfcsize: input and output size of the intermediate fully connected layerdropout_prob: the dropout level between each fully connected layer