From 1e901416160e4be11bcd86b6112b95ec722df10d Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Fri, 29 Apr 2022 08:15:18 +0800 Subject: [PATCH 1/3] Update ShuffleNetV2 docstring --- torchvision/models/shufflenetv2.py | 72 +++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/torchvision/models/shufflenetv2.py b/torchvision/models/shufflenetv2.py index 5e58c489ee0..b29f26e3362 100644 --- a/torchvision/models/shufflenetv2.py +++ b/torchvision/models/shufflenetv2.py @@ -261,13 +261,25 @@ def shufflenet_v2_x0_5( *, weights: Optional[ShuffleNet_V2_X0_5_Weights] = None, progress: bool = True, **kwargs: Any ) -> ShuffleNetV2: """ - Constructs a ShuffleNetV2 with 0.5x output channels, as described in + Constructs a ShuffleNetV2 architecture with 0.5x output channels, as described in `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" `_. Args: - weights (ShuffleNet_V2_X0_5_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr + weights (:class:`~torchvision.models.ShuffleNet_V2_X0_5_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.ShuffleNet_V2_X0_5_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.shufflenetv2.ShuffleNetV2`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.ShuffleNet_V2_X0_5_Weights + :members: """ weights = ShuffleNet_V2_X0_5_Weights.verify(weights) @@ -279,13 +291,25 @@ def shufflenet_v2_x1_0( *, weights: Optional[ShuffleNet_V2_X1_0_Weights] = None, progress: bool = True, **kwargs: Any ) -> ShuffleNetV2: """ - Constructs a ShuffleNetV2 with 1.0x output channels, as described in + Constructs a ShuffleNetV2 architecture with 1.0x output channels, as described in `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" `_. Args: - weights (ShuffleNet_V2_X1_0_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr + weights (:class:`~torchvision.models.ShuffleNet_V2_X1_0_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.ShuffleNet_V2_X1_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.shufflenetv2.ShuffleNetV2`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.ShuffleNet_V2_X1_0_Weights + :members: """ weights = ShuffleNet_V2_X1_0_Weights.verify(weights) @@ -297,13 +321,25 @@ def shufflenet_v2_x1_5( *, weights: Optional[ShuffleNet_V2_X1_5_Weights] = None, progress: bool = True, **kwargs: Any ) -> ShuffleNetV2: """ - Constructs a ShuffleNetV2 with 1.5x output channels, as described in + Constructs a ShuffleNetV2 architecture with 1.5x output channels, as described in `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" `_. Args: - weights (ShuffleNet_V2_X1_5_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr + weights (:class:`~torchvision.models.ShuffleNet_V2_X1_5_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.ShuffleNet_V2_X1_5_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.shufflenetv2.ShuffleNetV2`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.ShuffleNet_V2_X1_5_Weights + :members: """ weights = ShuffleNet_V2_X1_5_Weights.verify(weights) @@ -315,13 +351,25 @@ def shufflenet_v2_x2_0( *, weights: Optional[ShuffleNet_V2_X2_0_Weights] = None, progress: bool = True, **kwargs: Any ) -> ShuffleNetV2: """ - Constructs a ShuffleNetV2 with 2.0x output channels, as described in + Constructs a ShuffleNetV2 architecture with 2.0x output channels, as described in `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" `_. Args: - weights (ShuffleNet_V2_X2_0_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr + weights (:class:`~torchvision.models.ShuffleNet_V2_X2_0_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.ShuffleNet_V2_X2_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.shufflenetv2.ShuffleNetV2`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.ShuffleNet_V2_X2_0_Weights + :members: """ weights = ShuffleNet_V2_X2_0_Weights.verify(weights) From 708b59a7c7989f04837baf43c75af6be6c259d17 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Fri, 29 Apr 2022 08:15:58 +0800 Subject: [PATCH 2/3] Add entry for ShuffleNet V2 in new doc --- docs/source/models/shufflenetv2.rst | 27 +++++++++++++++++++++++++++ docs/source/models_new.rst | 1 + 2 files changed, 28 insertions(+) create mode 100644 docs/source/models/shufflenetv2.rst diff --git a/docs/source/models/shufflenetv2.rst b/docs/source/models/shufflenetv2.rst new file mode 100644 index 00000000000..7813b79ae94 --- /dev/null +++ b/docs/source/models/shufflenetv2.rst @@ -0,0 +1,27 @@ +ShuffleNet V2 +============ + +.. currentmodule:: torchvision.models + +The ShuffleNet V2 model is based on the `ShuffleNet V2: Practical Guidelines for Efficient +CNN Architecture Design `__ paper. + + +Model builders +-------------- + +The following model builders can be used to instantiate a ShuffleNetV2 model, with or +without pre-trained weights. All the model builders internally rely on the +``torchvision.models.shufflenetv2.ShuffleNetV2`` base class. Please refer to the `source +code +`_ for +more details about this class. + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + shufflenet_v2_x0_5 + shufflenet_v2_x1_0 + shufflenet_v2_x1_5 + shufflenet_v2_x2_0 diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index b4945938824..303427614fa 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -47,6 +47,7 @@ weights: models/regnet models/resnet models/resnext + models/shufflenetv2 models/squeezenet models/swin_transformer models/vgg From b4c90e7d510190b89e7d631a0cb2746301e7d316 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Fri, 29 Apr 2022 08:22:15 +0800 Subject: [PATCH 3/3] Minor fixes --- docs/source/models/shufflenetv2.rst | 2 +- torchvision/models/shufflenetv2.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/source/models/shufflenetv2.rst b/docs/source/models/shufflenetv2.rst index 7813b79ae94..2cbe328ca8b 100644 --- a/docs/source/models/shufflenetv2.rst +++ b/docs/source/models/shufflenetv2.rst @@ -1,5 +1,5 @@ ShuffleNet V2 -============ +============= .. currentmodule:: torchvision.models diff --git a/torchvision/models/shufflenetv2.py b/torchvision/models/shufflenetv2.py index b29f26e3362..dc8efbc670d 100644 --- a/torchvision/models/shufflenetv2.py +++ b/torchvision/models/shufflenetv2.py @@ -262,8 +262,8 @@ def shufflenet_v2_x0_5( ) -> ShuffleNetV2: """ Constructs a ShuffleNetV2 architecture with 0.5x output channels, as described in - `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" - `_. + `ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design + `__. Args: weights (:class:`~torchvision.models.ShuffleNet_V2_X0_5_Weights`, optional): The @@ -292,8 +292,8 @@ def shufflenet_v2_x1_0( ) -> ShuffleNetV2: """ Constructs a ShuffleNetV2 architecture with 1.0x output channels, as described in - `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" - `_. + `ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design + `__. Args: weights (:class:`~torchvision.models.ShuffleNet_V2_X1_0_Weights`, optional): The @@ -322,8 +322,8 @@ def shufflenet_v2_x1_5( ) -> ShuffleNetV2: """ Constructs a ShuffleNetV2 architecture with 1.5x output channels, as described in - `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" - `_. + `ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design + `__. Args: weights (:class:`~torchvision.models.ShuffleNet_V2_X1_5_Weights`, optional): The @@ -352,8 +352,8 @@ def shufflenet_v2_x2_0( ) -> ShuffleNetV2: """ Constructs a ShuffleNetV2 architecture with 2.0x output channels, as described in - `"ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" - `_. + `ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design + `__. Args: weights (:class:`~torchvision.models.ShuffleNet_V2_X2_0_Weights`, optional): The