From 286a2ed2e09319996c5c4f7a569efb16346b2e75 Mon Sep 17 00:00:00 2001 From: Joao Gomes Date: Thu, 28 Apr 2022 20:51:35 +0100 Subject: [PATCH 1/6] updating mnasnet docs --- docs/source/models/mnasnet.rst | 27 +++++++++++ docs/source/models_new.rst | 1 + torchvision/models/mnasnet.py | 88 ++++++++++++++++++++++++++-------- 3 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 docs/source/models/mnasnet.rst diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst new file mode 100644 index 00000000000..62f968a6006 --- /dev/null +++ b/docs/source/models/mnasnet.rst @@ -0,0 +1,27 @@ +MNASNet +======= + +.. currentmodule:: torchvision.models + +The MNASNet model is based on the `MnasNet: Platform-Aware Neural Architecture Search for Mobile + `_ paper + + +Model builders +-------------- + +The following model builders can be used to instanciate an MNASNet model, with or +without pre-trained weights. All the model builders internally rely on the +``torchvision.models.mnasnet.MNASNet`` base class. Please refer to the `source +code +`_ for +more details about this class. + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + mnasnet0_5 + mnasnet0_75 + mnasnet1_0 + mnasnet1_3 \ No newline at end of file diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index b4945938824..ab26ffb3668 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -42,6 +42,7 @@ weights: models/efficientnet models/efficientnetv2 models/googlenet + models/mnasnet models/mobilenetv2 models/mobilenetv3 models/regnet diff --git a/torchvision/models/mnasnet.py b/torchvision/models/mnasnet.py index ac15722ca10..df7d559dc34 100644 --- a/torchvision/models/mnasnet.py +++ b/torchvision/models/mnasnet.py @@ -274,13 +274,25 @@ def _mnasnet(alpha: float, weights: Optional[WeightsEnum], progress: bool, **kwa @handle_legacy_interface(weights=("pretrained", MNASNet0_5_Weights.IMAGENET1K_V1)) def mnasnet0_5(*, weights: Optional[MNASNet0_5_Weights] = None, progress: bool = True, **kwargs: Any) -> MNASNet: - r"""MNASNet with depth multiplier of 0.5 from - `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" - `_. + """MNASNet with depth multiplier of 0.5 from + `MnasNet: Platform-Aware Neural Architecture Search for Mobile + `_ paper. Args: - weights (MNASNet0_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.MNASNet0_5_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.MNASNet0_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.mnasnet.MNASNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.MNASNet0_5_Weights + :members: """ weights = MNASNet0_5_Weights.verify(weights) @@ -289,13 +301,25 @@ def mnasnet0_5(*, weights: Optional[MNASNet0_5_Weights] = None, progress: bool = @handle_legacy_interface(weights=("pretrained", None)) def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool = True, **kwargs: Any) -> MNASNet: - r"""MNASNet with depth multiplier of 0.75 from - `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" - `_. + """MNASNet with depth multiplier of 0.75 from + `MnasNet: Platform-Aware Neural Architecture Search for Mobile + `_ paper. Args: - weights (MNASNet0_75_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.MNASNet0_75_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.MNASNet0_75_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.mnasnet.MNASNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.MNASNet0_75_Weights + :members: """ weights = MNASNet0_75_Weights.verify(weights) @@ -304,13 +328,25 @@ def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool @handle_legacy_interface(weights=("pretrained", MNASNet1_0_Weights.IMAGENET1K_V1)) def mnasnet1_0(*, weights: Optional[MNASNet1_0_Weights] = None, progress: bool = True, **kwargs: Any) -> MNASNet: - r"""MNASNet with depth multiplier of 1.0 from - `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" - `_. + """MNASNet with depth multiplier of 1.0 from + `MnasNet: Platform-Aware Neural Architecture Search for Mobile + `_ paper. Args: - weights (MNASNet1_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.MNASNet1_0_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.MNASNet1_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.mnasnet.MNASNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.MNASNet1_0_Weights + :members: """ weights = MNASNet1_0_Weights.verify(weights) @@ -319,13 +355,25 @@ def mnasnet1_0(*, weights: Optional[MNASNet1_0_Weights] = None, progress: bool = @handle_legacy_interface(weights=("pretrained", None)) def mnasnet1_3(*, weights: Optional[MNASNet1_3_Weights] = None, progress: bool = True, **kwargs: Any) -> MNASNet: - r"""MNASNet with depth multiplier of 1.3 from - `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" - `_. + """MNASNet with depth multiplier of 1.3 from + `MnasNet: Platform-Aware Neural Architecture Search for Mobile + `_ paper. Args: - weights (MNASNet1_3_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.MNASNet1_3_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.MNASNet1_3_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.mnasnet.MNASNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.MNASNet1_3_Weights + :members: """ weights = MNASNet1_3_Weights.verify(weights) From 79a926815b1bb0025d73d5b89e42122e7564f83f Mon Sep 17 00:00:00 2001 From: Joao Gomes Date: Thu, 28 Apr 2022 21:42:46 +0100 Subject: [PATCH 2/6] fix bug --- docs/source/models/mnasnet.rst | 4 ++-- torchvision/models/mnasnet.py | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst index 62f968a6006..4e2b3cd6675 100644 --- a/docs/source/models/mnasnet.rst +++ b/docs/source/models/mnasnet.rst @@ -3,8 +3,8 @@ MNASNet .. currentmodule:: torchvision.models -The MNASNet model is based on the `MnasNet: Platform-Aware Neural Architecture Search for Mobile - `_ paper + +The MNASNet model is based on the `MnasNet: Platform-Aware Neural Architecture Search for Mobile `__ paper. Model builders diff --git a/torchvision/models/mnasnet.py b/torchvision/models/mnasnet.py index df7d559dc34..7e77cb90a3a 100644 --- a/torchvision/models/mnasnet.py +++ b/torchvision/models/mnasnet.py @@ -318,8 +318,6 @@ def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool `_ for more details about this class. - .. autoclass:: torchvision.models.MNASNet0_75_Weights - :members: """ weights = MNASNet0_75_Weights.verify(weights) @@ -372,8 +370,6 @@ def mnasnet1_3(*, weights: Optional[MNASNet1_3_Weights] = None, progress: bool = `_ for more details about this class. - .. autoclass:: torchvision.models.MNASNet1_3_Weights - :members: """ weights = MNASNet1_3_Weights.verify(weights) From 35e3546730ac07e1a9c135db745ba9fe2d51bb50 Mon Sep 17 00:00:00 2001 From: Joao Gomes Date: Thu, 28 Apr 2022 22:03:52 +0100 Subject: [PATCH 3/6] fix lint --- docs/source/models/mnasnet.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst index 4e2b3cd6675..04f885db55d 100644 --- a/docs/source/models/mnasnet.rst +++ b/docs/source/models/mnasnet.rst @@ -4,7 +4,9 @@ MNASNet .. currentmodule:: torchvision.models -The MNASNet model is based on the `MnasNet: Platform-Aware Neural Architecture Search for Mobile `__ paper. +The MNASNet model is based on the + `MnasNet: Platform-Aware Neural Architecture Search for Mobile `__ + paper. Model builders From 6b734e19f66ec61863ab44cb2138e4495755d52b Mon Sep 17 00:00:00 2001 From: Joao Gomes Date: Thu, 28 Apr 2022 22:16:24 +0100 Subject: [PATCH 4/6] fix end of file --- docs/source/models/mnasnet.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst index 04f885db55d..8a07f350504 100644 --- a/docs/source/models/mnasnet.rst +++ b/docs/source/models/mnasnet.rst @@ -26,4 +26,5 @@ more details about this class. mnasnet0_5 mnasnet0_75 mnasnet1_0 - mnasnet1_3 \ No newline at end of file + mnasnet1_3 + From d2c194b3a4c19cf334ba836d5504384f6647ebee Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 10:26:46 +0100 Subject: [PATCH 5/6] fix linting --- docs/source/models/mnasnet.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst index 8a07f350504..e938382f77c 100644 --- a/docs/source/models/mnasnet.rst +++ b/docs/source/models/mnasnet.rst @@ -27,4 +27,3 @@ more details about this class. mnasnet0_75 mnasnet1_0 mnasnet1_3 - From 19fdba23ca6dfe3d02351de9d667773b44d10ebb Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 10:28:36 +0100 Subject: [PATCH 6/6] Add missing weights --- docs/source/models/mnasnet.rst | 5 ++--- torchvision/models/mnasnet.py | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/source/models/mnasnet.rst b/docs/source/models/mnasnet.rst index e938382f77c..b4239be5c27 100644 --- a/docs/source/models/mnasnet.rst +++ b/docs/source/models/mnasnet.rst @@ -4,9 +4,8 @@ MNASNet .. currentmodule:: torchvision.models -The MNASNet model is based on the - `MnasNet: Platform-Aware Neural Architecture Search for Mobile `__ - paper. +The MNASNet model is based on the `MnasNet: Platform-Aware Neural Architecture +Search for Mobile `__ paper. Model builders diff --git a/torchvision/models/mnasnet.py b/torchvision/models/mnasnet.py index 7e77cb90a3a..df7d559dc34 100644 --- a/torchvision/models/mnasnet.py +++ b/torchvision/models/mnasnet.py @@ -318,6 +318,8 @@ def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool `_ for more details about this class. + .. autoclass:: torchvision.models.MNASNet0_75_Weights + :members: """ weights = MNASNet0_75_Weights.verify(weights) @@ -370,6 +372,8 @@ def mnasnet1_3(*, weights: Optional[MNASNet1_3_Weights] = None, progress: bool = `_ for more details about this class. + .. autoclass:: torchvision.models.MNASNet1_3_Weights + :members: """ weights = MNASNet1_3_Weights.verify(weights)