ResNet-18

Click a block to read its description, or select it with Tab and Enter.

ResNet-18Classification, 224 × 224 input, 1,000 classes. Tensor sizes exclude batch.LibreYOLOResNet-18Classification, 224 × 224 input, 1,000 classes. Tensor sizes exclude batch.NetworkInput3 × 224 × 224Conv2d 7×7 / 264 × 112 × 112, p=3BatchNorm2d64 × 112 × 112ReLU64 × 112 × 112MaxPool2d 3×3 / 264 × 56 × 56, p=1Layer 1: BasicBlock64 × 56 × 56, repeats=2Identity blocks onlyLayer 2: BasicBlock128 × 28 × 28, repeats=2First block downsamplesLayer 3: BasicBlock256 × 14 × 14, repeats=2First block downsamplesLayer 4: BasicBlock512 × 7 × 7, repeats=2First block downsamplesAdaptiveAvgPool2d512 × 1 × 1Flatten (from dim 1)512Linear + bias512 inputs, 1,000 logitsBasicBlock definitionsConv2d bias=False. k=kernel, s=stride, p=padding. ReLU follows each addition.Layer 1Identity block (n=2)Input 64 × 56 × 56Conv2d 3×364 to 64, s=1, p=1BatchNorm2d64 × 56 × 56ReLU64 × 56 × 56Conv2d 3×364 to 64, s=1, p=1BatchNorm2d64 × 56 × 56+identityReLU64 × 56 × 56Output 64 × 56 × 56Stage repeatsVariantn1n2n3n4ResNet-182222ResNet-343463n1..n4: total BasicBlocks per layer.Widths are fixed at 64, 128, 256, 512.Only repeat counts vary in this pair.ResNet-50/101 use Bottleneck blocksand are outside this shared topology.Outputs are logits from model.forward.Softmax is outside this network.Layer 2Projection block (n=1)Input 64 × 56 × 56Conv2d 3×364 to 128, s=2, p=1BatchNorm2d128 × 28 × 28ReLU128 × 28 × 28Conv2d 3×3128 to 128, s=1, p=1BatchNorm2d128 × 28 × 28+Conv2d 1×1 / 264 to 128, p=0BatchNorm2d128 × 28 × 28ReLU128 × 28 × 28Output 128 × 28 × 28Identity block (n=1)Input 128 × 28 × 28Conv2d 3×3128 to 128, s=1, p=1BatchNorm2d128 × 28 × 28ReLU128 × 28 × 28Conv2d 3×3128 to 128, s=1, p=1BatchNorm2d128 × 28 × 28+identityReLU128 × 28 × 28Output 128 × 28 × 28Then repeat the identity block below.Layer 3Projection block (n=1)Input 128 × 28 × 28Conv2d 3×3128 to 256, s=2, p=1BatchNorm2d256 × 14 × 14ReLU256 × 14 × 14Conv2d 3×3256 to 256, s=1, p=1BatchNorm2d256 × 14 × 14+Conv2d 1×1 / 2128 to 256, p=0BatchNorm2d256 × 14 × 14ReLU256 × 14 × 14Output 256 × 14 × 14Identity block (n=1)Input 256 × 14 × 14Conv2d 3×3256 to 256, s=1, p=1BatchNorm2d256 × 14 × 14ReLU256 × 14 × 14Conv2d 3×3256 to 256, s=1, p=1BatchNorm2d256 × 14 × 14+identityReLU256 × 14 × 14Output 256 × 14 × 14Then repeat the identity block below.Layer 4Projection block (n=1)Input 256 × 14 × 14Conv2d 3×3256 to 512, s=2, p=1BatchNorm2d512 × 7 × 7ReLU512 × 7 × 7Conv2d 3×3512 to 512, s=1, p=1BatchNorm2d512 × 7 × 7+Conv2d 1×1 / 2256 to 512, p=0BatchNorm2d512 × 7 × 7ReLU512 × 7 × 7Output 512 × 7 × 7Identity block (n=1)Input 512 × 7 × 7Conv2d 3×3512 to 512, s=1, p=1BatchNorm2d512 × 7 × 7ReLU512 × 7 × 7Conv2d 3×3512 to 512, s=1, p=1BatchNorm2d512 × 7 × 7+identityReLU512 × 7 × 7Output 512 × 7 × 7Then repeat the identity block below.Original diagram from LibreYOLO MIT source. Unfused inference graph.Source: libreyolo/models/resnet/nn.py. Revision a4d0ecc9e17f.libreyolo.com