public ResNet — struct
ResNet(channel_config, block_config, shortcut_config;
       block, connection = addrelu, nclasses = 1000)
Create a ResNet model
(reference).
See also resnet.
Arguments
channel_config: the growth rate of the output feature maps within a residual blockblock_config: a list of the number of residual blocks at each stageshortcut_config: the type of shortcut style (either:A,:B, or:C).shortcut_configcan also be a vector of symbols if different shortcut styles are applied to different residual blocks.block: a function with input(inplanes, outplanes, downsample=false)that returns a new residual block (seeMetalhead.basicblockandMetalhead.bottleneck)connection: the binary function applied to the output of residual and skip paths in a blocknclasses: the number of output classes
ResNet(depth = 50; pretrain = false, nclasses = 1000)
Create a ResNet model with a specified depth (reference) following these modification referred as ResNet v1.5.
See also Metalhead.resnet.
Arguments
depth: depth of the ResNet model. Options include (18, 34, 50, 101, 152).nclasses: the number of output classes
For ResNet(18) and ResNet(34), the parameter-free shortcut style (type :A)
is used in the first block and the three other blocks use type :B connection
(following the implementation in PyTorch). The published version of
ResNet(18) and ResNet(34) used type :A shortcuts for all four blocks. The
example below shows how to create a 18 or 34-layer ResNet using only type :A
shortcuts:
using Metalhead
resnet18 = ResNet([1, 1], [2, 2, 2, 2], :A; block = Metalhead.basicblock)
resnet34 = ResNet([1, 1], [3, 4, 6, 3], :A; block = Metalhead.basicblock)
The bottleneck of the orginal ResNet model has a stride of 2 on the first convolutional layer when downsampling (instead of the second convolutional layers as in ResNet v1.5). The architecture of the orignal ResNet model can be obtained as shown below:
resnet50_v1 = ResNet([1, 1, 4], [3, 4, 6, 3], :B; block = Metalhead.bottleneck_v1)