Skip to content

Commit f196782

Browse files
Add revamped docs for ConvNext (#5869)
* add convnext.rst * refactor code * add convnext Co-authored-by: Nicolas Hug <[email protected]>
1 parent a767cbf commit f196782

File tree

3 files changed

+83
-16
lines changed

3 files changed

+83
-16
lines changed

docs/source/models/convnext.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ConvNeXt
2+
======
3+
4+
.. currentmodule:: torchvision.models
5+
6+
The ConvNeXt model is based on the `A ConvNet for the 2020s
7+
<https://arxiv.org/abs/2201.03545>`_ paper.
8+
9+
10+
Model builders
11+
--------------
12+
13+
The following model builders can be used to instantiate a ConvNeXt model, with or
14+
without pre-trained weights. All the model builders internally rely on the
15+
``torchvision.models.convnext.ConvNeXt`` base class. Please refer to the `source code
16+
<https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py>`_ for
17+
more details about this class.
18+
19+
.. autosummary::
20+
:toctree: generated/
21+
:template: function.rst
22+
23+
convnext_tiny
24+
convnext_small
25+
convnext_base
26+
convnext_large

docs/source/models_new.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ weights:
3636
.. toctree::
3737
:maxdepth: 1
3838

39+
models/convnext
3940
models/efficientnet
4041
models/efficientnetv2
4142
models/regnet

torchvision/models/convnext.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,21 @@ class ConvNeXt_Large_Weights(WeightsEnum):
276276

277277
@handle_legacy_interface(weights=("pretrained", ConvNeXt_Tiny_Weights.IMAGENET1K_V1))
278278
def convnext_tiny(*, weights: Optional[ConvNeXt_Tiny_Weights] = None, progress: bool = True, **kwargs: Any) -> ConvNeXt:
279-
r"""ConvNeXt Tiny model architecture from the
280-
`"A ConvNet for the 2020s" <https://arxiv.org/abs/2201.03545>`_ paper.
279+
"""ConvNeXt Tiny model architecture from the
280+
`A ConvNet for the 2020s <https://arxiv.org/abs/2201.03545>`_ paper.
281+
281282
Args:
282-
weights (ConvNeXt_Tiny_Weights, optional): The pretrained weights for the model
283-
progress (bool): If True, displays a progress bar of the download to stderr
283+
weights (:class:`~torchvision.models.convnext.ConvNeXt_Tiny_Weights`, optional): The pretrained
284+
weights to use. See :class:`~torchvision.models.convnext.ConvNeXt_Tiny_Weights`
285+
below for more details and possible values. By default, no pre-trained weights are used.
286+
progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
287+
**kwargs: parameters passed to the ``torchvision.models.convnext.ConvNext``
288+
base class. Please refer to the `source code
289+
<https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py>`_
290+
for more details about this class.
291+
292+
.. autoclass:: torchvision.models.convnext.ConvNeXt_Tiny_Weights
293+
:members:
284294
"""
285295
weights = ConvNeXt_Tiny_Weights.verify(weights)
286296

@@ -298,11 +308,21 @@ def convnext_tiny(*, weights: Optional[ConvNeXt_Tiny_Weights] = None, progress:
298308
def convnext_small(
299309
*, weights: Optional[ConvNeXt_Small_Weights] = None, progress: bool = True, **kwargs: Any
300310
) -> ConvNeXt:
301-
r"""ConvNeXt Small model architecture from the
302-
`"A ConvNet for the 2020s" <https://arxiv.org/abs/2201.03545>`_ paper.
311+
"""ConvNeXt Small model architecture from the
312+
`A ConvNet for the 2020s <https://arxiv.org/abs/2201.03545>`_ paper.
313+
303314
Args:
304-
weights (ConvNeXt_Small_Weights, optional): The pretrained weights for the model
305-
progress (bool): If True, displays a progress bar of the download to stderr
315+
weights (:class:`~torchvision.models.convnext.ConvNeXt_Small_Weights`, optional): The pretrained
316+
weights to use. See :class:`~torchvision.models.convnext.ConvNeXt_Small_Weights`
317+
below for more details and possible values. By default, no pre-trained weights are used.
318+
progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
319+
**kwargs: parameters passed to the ``torchvision.models.convnext.ConvNext``
320+
base class. Please refer to the `source code
321+
<https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py>`_
322+
for more details about this class.
323+
324+
.. autoclass:: torchvision.models.convnext.ConvNeXt_Small_Weights
325+
:members:
306326
"""
307327
weights = ConvNeXt_Small_Weights.verify(weights)
308328

@@ -318,11 +338,21 @@ def convnext_small(
318338

319339
@handle_legacy_interface(weights=("pretrained", ConvNeXt_Base_Weights.IMAGENET1K_V1))
320340
def convnext_base(*, weights: Optional[ConvNeXt_Base_Weights] = None, progress: bool = True, **kwargs: Any) -> ConvNeXt:
321-
r"""ConvNeXt Base model architecture from the
322-
`"A ConvNet for the 2020s" <https://arxiv.org/abs/2201.03545>`_ paper.
341+
"""ConvNeXt Base model architecture from the
342+
`A ConvNet for the 2020s <https://arxiv.org/abs/2201.03545>`_ paper.
343+
323344
Args:
324-
weights (ConvNeXt_Base_Weights, optional): The pretrained weights for the model
325-
progress (bool): If True, displays a progress bar of the download to stderr
345+
weights (:class:`~torchvision.models.convnext.ConvNeXt_Base_Weights`, optional): The pretrained
346+
weights to use. See :class:`~torchvision.models.convnext.ConvNeXt_Base_Weights`
347+
below for more details and possible values. By default, no pre-trained weights are used.
348+
progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
349+
**kwargs: parameters passed to the ``torchvision.models.convnext.ConvNext``
350+
base class. Please refer to the `source code
351+
<https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py>`_
352+
for more details about this class.
353+
354+
.. autoclass:: torchvision.models.convnext.ConvNeXt_Base_Weights
355+
:members:
326356
"""
327357
weights = ConvNeXt_Base_Weights.verify(weights)
328358

@@ -340,11 +370,21 @@ def convnext_base(*, weights: Optional[ConvNeXt_Base_Weights] = None, progress:
340370
def convnext_large(
341371
*, weights: Optional[ConvNeXt_Large_Weights] = None, progress: bool = True, **kwargs: Any
342372
) -> ConvNeXt:
343-
r"""ConvNeXt Large model architecture from the
344-
`"A ConvNet for the 2020s" <https://arxiv.org/abs/2201.03545>`_ paper.
373+
"""ConvNeXt Large model architecture from the
374+
`A ConvNet for the 2020s <https://arxiv.org/abs/2201.03545>`_ paper.
375+
345376
Args:
346-
weights (ConvNeXt_Large_Weights, optional): The pretrained weights for the model
347-
progress (bool): If True, displays a progress bar of the download to stderr
377+
weights (:class:`~torchvision.models.convnext.ConvNeXt_Large_Weights`, optional): The pretrained
378+
weights to use. See :class:`~torchvision.models.convnext.ConvNeXt_Large_Weights`
379+
below for more details and possible values. By default, no pre-trained weights are used.
380+
progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True.
381+
**kwargs: parameters passed to the ``torchvision.models.convnext.ConvNext``
382+
base class. Please refer to the `source code
383+
<https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py>`_
384+
for more details about this class.
385+
386+
.. autoclass:: torchvision.models.convnext.ConvNeXt_Large_Weights
387+
:members:
348388
"""
349389
weights = ConvNeXt_Large_Weights.verify(weights)
350390

0 commit comments

Comments
 (0)