Skip to content

SKNet

The ResNet model is based on the "Selective Kernel Networks" paper.

Architecture overview

This paper revisits the concept of having a dynamic receptive field selection in convolutional blocks.

SKNet architecture

The key takeaways from the paper are the following:

  • performs convolutions with multiple kernel sizes
  • implements a cross-channel attention mechanism

Model builders

The following model builders can be used to instantiate a SKNet model, with or without pre-trained weights. All the model builders internally rely on the ResNet base class.

sknet50

sknet50(pretrained: bool = False, checkpoint: Checkpoint | None = None, progress: bool = True, **kwargs: Any) -> ResNet

SKNet-50 from "Selective Kernel Networks"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, the model's parameters will be set to the checkpoint's values

TYPE: Checkpoint | None DEFAULT: None

progress

If True, displays a progress bar of the download to stderr

TYPE: bool DEFAULT: True

kwargs

keyword args of ResNet

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
ResNet

classification model

SKNet50_Checkpoint

Bases: Enum

IMAGENETTE class-attribute instance-attribute
IMAGENETTE = _checkpoint(arch='sknet50', url='https://github.com/frgfm/Holocron/releases/download/v0.2.1/sknet50_224-e2349031.pth', acc1=0.9437, acc5=0.9954, sha256='e2349031c838a4661cd729dbc7825605c9e0c966bd89bbcc9b39f0e324894d1f', size=141253623, num_params=35224394, commit='6e32c5b578711a2ef3731a8f8c61760ed9f03e58', train_args='./imagenette2-320/ --arch sknet50 --batch-size 64 --mixup-alpha 0.2 --amp --device 0 --epochs 100 --lr 1e-3 --label-smoothing 0.1 --random-erase 0.1 --train-crop-size 176 --val-resize-size 232 --opt adamw --weight-decay 5e-2')
DEFAULT class-attribute instance-attribute
DEFAULT = IMAGENETTE
Source code in holocron/models/classification/sknet.py
def sknet50(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """SKNet-50 from
    ["Selective Kernel Networks"](https://arxiv.org/pdf/1903.06586.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, the model's parameters will be set to the checkpoint's values
        progress: If True, displays a progress bar of the download to stderr
        kwargs: keyword args of [`ResNet`][holocron.models.classification.resnet.ResNet]

    Returns:
        classification model

    ::: holocron.models.SKNet50_Checkpoint
        options:
            heading_level: 4
            show_if_no_docstring: true
    """
    checkpoint = _handle_legacy_pretrained(
        pretrained,
        checkpoint,
        SKNet50_Checkpoint.DEFAULT.value,
    )
    return _sknet(checkpoint, progress, [3, 4, 6, 3], [64, 128, 256, 512], **kwargs)

sknet101

sknet101(pretrained: bool = False, checkpoint: Checkpoint | None = None, progress: bool = True, **kwargs: Any) -> ResNet

SKNet-101 from "Selective Kernel Networks"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, the model's parameters will be set to the checkpoint's values

TYPE: Checkpoint | None DEFAULT: None

progress

If True, displays a progress bar of the download to stderr

TYPE: bool DEFAULT: True

kwargs

keyword args of ResNet

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
ResNet

classification model

Source code in holocron/models/classification/sknet.py
def sknet101(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """SKNet-101 from
    ["Selective Kernel Networks"](https://arxiv.org/pdf/1903.06586.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, the model's parameters will be set to the checkpoint's values
        progress: If True, displays a progress bar of the download to stderr
        kwargs: keyword args of [`ResNet`][holocron.models.classification.resnet.ResNet]

    Returns:
        classification model
    """
    return _sknet(checkpoint if pretrained else None, progress, [3, 4, 23, 3], [64, 128, 256, 512], **kwargs)

sknet152

sknet152(pretrained: bool = False, checkpoint: Checkpoint | None = None, progress: bool = True, **kwargs: Any) -> ResNet

SKNet-152 from "Selective Kernel Networks"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, the model's parameters will be set to the checkpoint's values

TYPE: Checkpoint | None DEFAULT: None

progress

If True, displays a progress bar of the download to stderr

TYPE: bool DEFAULT: True

kwargs

keyword args of ResNet

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
ResNet

classification model

Source code in holocron/models/classification/sknet.py
def sknet152(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """SKNet-152 from
    ["Selective Kernel Networks"](https://arxiv.org/pdf/1903.06586.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, the model's parameters will be set to the checkpoint's values
        progress: If True, displays a progress bar of the download to stderr
        kwargs: keyword args of [`ResNet`][holocron.models.classification.resnet.ResNet]

    Returns:
        classification model
    """
    return _sknet(checkpoint if pretrained else None, progress, [3, 8, 86, 3], [64, 128, 256, 512], **kwargs)