resnet
model.backbone.torchvision.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
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
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
extend_state_dict_input_channel
extend_state_dict_input_channel(state_dict: Mapping[str, Any], input_weight_key: str, input_conv_layer: Conv2d) -> None
(Multipage) 3채널 이상인 이미지를 사용하기 위해 필요한 기능이며, state_dict의 input conv 채널이 네트워크의 input conv 채널보다 작은 경우 해당 weight의 채널을 늘려줍니다. 현재 네트워크가 가진 input conv 웨이트에서 앞 3 채널을 state_dict의 input conv 웨이트로 치환하는 방식을 사용합니다.
Parameters:
-
state_dict(Mapping[str, Any]) –로드하려는 weight
-
input_weight_key(str) –input conv weight의 이름
-
input_conv_layer(Conv2d) –input conv layer
Source code in SaigeToolkit/model/util.py
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
conv1x1
_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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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
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_Weightsbelow 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.ResNetbase class. Please refer to thesource 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: