Skip to content

ResNeXt

The ResNeXt model is based on the "Aggregated Residual Transformations for Deep Neural Networks" paper.

Architecture overview

This paper improves the ResNet architecture by increasing the width of bottleneck blocks

The key takeaways from the paper are the following:

  • increases the number of channels in bottlenecks
  • switches to group convolutions to balance the number of operations

Model builders

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

resnext50_32x4d

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

ResNeXt-50 from "Aggregated Residual Transformations for Deep Neural Networks"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, load that checkpoint on the model

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

ResNeXt50_32x4d_Checkpoint

Bases: Enum

IMAGENETTE class-attribute instance-attribute
IMAGENETTE = _checkpoint(arch='resnext50_32x4d', url='https://github.com/frgfm/Holocron/releases/download/v0.2.1/resnext50_32x4d_224-5832c4ce.pth', acc1=0.9455, acc5=0.9949, sha256='5832c4ce33522a9eb7a8b5abe31cf30621721a92d4f99b4b332a007d81d071fe', size=92332638, num_params=23000394, commit='6e32c5b578711a2ef3731a8f8c61760ed9f03e58', train_args='./imagenette2-320/ --arch resnext50_32x4d --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/resnet.py
def resnext50_32x4d(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """ResNeXt-50 from
    ["Aggregated Residual Transformations for Deep Neural Networks"](https://arxiv.org/pdf/1611.05431.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, load that checkpoint on the model
        progress: If True, displays a progress bar of the download to stderr
        kwargs: keyword args of [`ResNet`][holocron.models.ResNet]

    Returns:
        classification model

    ::: holocron.models.ResNeXt50_32x4d_Checkpoint
        options:
            heading_level: 4
            show_if_no_docstring: true
    """
    kwargs["width_per_group"] = 4
    block_args = {"groups": 32}
    return _resnet(
        checkpoint,
        progress,
        Bottleneck,
        [3, 4, 6, 3],
        [64, 128, 256, 512],
        block_args=block_args,
        **kwargs,
    )

resnext101_32x8d

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

ResNeXt-101 from "Aggregated Residual Transformations for Deep Neural Networks"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, load that checkpoint on the model

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/resnet.py
def resnext101_32x8d(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """ResNeXt-101 from
    ["Aggregated Residual Transformations for Deep Neural Networks"](https://arxiv.org/pdf/1611.05431.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, load that checkpoint on the model
        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
    """
    kwargs["width_per_group"] = 8
    block_args = {"groups": 32}
    return _resnet(
        checkpoint,
        progress,
        Bottleneck,
        [3, 4, 23, 3],
        [64, 128, 256, 512],
        block_args=block_args,
        **kwargs,
    )