Skip to content

torchvision

Module diagram

classDiagram
  class torchvision {
  }
  class regnet {
  }
  class resnet {
  }
  class squeezenet {
  }
  class vgg {
  }

model.backbone.torchvision

regnet

__all__ module-attribute

__all__ = ['RegNet', 'regnet_y_400mf', 'regnet_y_800mf', 'regnet_y_1_6gf', 'regnet_y_3_2gf', 'regnet_y_8gf', 'regnet_y_16gf', 'regnet_y_32gf', 'regnet_y_128gf', 'regnet_x_400mf', 'regnet_x_800mf', 'regnet_x_1_6gf', 'regnet_x_3_2gf', 'regnet_x_8gf', 'regnet_x_16gf', 'regnet_x_32gf']

SimpleStemIN

SimpleStemIN(width_in: int, width_out: int, norm_layer: Callable[..., Module], activation_layer: Callable[..., Module])

Bases: Conv2dNormActivation

Simple stem for ImageNet: 3x3, BN, ReLU.

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    width_in: int,
    width_out: int,
    norm_layer: Callable[..., nn.Module],
    activation_layer: Callable[..., nn.Module],
) -> None:
    super().__init__(
        width_in,
        width_out,
        kernel_size=3,
        stride=2,
        norm_layer=norm_layer,
        activation_layer=activation_layer,
    )

BottleneckTransform

BottleneckTransform(width_in: int, width_out: int, stride: int, norm_layer: Callable[..., Module], activation_layer: Callable[..., Module], group_width: int, bottleneck_multiplier: float, se_ratio: Optional[float])

Bases: Sequential

Bottleneck transformation: 1x1, 3x3 [+SE], 1x1.

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    width_in: int,
    width_out: int,
    stride: int,
    norm_layer: Callable[..., nn.Module],
    activation_layer: Callable[..., nn.Module],
    group_width: int,
    bottleneck_multiplier: float,
    se_ratio: Optional[float],
) -> None:
    layers: OrderedDict[str, nn.Module] = OrderedDict()
    w_b = int(round(width_out * bottleneck_multiplier))
    g = w_b // group_width

    layers["a"] = Conv2dNormActivation(
        width_in,
        w_b,
        kernel_size=1,
        stride=1,
        norm_layer=norm_layer,
        activation_layer=activation_layer,
    )
    layers["b"] = Conv2dNormActivation(
        w_b,
        w_b,
        kernel_size=3,
        stride=stride,
        groups=g,
        norm_layer=norm_layer,
        activation_layer=activation_layer,
    )

    if se_ratio:
        # The SE reduction ratio is defined with respect to the
        # beginning of the block
        width_se_out = int(round(se_ratio * width_in))
        layers["se"] = SqueezeExcitation(
            input_channels=w_b,
            squeeze_channels=width_se_out,
            activation=activation_layer,
        )

    layers["c"] = Conv2dNormActivation(
        w_b, width_out, kernel_size=1, stride=1, norm_layer=norm_layer, activation_layer=None
    )
    super().__init__(layers)

ResBottleneckBlock

ResBottleneckBlock(width_in: int, width_out: int, stride: int, norm_layer: Callable[..., Module], activation_layer: Callable[..., Module], group_width: int = 1, bottleneck_multiplier: float = 1.0, se_ratio: Optional[float] = None)

Bases: Module

Residual bottleneck block: x + F(x), F = bottleneck transform.

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    width_in: int,
    width_out: int,
    stride: int,
    norm_layer: Callable[..., nn.Module],
    activation_layer: Callable[..., nn.Module],
    group_width: int = 1,
    bottleneck_multiplier: float = 1.0,
    se_ratio: Optional[float] = None,
) -> None:
    super().__init__()

    # Use skip connection with projection if shape changes
    self.proj = None
    should_proj = (width_in != width_out) or (stride != 1)
    if should_proj:
        self.proj = Conv2dNormActivation(
            width_in,
            width_out,
            kernel_size=1,
            stride=stride,
            norm_layer=norm_layer,
            activation_layer=None,
        )
    self.f = BottleneckTransform(
        width_in,
        width_out,
        stride,
        norm_layer,
        activation_layer,
        group_width,
        bottleneck_multiplier,
        se_ratio,
    )
    self.activation = activation_layer(inplace=True)
proj instance-attribute
proj = None
f instance-attribute
f = BottleneckTransform(width_in, width_out, stride, norm_layer, activation_layer, group_width, bottleneck_multiplier, se_ratio)
activation instance-attribute
activation = activation_layer(inplace=True)
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def forward(self, x: Tensor) -> Tensor:
    if self.proj is not None:
        x = self.proj(x) + self.f(x)
    else:
        x = x + self.f(x)
    return self.activation(x)

AnyStage

AnyStage(width_in: int, width_out: int, stride: int, depth: int, block_constructor: Callable[..., Module], norm_layer: Callable[..., Module], activation_layer: Callable[..., Module], group_width: int, bottleneck_multiplier: float, se_ratio: Optional[float] = None, stage_index: int = 0)

Bases: Sequential

AnyNet stage (sequence of blocks w/ the same output shape).

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    width_in: int,
    width_out: int,
    stride: int,
    depth: int,
    block_constructor: Callable[..., nn.Module],
    norm_layer: Callable[..., nn.Module],
    activation_layer: Callable[..., nn.Module],
    group_width: int,
    bottleneck_multiplier: float,
    se_ratio: Optional[float] = None,
    stage_index: int = 0,
) -> None:
    super().__init__()

    for i in range(depth):
        block = block_constructor(
            width_in if i == 0 else width_out,
            width_out,
            stride if i == 0 else 1,
            norm_layer,
            activation_layer,
            group_width,
            bottleneck_multiplier,
            se_ratio,
        )

        self.add_module(f"block{stage_index}-{i}", block)

BlockParams

BlockParams(depths: List[int], widths: List[int], group_widths: List[int], bottleneck_multipliers: List[float], strides: List[int], se_ratio: Optional[float] = None)
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    depths: List[int],
    widths: List[int],
    group_widths: List[int],
    bottleneck_multipliers: List[float],
    strides: List[int],
    se_ratio: Optional[float] = None,
) -> None:
    self.depths = depths
    self.widths = widths
    self.group_widths = group_widths
    self.bottleneck_multipliers = bottleneck_multipliers
    self.strides = strides
    self.se_ratio = se_ratio
depths instance-attribute
depths = depths
widths instance-attribute
widths = widths
group_widths instance-attribute
group_widths = group_widths
bottleneck_multipliers instance-attribute
bottleneck_multipliers = bottleneck_multipliers
strides instance-attribute
strides = strides
se_ratio instance-attribute
se_ratio = se_ratio
from_init_params classmethod
from_init_params(depth: int, w_0: int, w_a: float, w_m: float, group_width: int, bottleneck_multiplier: float = 1.0, se_ratio: Optional[float] = None, **kwargs: Any) -> BlockParams

Programmatically compute all the per-block settings, given the RegNet parameters. The first step is to compute the quantized linear block parameters, in log space. Key parameters are: - w_a is the width progression slope - w_0 is the initial width - w_m is the width stepping in the log space In other terms log(block_width) = log(w_0) + w_m * block_capacity, with bock_capacity ramping up following the w_0 and w_a params. This block width is finally quantized to multiples of 8. The second step is to compute the parameters per stage, taking into account the skip connection and the final 1x1 convolutions. We use the fact that the output width is constant within a stage.

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@classmethod
def from_init_params(
    cls,
    depth: int,
    w_0: int,
    w_a: float,
    w_m: float,
    group_width: int,
    bottleneck_multiplier: float = 1.0,
    se_ratio: Optional[float] = None,
    **kwargs: Any,
) -> "BlockParams":
    """
    Programmatically compute all the per-block settings,
    given the RegNet parameters.
    The first step is to compute the quantized linear block parameters,
    in log space. Key parameters are:
    - `w_a` is the width progression slope
    - `w_0` is the initial width
    - `w_m` is the width stepping in the log space
    In other terms
    `log(block_width) = log(w_0) + w_m * block_capacity`,
    with `bock_capacity` ramping up following the w_0 and w_a params.
    This block width is finally quantized to multiples of 8.
    The second step is to compute the parameters per stage,
    taking into account the skip connection and the final 1x1 convolutions.
    We use the fact that the output width is constant within a stage.
    """

    QUANT = 8
    STRIDE = 2

    if w_a < 0 or w_0 <= 0 or w_m <= 1 or w_0 % 8 != 0:
        raise ValueError("Invalid RegNet settings")
    # Compute the block widths. Each stage has one unique block width
    widths_cont = torch.arange(depth) * w_a + w_0
    block_capacity = torch.round(torch.log(widths_cont / w_0) / math.log(w_m))
    block_widths = (
        (torch.round(torch.divide(w_0 * torch.pow(w_m, block_capacity), QUANT)) * QUANT)
        .int()
        .tolist()
    )
    num_stages = len(set(block_widths))

    # Convert to per stage parameters
    split_helper = zip(
        block_widths + [0],
        [0] + block_widths,
        block_widths + [0],
        [0] + block_widths,
    )
    splits = [w != wp or r != rp for w, wp, r, rp in split_helper]

    stage_widths = [w for w, t in zip(block_widths, splits[:-1]) if t]
    stage_depths = torch.diff(torch.tensor([d for d, t in enumerate(splits) if t])).int().tolist()

    strides = [STRIDE] * num_stages
    bottleneck_multipliers = [bottleneck_multiplier] * num_stages
    group_widths = [group_width] * num_stages

    # Adjust the compatibility of stage widths and group widths
    stage_widths, group_widths = cls._adjust_widths_groups_compatibilty(
        stage_widths, bottleneck_multipliers, group_widths
    )

    return cls(
        depths=stage_depths,
        widths=stage_widths,
        group_widths=group_widths,
        bottleneck_multipliers=bottleneck_multipliers,
        strides=strides,
        se_ratio=se_ratio,
    )
_get_expanded_params
_get_expanded_params()
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def _get_expanded_params(self):
    return zip(
        self.widths, self.strides, self.depths, self.group_widths, self.bottleneck_multipliers
    )
_adjust_widths_groups_compatibilty staticmethod
_adjust_widths_groups_compatibilty(stage_widths: List[int], bottleneck_ratios: List[float], group_widths: List[int]) -> Tuple[List[int], List[int]]

Adjusts the compatibility of widths and groups, depending on the bottleneck ratio.

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@staticmethod
def _adjust_widths_groups_compatibilty(
    stage_widths: List[int], bottleneck_ratios: List[float], group_widths: List[int]
) -> Tuple[List[int], List[int]]:
    """
    Adjusts the compatibility of widths and groups,
    depending on the bottleneck ratio.
    """
    # Compute all widths for the current settings
    widths = [int(w * b) for w, b in zip(stage_widths, bottleneck_ratios)]
    group_widths_min = [min(g, w_bot) for g, w_bot in zip(group_widths, widths)]

    # Compute the adjusted widths so that stage and group widths fit
    ws_bot = [_make_divisible(w_bot, g) for w_bot, g in zip(widths, group_widths_min)]
    stage_widths = [int(w_bot / b) for w_bot, b in zip(ws_bot, bottleneck_ratios)]
    return stage_widths, group_widths_min

RegNet

RegNet(block_params: BlockParams, num_classes: int = 1000, stem_width: int = 32, stem_type: Optional[Callable[..., Module]] = None, block_type: Optional[Callable[..., Module]] = None, norm_layer: Optional[Callable[..., Module]] = None, activation: Optional[Callable[..., Module]] = None, in_channels: int = 3)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def __init__(
    self,
    block_params: BlockParams,
    num_classes: int = 1000,
    stem_width: int = 32,
    stem_type: Optional[Callable[..., nn.Module]] = None,
    block_type: Optional[Callable[..., nn.Module]] = None,
    norm_layer: Optional[Callable[..., nn.Module]] = None,
    activation: Optional[Callable[..., nn.Module]] = None,
    in_channels: int = 3,
) -> None:
    super().__init__()
    _log_api_usage_once(self)

    if stem_type is None:
        stem_type = SimpleStemIN
    if norm_layer is None:
        norm_layer = nn.BatchNorm2d
    if block_type is None:
        block_type = ResBottleneckBlock
    if activation is None:
        activation = nn.ReLU

    self.in_channels = in_channels

    # Ad hoc stem
    self.stem = stem_type(
        self.in_channels,  # width_in
        stem_width,
        norm_layer,
        activation,
    )

    current_width = stem_width

    blocks = []
    for i, (
        width_out,
        stride,
        depth,
        group_width,
        bottleneck_multiplier,
    ) in enumerate(block_params._get_expanded_params()):
        blocks.append(
            (
                f"block{i+1}",
                AnyStage(
                    current_width,
                    width_out,
                    stride,
                    depth,
                    block_type,
                    norm_layer,
                    activation,
                    group_width,
                    bottleneck_multiplier,
                    block_params.se_ratio,
                    stage_index=i + 1,
                ),
            )
        )

        current_width = width_out

    self.trunk_output = nn.Sequential(OrderedDict(blocks))

    # Performs ResNet-style weight initialization
    for m in self.modules():
        if isinstance(m, nn.Conv2d):
            # Note that there is no bias due to BN
            fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
            nn.init.normal_(m.weight, mean=0.0, std=math.sqrt(2.0 / fan_out))
        elif isinstance(m, nn.BatchNorm2d):
            nn.init.ones_(m.weight)
            nn.init.zeros_(m.bias)
        elif isinstance(m, nn.Linear):
            nn.init.normal_(m.weight, mean=0.0, std=0.01)
            nn.init.zeros_(m.bias)
in_channels instance-attribute
in_channels = in_channels
stem instance-attribute
stem = stem_type(in_channels, stem_width, norm_layer, activation)
trunk_output instance-attribute
trunk_output = Sequential(OrderedDict(blocks))
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def forward(self, x: Tensor) -> Tensor:
    x = self.stem(x)
    x = self.trunk_output(x)
    return x
load_state_dict
load_state_dict(state_dict, strict: bool = True)
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def load_state_dict(self, state_dict, strict: bool = True):
    extend_state_dict_input_channel(state_dict, "stem.0.weight", self.stem[0])
    for key in list(state_dict):
        if key.startswith("fc."):
            state_dict.pop(key)
    return super().load_state_dict(state_dict, strict)

_regnet

_regnet(block_params: BlockParams, weights: Optional[WeightsEnum], progress: bool, **kwargs: Any) -> RegNet
Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
def _regnet(
    block_params: BlockParams,
    weights: Optional[WeightsEnum],
    progress: bool,
    **kwargs: Any,
) -> RegNet:
    if weights is not None:
        _ovewrite_named_param(kwargs, "num_classes", len(weights.meta["categories"]))

    norm_layer = kwargs.pop("norm_layer", partial(nn.BatchNorm2d, eps=1e-05, momentum=0.1))
    model = RegNet(block_params, norm_layer=norm_layer, **kwargs)

    if weights is not None:
        model.load_state_dict(weights.get_state_dict(progress=progress))

    return model

regnet_y_400mf

regnet_y_400mf(*, weights: Optional[RegNet_Y_400MF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_400MF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_400MF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_400MF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_400MF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_400MF_Weights.IMAGENET1K_V1))
def regnet_y_400mf(
    *, weights: Optional[RegNet_Y_400MF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_400MF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_400MF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_400MF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_400MF_Weights
        :members:
    """
    weights = RegNet_Y_400MF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=16, w_0=48, w_a=27.89, w_m=2.09, group_width=8, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_800mf

regnet_y_800mf(*, weights: Optional[RegNet_Y_800MF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_800MF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_800MF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_800MF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_800MF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_800MF_Weights.IMAGENET1K_V1))
def regnet_y_800mf(
    *, weights: Optional[RegNet_Y_800MF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_800MF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_800MF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_800MF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_800MF_Weights
        :members:
    """
    weights = RegNet_Y_800MF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=14, w_0=56, w_a=38.84, w_m=2.4, group_width=16, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_1_6gf

regnet_y_1_6gf(*, weights: Optional[RegNet_Y_1_6GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_1.6GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_1_6GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_1_6GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_1_6GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_1_6GF_Weights.IMAGENET1K_V1))
def regnet_y_1_6gf(
    *, weights: Optional[RegNet_Y_1_6GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_1.6GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_1_6GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_1_6GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_1_6GF_Weights
        :members:
    """
    weights = RegNet_Y_1_6GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=27, w_0=48, w_a=20.71, w_m=2.65, group_width=24, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_3_2gf

regnet_y_3_2gf(*, weights: Optional[RegNet_Y_3_2GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_3.2GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_3_2GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_3_2GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_3_2GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_3_2GF_Weights.IMAGENET1K_V1))
def regnet_y_3_2gf(
    *, weights: Optional[RegNet_Y_3_2GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_3.2GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_3_2GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_3_2GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_3_2GF_Weights
        :members:
    """
    weights = RegNet_Y_3_2GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=21, w_0=80, w_a=42.63, w_m=2.66, group_width=24, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_8gf

regnet_y_8gf(*, weights: Optional[RegNet_Y_8GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_8GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_8GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_8GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_8GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_8GF_Weights.IMAGENET1K_V1))
def regnet_y_8gf(
    *, weights: Optional[RegNet_Y_8GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_8GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_8GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_8GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_8GF_Weights
        :members:
    """
    weights = RegNet_Y_8GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=17, w_0=192, w_a=76.82, w_m=2.19, group_width=56, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_16gf

regnet_y_16gf(*, weights: Optional[RegNet_Y_16GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_16GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_16GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_16GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_16GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_16GF_Weights.IMAGENET1K_V1))
def regnet_y_16gf(
    *, weights: Optional[RegNet_Y_16GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_16GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_16GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_16GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_16GF_Weights
        :members:
    """
    weights = RegNet_Y_16GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=18, w_0=200, w_a=106.23, w_m=2.48, group_width=112, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_32gf

regnet_y_32gf(*, weights: Optional[RegNet_Y_32GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_32GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_32GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_32GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_32GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_Y_32GF_Weights.IMAGENET1K_V1))
def regnet_y_32gf(
    *, weights: Optional[RegNet_Y_32GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_32GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_32GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_32GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_32GF_Weights
        :members:
    """
    weights = RegNet_Y_32GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=20, w_0=232, w_a=115.89, w_m=2.53, group_width=232, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_y_128gf

regnet_y_128gf(*, weights: Optional[RegNet_Y_128GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetY_128GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_Y_128GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_Y_128GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_Y_128GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", None))
def regnet_y_128gf(
    *, weights: Optional[RegNet_Y_128GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetY_128GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_Y_128GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_Y_128GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_Y_128GF_Weights
        :members:
    """
    weights = RegNet_Y_128GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=27, w_0=456, w_a=160.83, w_m=2.52, group_width=264, se_ratio=0.25, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_400mf

regnet_x_400mf(*, weights: Optional[RegNet_X_400MF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_400MF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_400MF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_400MF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_400MF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_400MF_Weights.IMAGENET1K_V1))
def regnet_x_400mf(
    *, weights: Optional[RegNet_X_400MF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_400MF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_400MF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_400MF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_400MF_Weights
        :members:
    """
    weights = RegNet_X_400MF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=22, w_0=24, w_a=24.48, w_m=2.54, group_width=16, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_800mf

regnet_x_800mf(*, weights: Optional[RegNet_X_800MF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_800MF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_800MF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_800MF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_800MF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_800MF_Weights.IMAGENET1K_V1))
def regnet_x_800mf(
    *, weights: Optional[RegNet_X_800MF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_800MF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_800MF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_800MF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_800MF_Weights
        :members:
    """
    weights = RegNet_X_800MF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=16, w_0=56, w_a=35.73, w_m=2.28, group_width=16, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_1_6gf

regnet_x_1_6gf(*, weights: Optional[RegNet_X_1_6GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_1.6GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_1_6GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_1_6GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_1_6GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_1_6GF_Weights.IMAGENET1K_V1))
def regnet_x_1_6gf(
    *, weights: Optional[RegNet_X_1_6GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_1.6GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_1_6GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_1_6GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_1_6GF_Weights
        :members:
    """
    weights = RegNet_X_1_6GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=18, w_0=80, w_a=34.01, w_m=2.25, group_width=24, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_3_2gf

regnet_x_3_2gf(*, weights: Optional[RegNet_X_3_2GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_3.2GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_3_2GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_3_2GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_3_2GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_3_2GF_Weights.IMAGENET1K_V1))
def regnet_x_3_2gf(
    *, weights: Optional[RegNet_X_3_2GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_3.2GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_3_2GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_3_2GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_3_2GF_Weights
        :members:
    """
    weights = RegNet_X_3_2GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=25, w_0=88, w_a=26.31, w_m=2.25, group_width=48, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_8gf

regnet_x_8gf(*, weights: Optional[RegNet_X_8GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_8GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_8GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_8GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_8GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_8GF_Weights.IMAGENET1K_V1))
def regnet_x_8gf(
    *, weights: Optional[RegNet_X_8GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_8GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_8GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_8GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_8GF_Weights
        :members:
    """
    weights = RegNet_X_8GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=23, w_0=80, w_a=49.56, w_m=2.88, group_width=120, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_16gf

regnet_x_16gf(*, weights: Optional[RegNet_X_16GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_16GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_16GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_16GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_16GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_16GF_Weights.IMAGENET1K_V1))
def regnet_x_16gf(
    *, weights: Optional[RegNet_X_16GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_16GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_16GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_16GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_16GF_Weights
        :members:
    """
    weights = RegNet_X_16GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=22, w_0=216, w_a=55.59, w_m=2.1, group_width=128, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

regnet_x_32gf

regnet_x_32gf(*, weights: Optional[RegNet_X_32GF_Weights] = None, progress: bool = True, **kwargs: Any) -> RegNet

Constructs a RegNetX_32GF architecture from Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>. Args: weights (:class:~torchvision.models.RegNet_X_32GF_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.RegNet_X_32GF_Weights below for more details and possible values. By default, no pretrained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to either torchvision.models.regnet.RegNet or torchvision.models.regnet.BlockParams class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py> for more detail about the classes. .. autoclass:: torchvision.models.RegNet_X_32GF_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/regnet.py
@handle_legacy_interface(weights=("pretrained", RegNet_X_32GF_Weights.IMAGENET1K_V1))
def regnet_x_32gf(
    *, weights: Optional[RegNet_X_32GF_Weights] = None, progress: bool = True, **kwargs: Any
) -> RegNet:
    """
    Constructs a RegNetX_32GF architecture from
    `Designing Network Design Spaces <https://arxiv.org/abs/2003.13678>`_.
    Args:
        weights (:class:`~torchvision.models.RegNet_X_32GF_Weights`, optional): The pretrained weights to use.
            See :class:`~torchvision.models.RegNet_X_32GF_Weights` below for more details and possible values.
            By default, no pretrained weights are used.
        progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to either ``torchvision.models.regnet.RegNet`` or
            ``torchvision.models.regnet.BlockParams`` class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py>`_
            for more detail about the classes.
    .. autoclass:: torchvision.models.RegNet_X_32GF_Weights
        :members:
    """
    weights = RegNet_X_32GF_Weights.verify(weights)

    params = BlockParams.from_init_params(
        depth=23, w_0=320, w_a=69.86, w_m=2.0, group_width=168, **kwargs
    )
    return _regnet(params, weights, progress, **kwargs)

resnet

__all__ module-attribute

__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'resnext101_64x4d', 'wide_resnet50_2', 'wide_resnet101_2']

BasicBlock

BasicBlock(inplanes: int, planes: int, stride: int = 1, downsample: Optional[Module] = None, groups: int = 1, base_width: int = 64, dilation: int = 1, norm_layer: Optional[Callable[..., Module]] = None)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def __init__(
    self,
    inplanes: int,
    planes: int,
    stride: int = 1,
    downsample: Optional[nn.Module] = None,
    groups: int = 1,
    base_width: int = 64,
    dilation: int = 1,
    norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
    super().__init__()
    if norm_layer is None:
        norm_layer = nn.BatchNorm2d
    if groups != 1 or base_width != 64:
        raise ValueError("BasicBlock only supports groups=1 and base_width=64")
    if dilation > 1:
        raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
    # Both self.conv1 and self.downsample layers downsample the input when stride != 1
    self.conv1 = conv3x3(inplanes, planes, stride)
    self.bn1 = norm_layer(planes)
    self.relu = nn.ReLU(inplace=True)
    self.conv2 = conv3x3(planes, planes)
    self.bn2 = norm_layer(planes)
    self.downsample = downsample
    self.stride = stride
expansion class-attribute instance-attribute
expansion: int = 1
conv1 instance-attribute
conv1 = conv3x3(inplanes, planes, stride)
bn1 instance-attribute
bn1 = norm_layer(planes)
relu instance-attribute
relu = ReLU(inplace=True)
conv2 instance-attribute
conv2 = conv3x3(planes, planes)
bn2 instance-attribute
bn2 = norm_layer(planes)
downsample instance-attribute
downsample = downsample
stride instance-attribute
stride = stride
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def forward(self, x: Tensor) -> Tensor:
    identity = x

    out = self.conv1(x)
    out = self.bn1(out)
    out = self.relu(out)

    out = self.conv2(out)
    out = self.bn2(out)

    if self.downsample is not None:
        identity = self.downsample(x)

    out += identity
    out = self.relu(out)

    return out

Bottleneck

Bottleneck(inplanes: int, planes: int, stride: int = 1, downsample: Optional[Module] = None, groups: int = 1, base_width: int = 64, dilation: int = 1, norm_layer: Optional[Callable[..., Module]] = None)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def __init__(
    self,
    inplanes: int,
    planes: int,
    stride: int = 1,
    downsample: Optional[nn.Module] = None,
    groups: int = 1,
    base_width: int = 64,
    dilation: int = 1,
    norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
    super().__init__()
    if norm_layer is None:
        norm_layer = nn.BatchNorm2d
    width = int(planes * (base_width / 64.0)) * groups
    # Both self.conv2 and self.downsample layers downsample the input when stride != 1
    self.conv1 = conv1x1(inplanes, width)
    self.bn1 = norm_layer(width)
    self.conv2 = conv3x3(width, width, stride, groups, dilation)
    self.bn2 = norm_layer(width)
    self.conv3 = conv1x1(width, planes * self.expansion)
    self.bn3 = norm_layer(planes * self.expansion)
    self.relu = nn.ReLU(inplace=True)
    self.downsample = downsample
    self.stride = stride
expansion class-attribute instance-attribute
expansion: int = 4
conv1 instance-attribute
conv1 = conv1x1(inplanes, width)
bn1 instance-attribute
bn1 = norm_layer(width)
conv2 instance-attribute
conv2 = conv3x3(width, width, stride, groups, dilation)
bn2 instance-attribute
bn2 = norm_layer(width)
conv3 instance-attribute
conv3 = conv1x1(width, planes * expansion)
bn3 instance-attribute
bn3 = norm_layer(planes * expansion)
relu instance-attribute
relu = ReLU(inplace=True)
downsample instance-attribute
downsample = downsample
stride instance-attribute
stride = stride
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def forward(self, x: Tensor) -> Tensor:
    identity = x

    out = self.conv1(x)
    out = self.bn1(out)
    out = self.relu(out)

    out = self.conv2(out)
    out = self.bn2(out)
    out = self.relu(out)

    out = self.conv3(out)
    out = self.bn3(out)

    if self.downsample is not None:
        identity = self.downsample(x)

    out += identity
    out = self.relu(out)

    return out

ResNet

ResNet(block: Type[Union[BasicBlock, Bottleneck]], layers: List[int], num_classes: int = 1000, zero_init_residual: bool = False, groups: int = 1, width_per_group: int = 64, replace_stride_with_dilation: Optional[List[bool]] = None, norm_layer: Optional[Callable[..., Module]] = None, in_channels: int = 3)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def __init__(
    self,
    block: Type[Union[BasicBlock, Bottleneck]],
    layers: List[int],
    num_classes: int = 1000,
    zero_init_residual: bool = False,
    groups: int = 1,
    width_per_group: int = 64,
    replace_stride_with_dilation: Optional[List[bool]] = None,
    norm_layer: Optional[Callable[..., nn.Module]] = None,
    in_channels: int = 3,
) -> None:
    super().__init__()
    _log_api_usage_once(self)
    if norm_layer is None:
        norm_layer = nn.BatchNorm2d
    self._norm_layer = norm_layer
    self.in_channels = in_channels

    self.inplanes = 64
    self.dilation = 1
    if replace_stride_with_dilation is None:
        # each element in the tuple indicates if we should replace
        # the 2x2 stride with a dilated convolution instead
        replace_stride_with_dilation = [False, False, False]
    if len(replace_stride_with_dilation) != 3:
        raise ValueError(
            "replace_stride_with_dilation should be None "
            f"or a 3-element tuple, got {replace_stride_with_dilation}"
        )
    self.groups = groups
    self.base_width = width_per_group
    self.conv1 = nn.Conv2d(
        self.in_channels, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False
    )
    self.bn1 = norm_layer(self.inplanes)
    self.relu = nn.ReLU(inplace=True)
    self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
    self.layer1 = self._make_layer(block, 64, layers[0])
    self.layer2 = self._make_layer(
        block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]
    )
    self.layer3 = self._make_layer(
        block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]
    )
    self.layer4 = self._make_layer(
        block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]
    )

    for m in self.modules():
        if isinstance(m, nn.Conv2d):
            nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
        elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
            nn.init.constant_(m.weight, 1)
            nn.init.constant_(m.bias, 0)

    # Zero-initialize the last BN in each residual branch,
    # so that the residual branch starts with zeros, and each residual block behaves like an identity.
    # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
    if zero_init_residual:
        for m in self.modules():
            if isinstance(m, Bottleneck) and m.bn3.weight is not None:
                nn.init.constant_(m.bn3.weight, 0)  # type: ignore[arg-type]
            elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
                nn.init.constant_(m.bn2.weight, 0)  # type: ignore[arg-type]
_norm_layer instance-attribute
_norm_layer = norm_layer
in_channels instance-attribute
in_channels = in_channels
inplanes instance-attribute
inplanes = 64
dilation instance-attribute
dilation = 1
groups instance-attribute
groups = groups
base_width instance-attribute
base_width = width_per_group
conv1 instance-attribute
conv1 = Conv2d(in_channels, inplanes, kernel_size=7, stride=2, padding=3, bias=False)
bn1 instance-attribute
bn1 = norm_layer(inplanes)
relu instance-attribute
relu = ReLU(inplace=True)
maxpool instance-attribute
maxpool = MaxPool2d(kernel_size=3, stride=2, padding=1)
layer1 instance-attribute
layer1 = _make_layer(block, 64, layers[0])
layer2 instance-attribute
layer2 = _make_layer(block, 128, layers[1], stride=2, dilate=(replace_stride_with_dilation[0]))
layer3 instance-attribute
layer3 = _make_layer(block, 256, layers[2], stride=2, dilate=(replace_stride_with_dilation[1]))
layer4 instance-attribute
layer4 = _make_layer(block, 512, layers[3], stride=2, dilate=(replace_stride_with_dilation[2]))
_make_layer
_make_layer(block: Type[Union[BasicBlock, Bottleneck]], planes: int, blocks: int, stride: int = 1, dilate: bool = False) -> Sequential
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def _make_layer(
    self,
    block: Type[Union[BasicBlock, Bottleneck]],
    planes: int,
    blocks: int,
    stride: int = 1,
    dilate: bool = False,
) -> nn.Sequential:
    norm_layer = self._norm_layer
    downsample = None
    previous_dilation = self.dilation
    if dilate:
        self.dilation *= stride
        stride = 1
    if stride != 1 or self.inplanes != planes * block.expansion:
        downsample = nn.Sequential(
            conv1x1(self.inplanes, planes * block.expansion, stride),
            norm_layer(planes * block.expansion),
        )

    layers = []
    layers.append(
        block(
            self.inplanes,
            planes,
            stride,
            downsample,
            self.groups,
            self.base_width,
            previous_dilation,
            norm_layer,
        )
    )
    self.inplanes = planes * block.expansion
    for _ in range(1, blocks):
        layers.append(
            block(
                self.inplanes,
                planes,
                groups=self.groups,
                base_width=self.base_width,
                dilation=self.dilation,
                norm_layer=norm_layer,
            )
        )

    return nn.Sequential(*layers)
_forward_impl
_forward_impl(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def _forward_impl(self, x: Tensor) -> Tensor:
    # See note [TorchScript super()]
    x = self.conv1(x)
    x = self.bn1(x)
    x = self.relu(x)
    x = self.maxpool(x)

    x = self.layer1(x)
    x = self.layer2(x)
    x = self.layer3(x)
    x = self.layer4(x)

    return x
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def forward(self, x: Tensor) -> Tensor:
    return self._forward_impl(x)
load_state_dict
load_state_dict(state_dict, strict: bool = True)
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def load_state_dict(self, state_dict, strict: bool = True):
    extend_state_dict_input_channel(state_dict, "conv1.weight", self.conv1)
    for key in list(state_dict):
        if key.startswith("fc."):
            state_dict.pop(key)
    return super().load_state_dict(state_dict, strict)

conv3x3

conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> Conv2d

3x3 convolution with padding

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def conv3x3(
    in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1
) -> nn.Conv2d:
    """3x3 convolution with padding"""
    return nn.Conv2d(
        in_planes,
        out_planes,
        kernel_size=3,
        stride=stride,
        padding=dilation,
        groups=groups,
        bias=False,
        dilation=dilation,
    )

conv1x1

conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> Conv2d

1x1 convolution

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:
    """1x1 convolution"""
    return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)

_resnet

_resnet(block: Type[Union[BasicBlock, Bottleneck]], layers: List[int], weights: Optional[WeightsEnum], progress: bool, **kwargs: Any) -> ResNet
Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def _resnet(
    block: Type[Union[BasicBlock, Bottleneck]],
    layers: List[int],
    weights: Optional[WeightsEnum],
    progress: bool,
    **kwargs: Any,
) -> ResNet:
    if weights is not None:
        _ovewrite_named_param(kwargs, "num_classes", len(weights.meta["categories"]))

    model = ResNet(block, layers, **kwargs)

    if weights is not None:
        model.load_state_dict(weights.get_state_dict(progress=progress))

    return model

resnet18

resnet18(*, weights: Optional[ResNet18_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNet-18 from Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>__.

Parameters:

  • weights (

    class:~torchvision.models.ResNet18_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNet18_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNet18_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNet18_Weights.IMAGENET1K_V1))
def resnet18(
    *, weights: Optional[ResNet18_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNet-18 from `Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>`__.

    Args:
        weights (:class:`~torchvision.models.ResNet18_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNet18_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.ResNet18_Weights
        :members:
    """
    weights = ResNet18_Weights.verify(weights)

    return _resnet(BasicBlock, [2, 2, 2, 2], weights, progress, **kwargs)

resnet34

resnet34(*, weights: Optional[ResNet34_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNet-34 from Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>__.

Parameters:

  • weights (

    class:~torchvision.models.ResNet34_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNet34_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNet34_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNet34_Weights.IMAGENET1K_V1))
def resnet34(
    *, weights: Optional[ResNet34_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNet-34 from `Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>`__.

    Args:
        weights (:class:`~torchvision.models.ResNet34_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNet34_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.ResNet34_Weights
        :members:
    """
    weights = ResNet34_Weights.verify(weights)

    return _resnet(BasicBlock, [3, 4, 6, 3], weights, progress, **kwargs)

resnet50

resnet50(*, weights: Optional[ResNet50_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNet-50 from Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>__.

.. note:: The bottleneck of TorchVision places the stride for downsampling to the second 3x3 convolution while the original paper places it to the first 1x1 convolution. This variant improves the accuracy and is known as ResNet V1.5 <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNet50_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNet50_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNet50_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNet50_Weights.IMAGENET1K_V1))
def resnet50(
    *, weights: Optional[ResNet50_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNet-50 from `Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>`__.

    .. note::
       The bottleneck of TorchVision places the stride for downsampling to the second 3x3
       convolution while the original paper places it to the first 1x1 convolution.
       This variant improves the accuracy and is known as `ResNet V1.5
       <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>`_.

    Args:
        weights (:class:`~torchvision.models.ResNet50_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNet50_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.ResNet50_Weights
        :members:
    """
    weights = ResNet50_Weights.verify(weights)

    return _resnet(Bottleneck, [3, 4, 6, 3], weights, progress, **kwargs)

resnet101

resnet101(*, weights: Optional[ResNet101_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNet-101 from Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>__.

.. note:: The bottleneck of TorchVision places the stride for downsampling to the second 3x3 convolution while the original paper places it to the first 1x1 convolution. This variant improves the accuracy and is known as ResNet V1.5 <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNet101_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNet101_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNet101_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNet101_Weights.IMAGENET1K_V1))
def resnet101(
    *, weights: Optional[ResNet101_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNet-101 from `Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>`__.

    .. note::
       The bottleneck of TorchVision places the stride for downsampling to the second 3x3
       convolution while the original paper places it to the first 1x1 convolution.
       This variant improves the accuracy and is known as `ResNet V1.5
       <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>`_.

    Args:
        weights (:class:`~torchvision.models.ResNet101_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNet101_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.ResNet101_Weights
        :members:
    """
    weights = ResNet101_Weights.verify(weights)

    return _resnet(Bottleneck, [3, 4, 23, 3], weights, progress, **kwargs)

resnet152

resnet152(*, weights: Optional[ResNet152_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNet-152 from Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>__.

.. note:: The bottleneck of TorchVision places the stride for downsampling to the second 3x3 convolution while the original paper places it to the first 1x1 convolution. This variant improves the accuracy and is known as ResNet V1.5 <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNet152_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNet152_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNet152_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNet152_Weights.IMAGENET1K_V1))
def resnet152(
    *, weights: Optional[ResNet152_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNet-152 from `Deep Residual Learning for Image Recognition <https://arxiv.org/pdf/1512.03385.pdf>`__.

    .. note::
       The bottleneck of TorchVision places the stride for downsampling to the second 3x3
       convolution while the original paper places it to the first 1x1 convolution.
       This variant improves the accuracy and is known as `ResNet V1.5
       <https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch>`_.

    Args:
        weights (:class:`~torchvision.models.ResNet152_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNet152_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.ResNet152_Weights
        :members:
    """
    weights = ResNet152_Weights.verify(weights)

    return _resnet(Bottleneck, [3, 8, 36, 3], weights, progress, **kwargs)

resnext50_32x4d

resnext50_32x4d(*, weights: Optional[ResNeXt50_32X4D_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNeXt-50 32x4d model from Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNeXt50_32X4D_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNext50_32X4D_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNeXt50_32X4D_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNeXt50_32X4D_Weights.IMAGENET1K_V1))
def resnext50_32x4d(
    *, weights: Optional[ResNeXt50_32X4D_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNeXt-50 32x4d model from
    `Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>`_.

    Args:
        weights (:class:`~torchvision.models.ResNeXt50_32X4D_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNext50_32X4D_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.
    .. autoclass:: torchvision.models.ResNeXt50_32X4D_Weights
        :members:
    """
    weights = ResNeXt50_32X4D_Weights.verify(weights)

    _ovewrite_named_param(kwargs, "groups", 32)
    _ovewrite_named_param(kwargs, "width_per_group", 4)
    return _resnet(Bottleneck, [3, 4, 6, 3], weights, progress, **kwargs)

resnext101_32x8d

resnext101_32x8d(*, weights: Optional[ResNeXt101_32X8D_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNeXt-101 32x8d model from Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNeXt101_32X8D_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNeXt101_32X8D_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNeXt101_32X8D_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", ResNeXt101_32X8D_Weights.IMAGENET1K_V1))
def resnext101_32x8d(
    *, weights: Optional[ResNeXt101_32X8D_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNeXt-101 32x8d model from
    `Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>`_.

    Args:
        weights (:class:`~torchvision.models.ResNeXt101_32X8D_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNeXt101_32X8D_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.
    .. autoclass:: torchvision.models.ResNeXt101_32X8D_Weights
        :members:
    """
    weights = ResNeXt101_32X8D_Weights.verify(weights)

    _ovewrite_named_param(kwargs, "groups", 32)
    _ovewrite_named_param(kwargs, "width_per_group", 8)
    return _resnet(Bottleneck, [3, 4, 23, 3], weights, progress, **kwargs)

resnext101_64x4d

resnext101_64x4d(*, weights: Optional[ResNeXt101_64X4D_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

ResNeXt-101 64x4d model from Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>_.

Parameters:

  • weights (

    class:~torchvision.models.ResNeXt101_64X4D_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.ResNeXt101_64X4D_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.ResNeXt101_64X4D_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
def resnext101_64x4d(
    *, weights: Optional[ResNeXt101_64X4D_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """ResNeXt-101 64x4d model from
    `Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431>`_.

    Args:
        weights (:class:`~torchvision.models.ResNeXt101_64X4D_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.ResNeXt101_64X4D_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.
    .. autoclass:: torchvision.models.ResNeXt101_64X4D_Weights
        :members:
    """
    weights = ResNeXt101_64X4D_Weights.verify(weights)

    _ovewrite_named_param(kwargs, "groups", 64)
    _ovewrite_named_param(kwargs, "width_per_group", 4)
    return _resnet(Bottleneck, [3, 4, 23, 3], weights, progress, **kwargs)

wide_resnet50_2

wide_resnet50_2(*, weights: Optional[Wide_ResNet50_2_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

Wide ResNet-50-2 model from Wide Residual Networks <https://arxiv.org/abs/1605.07146>_.

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048.

Parameters:

  • weights (

    class:~torchvision.models.Wide_ResNet50_2_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.Wide_ResNet50_2_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.Wide_ResNet50_2_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", Wide_ResNet50_2_Weights.IMAGENET1K_V1))
def wide_resnet50_2(
    *, weights: Optional[Wide_ResNet50_2_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """Wide ResNet-50-2 model from
    `Wide Residual Networks <https://arxiv.org/abs/1605.07146>`_.

    The model is the same as ResNet except for the bottleneck number of channels
    which is twice larger in every block. The number of channels in outer 1x1
    convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048
    channels, and in Wide ResNet-50-2 has 2048-1024-2048.

    Args:
        weights (:class:`~torchvision.models.Wide_ResNet50_2_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.Wide_ResNet50_2_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.
    .. autoclass:: torchvision.models.Wide_ResNet50_2_Weights
        :members:
    """
    weights = Wide_ResNet50_2_Weights.verify(weights)

    _ovewrite_named_param(kwargs, "width_per_group", 64 * 2)
    return _resnet(Bottleneck, [3, 4, 6, 3], weights, progress, **kwargs)

wide_resnet101_2

wide_resnet101_2(*, weights: Optional[Wide_ResNet101_2_Weights] = None, progress: bool = True, **kwargs: Any) -> ResNet

Wide ResNet-101-2 model from Wide Residual Networks <https://arxiv.org/abs/1605.07146>_.

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-101 has 2048-512-2048 channels, and in Wide ResNet-101-2 has 2048-1024-2048.

Parameters:

  • weights (

    class:~torchvision.models.Wide_ResNet101_2_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.Wide_ResNet101_2_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>_ for more details about this class.

.. autoclass:: torchvision.models.Wide_ResNet101_2_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/resnet.py
@handle_legacy_interface(weights=("pretrained", Wide_ResNet101_2_Weights.IMAGENET1K_V1))
def wide_resnet101_2(
    *, weights: Optional[Wide_ResNet101_2_Weights] = None, progress: bool = True, **kwargs: Any
) -> ResNet:
    """Wide ResNet-101-2 model from
    `Wide Residual Networks <https://arxiv.org/abs/1605.07146>`_.

    The model is the same as ResNet except for the bottleneck number of channels
    which is twice larger in every block. The number of channels in outer 1x1
    convolutions is the same, e.g. last block in ResNet-101 has 2048-512-2048
    channels, and in Wide ResNet-101-2 has 2048-1024-2048.

    Args:
        weights (:class:`~torchvision.models.Wide_ResNet101_2_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.Wide_ResNet101_2_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.resnet.ResNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py>`_
            for more details about this class.
    .. autoclass:: torchvision.models.Wide_ResNet101_2_Weights
        :members:
    """
    weights = Wide_ResNet101_2_Weights.verify(weights)

    _ovewrite_named_param(kwargs, "width_per_group", 64 * 2)
    return _resnet(Bottleneck, [3, 4, 23, 3], weights, progress, **kwargs)

squeezenet

__all__ module-attribute

__all__ = ['SqueezeNet', 'squeezenet1_0', 'squeezenet1_1']

Fire

Fire(inplanes: int, squeeze_planes: int, expand1x1_planes: int, expand3x3_planes: int)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def __init__(
    self, inplanes: int, squeeze_planes: int, expand1x1_planes: int, expand3x3_planes: int
) -> None:
    super().__init__()
    self.inplanes = inplanes
    self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1)
    self.squeeze_activation = nn.ReLU(inplace=True)
    self.expand1x1 = nn.Conv2d(squeeze_planes, expand1x1_planes, kernel_size=1)
    self.expand1x1_activation = nn.ReLU(inplace=True)
    self.expand3x3 = nn.Conv2d(squeeze_planes, expand3x3_planes, kernel_size=3, padding=1)
    self.expand3x3_activation = nn.ReLU(inplace=True)
inplanes instance-attribute
inplanes = inplanes
squeeze instance-attribute
squeeze = Conv2d(inplanes, squeeze_planes, kernel_size=1)
squeeze_activation instance-attribute
squeeze_activation = ReLU(inplace=True)
expand1x1 instance-attribute
expand1x1 = Conv2d(squeeze_planes, expand1x1_planes, kernel_size=1)
expand1x1_activation instance-attribute
expand1x1_activation = ReLU(inplace=True)
expand3x3 instance-attribute
expand3x3 = Conv2d(squeeze_planes, expand3x3_planes, kernel_size=3, padding=1)
expand3x3_activation instance-attribute
expand3x3_activation = ReLU(inplace=True)
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def forward(self, x: torch.Tensor) -> torch.Tensor:
    x = self.squeeze_activation(self.squeeze(x))
    return torch.cat(
        [self.expand1x1_activation(self.expand1x1(x)), self.expand3x3_activation(self.expand3x3(x))],
        1,
    )

SqueezeNet

SqueezeNet(version: str = '1_0', num_classes: int = 1000, dropout: float = 0.5, in_channels: int = 3)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def __init__(
    self,
    version: str = "1_0",
    num_classes: int = 1000,
    dropout: float = 0.5,
    in_channels: int = 3,
) -> None:
    super().__init__()
    _log_api_usage_once(self)
    self.num_classes = num_classes
    self.in_channels = in_channels
    if version == "1_0":
        self.features = nn.Sequential(
            nn.Conv2d(self.in_channels, 96, kernel_size=7, stride=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(96, 16, 64, 64),
            Fire(128, 16, 64, 64),
            Fire(128, 32, 128, 128),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(256, 32, 128, 128),
            Fire(256, 48, 192, 192),
            Fire(384, 48, 192, 192),
            Fire(384, 64, 256, 256),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(512, 64, 256, 256),
        )
    elif version == "1_1":
        self.features = nn.Sequential(
            nn.Conv2d(self.in_channels, 64, kernel_size=3, stride=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(64, 16, 64, 64),
            Fire(128, 16, 64, 64),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(128, 32, 128, 128),
            Fire(256, 32, 128, 128),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(256, 48, 192, 192),
            Fire(384, 48, 192, 192),
            Fire(384, 64, 256, 256),
            Fire(512, 64, 256, 256),
        )
    else:
        # FIXME: Is this needed? SqueezeNet should only be called from the
        # FIXME: squeezenet1_x() functions
        # FIXME: This checking is not done for the other models
        raise ValueError(f"Unsupported SqueezeNet version {version}: 1_0 or 1_1 expected")

    for m in self.modules():
        if isinstance(m, nn.Conv2d):
            init.kaiming_uniform_(m.weight)
            if m.bias is not None:
                init.constant_(m.bias, 0)
num_classes instance-attribute
num_classes = num_classes
in_channels instance-attribute
in_channels = in_channels
features instance-attribute
features = Sequential(Conv2d(in_channels, 96, kernel_size=7, stride=2), ReLU(inplace=True), MaxPool2d(kernel_size=3, stride=2, ceil_mode=True), Fire(96, 16, 64, 64), Fire(128, 16, 64, 64), Fire(128, 32, 128, 128), MaxPool2d(kernel_size=3, stride=2, ceil_mode=True), Fire(256, 32, 128, 128), Fire(256, 48, 192, 192), Fire(384, 48, 192, 192), Fire(384, 64, 256, 256), MaxPool2d(kernel_size=3, stride=2, ceil_mode=True), Fire(512, 64, 256, 256))
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def forward(self, x: torch.Tensor) -> torch.Tensor:
    x = self.features(x)
    return x
load_state_dict
load_state_dict(state_dict, strict: bool = True)
Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def load_state_dict(self, state_dict, strict: bool = True):
    extend_state_dict_input_channel(state_dict, "features.0.weight", self.features[0])
    for key in list(state_dict):
        if key.startswith("classifier."):
            state_dict.pop(key)
    return super().load_state_dict(state_dict, strict)

_squeezenet

_squeezenet(version: str, weights: Optional[WeightsEnum], progress: bool, **kwargs: Any) -> SqueezeNet
Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
def _squeezenet(
    version: str,
    weights: Optional[WeightsEnum],
    progress: bool,
    **kwargs: Any,
) -> SqueezeNet:
    if weights is not None:
        _ovewrite_named_param(kwargs, "num_classes", len(weights.meta["categories"]))

    model = SqueezeNet(version, **kwargs)

    if weights is not None:
        model.load_state_dict(weights.get_state_dict(progress=progress))

    return model

squeezenet1_0

squeezenet1_0(*, weights: Optional[SqueezeNet1_0_Weights] = None, progress: bool = True, **kwargs: Any) -> SqueezeNet

SqueezeNet model architecture from the SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size <https://arxiv.org/abs/1602.07360>_ paper.

Parameters:

  • weights (

    class:~torchvision.models.SqueezeNet1_0_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.SqueezeNet1_0_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.squeezenet.SqueezeNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>_ for more details about this class.

.. autoclass:: torchvision.models.SqueezeNet1_0_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
@handle_legacy_interface(weights=("pretrained", SqueezeNet1_0_Weights.IMAGENET1K_V1))
def squeezenet1_0(
    *, weights: Optional[SqueezeNet1_0_Weights] = None, progress: bool = True, **kwargs: Any
) -> SqueezeNet:
    """SqueezeNet model architecture from the `SqueezeNet: AlexNet-level
    accuracy with 50x fewer parameters and <0.5MB model size
    <https://arxiv.org/abs/1602.07360>`_ paper.

    Args:
        weights (:class:`~torchvision.models.SqueezeNet1_0_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.SqueezeNet1_0_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.squeezenet.SqueezeNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.SqueezeNet1_0_Weights
        :members:
    """
    weights = SqueezeNet1_0_Weights.verify(weights)
    return _squeezenet("1_0", weights, progress, **kwargs)

squeezenet1_1

squeezenet1_1(*, weights: Optional[SqueezeNet1_1_Weights] = None, progress: bool = True, **kwargs: Any) -> SqueezeNet

SqueezeNet 1.1 model from the official SqueezeNet repo <https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>_.

SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters than SqueezeNet 1.0, without sacrificing accuracy.

Parameters:

  • weights (

    class:~torchvision.models.SqueezeNet1_1_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.SqueezeNet1_1_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.squeezenet.SqueezeNet base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>_ for more details about this class.

.. autoclass:: torchvision.models.SqueezeNet1_1_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/squeezenet.py
@handle_legacy_interface(weights=("pretrained", SqueezeNet1_1_Weights.IMAGENET1K_V1))
def squeezenet1_1(
    *, weights: Optional[SqueezeNet1_1_Weights] = None, progress: bool = True, **kwargs: Any
) -> SqueezeNet:
    """SqueezeNet 1.1 model from the `official SqueezeNet repo
    <https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>`_.

    SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters
    than SqueezeNet 1.0, without sacrificing accuracy.

    Args:
        weights (:class:`~torchvision.models.SqueezeNet1_1_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.SqueezeNet1_1_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.squeezenet.SqueezeNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.SqueezeNet1_1_Weights
        :members:
    """
    weights = SqueezeNet1_1_Weights.verify(weights)
    return _squeezenet("1_1", weights, progress, **kwargs)

vgg

__all__ module-attribute

__all__ = ['VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn', 'vgg19', 'vgg19_bn']

cfgs module-attribute

cfgs: Dict[str, List[Union[str, int]]] = {'A': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'B': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'D': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512, 512, 512, 'M'], 'E': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512, 'M', 512, 512, 512, 512, 'M']}

VGG

VGG(features: Module, num_classes: int = 1000, init_weights: bool = True, dropout: float = 0.5)

Bases: Module

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
def __init__(
    self,
    features: nn.Module,
    num_classes: int = 1000,
    init_weights: bool = True,
    dropout: float = 0.5,
) -> None:
    super().__init__()
    _log_api_usage_once(self)
    self.features = features
    if init_weights:
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
                if m.bias is not None:
                    nn.init.constant_(m.bias, 0)
            elif isinstance(m, nn.BatchNorm2d):
                nn.init.constant_(m.weight, 1)
                nn.init.constant_(m.bias, 0)
            elif isinstance(m, nn.Linear):
                nn.init.normal_(m.weight, 0, 0.01)
                nn.init.constant_(m.bias, 0)
features instance-attribute
features = features
forward
forward(x: Tensor) -> Tensor
Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
def forward(self, x: torch.Tensor) -> torch.Tensor:
    x = self.features(x)
    return x
load_state_dict
load_state_dict(state_dict, strict: bool = True)
Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
def load_state_dict(self, state_dict, strict: bool = True):
    extend_state_dict_input_channel(state_dict, "features.0.weight", self.features[0])
    for key in list(state_dict):
        if key.startswith("classifier."):
            state_dict.pop(key)
    return super().load_state_dict(state_dict, strict)

make_layers

make_layers(cfg: List[Union[str, int]], batch_norm: bool = False, in_channels: int = 3) -> Sequential
Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
def make_layers(
    cfg: List[Union[str, int]], batch_norm: bool = False, in_channels: int = 3
) -> nn.Sequential:
    layers: List[nn.Module] = []
    for v in cfg:
        if v == "M":
            layers += [nn.MaxPool2d(kernel_size=2, stride=2)]
        else:
            v = cast(int, v)
            conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1)
            if batch_norm:
                layers += [conv2d, nn.BatchNorm2d(v), nn.ReLU(inplace=True)]
            else:
                layers += [conv2d, nn.ReLU(inplace=True)]
            in_channels = v
    return nn.Sequential(*layers)

_vgg

_vgg(cfg: str, batch_norm: bool, weights: Optional[WeightsEnum], progress: bool, in_channels: int = 3, **kwargs: Any) -> VGG
Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
def _vgg(
    cfg: str,
    batch_norm: bool,
    weights: Optional[WeightsEnum],
    progress: bool,
    in_channels: int = 3,
    **kwargs: Any,
) -> VGG:
    if weights is not None:
        kwargs["init_weights"] = False
        if weights.meta["categories"] is not None:
            _ovewrite_named_param(kwargs, "num_classes", len(weights.meta["categories"]))
    model = VGG(make_layers(cfgs[cfg], batch_norm=batch_norm, in_channels=in_channels), **kwargs)
    if weights is not None:
        model.load_state_dict(weights.get_state_dict(progress=progress))
    return model

vgg11

vgg11(*, weights: Optional[VGG11_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-11 from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG11_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG11_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG11_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG11_Weights.IMAGENET1K_V1))
def vgg11(*, weights: Optional[VGG11_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-11 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG11_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG11_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG11_Weights
        :members:
    """
    weights = VGG11_Weights.verify(weights)

    return _vgg("A", False, weights, progress, **kwargs)

vgg11_bn

vgg11_bn(*, weights: Optional[VGG11_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-11-BN from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG11_BN_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG11_BN_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG11_BN_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG11_BN_Weights.IMAGENET1K_V1))
def vgg11_bn(*, weights: Optional[VGG11_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-11-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG11_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG11_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG11_BN_Weights
        :members:
    """
    weights = VGG11_BN_Weights.verify(weights)

    return _vgg("A", True, weights, progress, **kwargs)

vgg13

vgg13(*, weights: Optional[VGG13_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-13 from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG13_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG13_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG13_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG13_Weights.IMAGENET1K_V1))
def vgg13(*, weights: Optional[VGG13_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-13 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG13_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG13_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG13_Weights
        :members:
    """
    weights = VGG13_Weights.verify(weights)

    return _vgg("B", False, weights, progress, **kwargs)

vgg13_bn

vgg13_bn(*, weights: Optional[VGG13_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-13-BN from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG13_BN_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG13_BN_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG13_BN_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG13_BN_Weights.IMAGENET1K_V1))
def vgg13_bn(*, weights: Optional[VGG13_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-13-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG13_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG13_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG13_BN_Weights
        :members:
    """
    weights = VGG13_BN_Weights.verify(weights)

    return _vgg("B", True, weights, progress, **kwargs)

vgg16

vgg16(*, weights: Optional[VGG16_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-16 from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG16_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG16_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG16_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG16_Weights.IMAGENET1K_V1))
def vgg16(*, weights: Optional[VGG16_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-16 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG16_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG16_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG16_Weights
        :members:
    """
    weights = VGG16_Weights.verify(weights)

    return _vgg("D", False, weights, progress, **kwargs)

vgg16_bn

vgg16_bn(*, weights: Optional[VGG16_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-16-BN from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG16_BN_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG16_BN_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG16_BN_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG16_BN_Weights.IMAGENET1K_V1))
def vgg16_bn(*, weights: Optional[VGG16_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-16-BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG16_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG16_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG16_BN_Weights
        :members:
    """
    weights = VGG16_BN_Weights.verify(weights)

    return _vgg("D", True, weights, progress, **kwargs)

vgg19

vgg19(*, weights: Optional[VGG19_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-19 from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG19_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG19_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG19_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG19_Weights.IMAGENET1K_V1))
def vgg19(*, weights: Optional[VGG19_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-19 from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG19_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG19_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG19_Weights
        :members:
    """
    weights = VGG19_Weights.verify(weights)

    return _vgg("E", False, weights, progress, **kwargs)

vgg19_bn

vgg19_bn(*, weights: Optional[VGG19_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG

VGG-19_BN from Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>__.

Parameters:

  • weights (

    class:~torchvision.models.VGG19_BN_Weights, optional): The pretrained weights to use. See :class:~torchvision.models.VGG19_BN_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, default: True ) –

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

  • **kwargs (Any, default: {} ) –

    parameters passed to the torchvision.models.vgg.VGG base class. Please refer to the source code <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>_ for more details about this class.

.. autoclass:: torchvision.models.VGG19_BN_Weights :members:

Source code in SaigeToolkit/model/backbone/torchvision/vgg.py
@handle_legacy_interface(weights=("pretrained", VGG19_BN_Weights.IMAGENET1K_V1))
def vgg19_bn(*, weights: Optional[VGG19_BN_Weights] = None, progress: bool = True, **kwargs: Any) -> VGG:
    """VGG-19_BN from `Very Deep Convolutional Networks for Large-Scale Image Recognition <https://arxiv.org/abs/1409.1556>`__.

    Args:
        weights (:class:`~torchvision.models.VGG19_BN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.VGG19_BN_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.vgg.VGG``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/vgg.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.VGG19_BN_Weights
        :members:
    """
    weights = VGG19_BN_Weights.verify(weights)

    return _vgg("E", True, weights, progress, **kwargs)