Skip to content

Commit d585f86

Browse files
Added revamped quantized resnet docs (#6012)
* Create resnet_quant.rst * add resnet quant * refactor docs * Minor fix * Nit Co-authored-by: Nicolas Hug <[email protected]>
1 parent e7abd3b commit d585f86

File tree

3 files changed

+110
-24
lines changed

3 files changed

+110
-24
lines changed

docs/source/models/resnet_quant.rst

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

docs/source/models_new.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pre-trained weights:
149149
models/googlenet_quant
150150
models/inception_quant
151151
models/mobilenetv2_quant
152+
models/resnet_quant
152153

153154
|
154155

torchvision/models/quantization/resnet.py

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,29 @@ def resnet18(
267267
quantize: bool = False,
268268
**kwargs: Any,
269269
) -> QuantizableResNet:
270-
r"""ResNet-18 model from
271-
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
270+
"""ResNet-18 model from
271+
`Deep Residual Learning for Image Recognition <https://arxiv.org/abs/1512.03385.pdf>`_
272272
273273
Args:
274-
weights (ResNet18_QuantizedWeights or ResNet18_Weights, optional): The pretrained
275-
weights for the model
276-
progress (bool): If True, displays a progress bar of the download to stderr
277-
quantize (bool): If True, return a quantized version of the model
274+
weights (:class:`~torchvision.models.quantization.ResNet18_QuantizedWeights` or :class:`~torchvision.models.ResNet18_Weights`, optional): The
275+
pretrained weights for the model. See
276+
:class:`~torchvision.models.quantization.ResNet18_QuantizedWeights` below for
277+
more details, and possible values. By default, no pre-trained
278+
weights are used.
279+
progress (bool, optional): If True, displays a progress bar of the
280+
download to stderr. Default is True.
281+
quantize (bool, optional): If True, return a quantized version of the model. Default is False.
282+
**kwargs: parameters passed to the ``torchvision.models.quantization.QuantizableResNet``
283+
base class. Please refer to the `source code
284+
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization.resnet.py>`_
285+
for more details about this class.
286+
287+
.. autoclass:: torchvision.models.quantization.ResNet18_QuantizedWeights
288+
:members:
289+
290+
.. autoclass:: torchvision.models.ResNet18_Weights
291+
:members:
292+
:noindex:
278293
"""
279294
weights = (ResNet18_QuantizedWeights if quantize else ResNet18_Weights).verify(weights)
280295

@@ -296,14 +311,29 @@ def resnet50(
296311
quantize: bool = False,
297312
**kwargs: Any,
298313
) -> QuantizableResNet:
299-
r"""ResNet-50 model from
300-
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
314+
"""ResNet-50 model from
315+
`Deep Residual Learning for Image Recognition <https://arxiv.org/abs/1512.03385.pdf>`_
301316
302317
Args:
303-
weights (ResNet50_QuantizedWeights or ResNet50_Weights, optional): The pretrained
304-
weights for the model
305-
progress (bool): If True, displays a progress bar of the download to stderr
306-
quantize (bool): If True, return a quantized version of the model
318+
weights (:class:`~torchvision.models.quantization.ResNet50_QuantizedWeights` or :class:`~torchvision.models.ResNet50_Weights`, optional): The
319+
pretrained weights for the model. See
320+
:class:`~torchvision.models.quantization.ResNet50_QuantizedWeights` below for
321+
more details, and possible values. By default, no pre-trained
322+
weights are used.
323+
progress (bool, optional): If True, displays a progress bar of the
324+
download to stderr. Default is True.
325+
quantize (bool, optional): If True, return a quantized version of the model. Default is False.
326+
**kwargs: parameters passed to the ``torchvision.models.quantization.QuantizableResNet``
327+
base class. Please refer to the `source code
328+
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization.resnet.py>`_
329+
for more details about this class.
330+
331+
.. autoclass:: torchvision.models.quantization.ResNet50_QuantizedWeights
332+
:members:
333+
334+
.. autoclass:: torchvision.models.ResNet50_Weights
335+
:members:
336+
:noindex:
307337
"""
308338
weights = (ResNet50_QuantizedWeights if quantize else ResNet50_Weights).verify(weights)
309339

@@ -325,14 +355,29 @@ def resnext101_32x8d(
325355
quantize: bool = False,
326356
**kwargs: Any,
327357
) -> QuantizableResNet:
328-
r"""ResNeXt-101 32x8d model from
329-
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
358+
"""ResNeXt-101 32x8d model from
359+
`Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431.pdf>`_
330360
331361
Args:
332-
weights (ResNeXt101_32X8D_QuantizedWeights or ResNeXt101_32X8D_Weights, optional): The pretrained
333-
weights for the model
334-
progress (bool): If True, displays a progress bar of the download to stderr
335-
quantize (bool): If True, return a quantized version of the model
362+
weights (:class:`~torchvision.models.quantization.ResNet101_32X8D_QuantizedWeights` or :class:`~torchvision.models.ResNet101_32X8D_Weights`, optional): The
363+
pretrained weights for the model. See
364+
:class:`~torchvision.models.quantization.ResNet101_32X8D_QuantizedWeights` below for
365+
more details, and possible values. By default, no pre-trained
366+
weights are used.
367+
progress (bool, optional): If True, displays a progress bar of the
368+
download to stderr. Default is True.
369+
quantize (bool, optional): If True, return a quantized version of the model. Default is False.
370+
**kwargs: parameters passed to the ``torchvision.models.quantization.QuantizableResNet``
371+
base class. Please refer to the `source code
372+
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization.resnet.py>`_
373+
for more details about this class.
374+
375+
.. autoclass:: torchvision.models.quantization.ResNet101_32X8D_QuantizedWeights
376+
:members:
377+
378+
.. autoclass:: torchvision.models.ResNet101_32X8D_Weights
379+
:members:
380+
:noindex:
336381
"""
337382
weights = (ResNeXt101_32X8D_QuantizedWeights if quantize else ResNeXt101_32X8D_Weights).verify(weights)
338383

@@ -348,14 +393,29 @@ def resnext101_64x4d(
348393
quantize: bool = False,
349394
**kwargs: Any,
350395
) -> QuantizableResNet:
351-
r"""ResNeXt-101 64x4d model from
352-
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
396+
"""ResNeXt-101 64x4d model from
397+
`Aggregated Residual Transformation for Deep Neural Networks <https://arxiv.org/abs/1611.05431.pdf>`_
353398
354399
Args:
355-
weights (ResNeXt101_64X4D_QuantizedWeights or ResNeXt101_64X4D_Weights, optional): The pretrained
356-
weights for the model
357-
progress (bool): If True, displays a progress bar of the download to stderr
358-
quantize (bool): If True, return a quantized version of the model
400+
weights (:class:`~torchvision.models.quantization.ResNet101_64X4D_QuantizedWeights` or :class:`~torchvision.models.ResNet101_64X4D_Weights`, optional): The
401+
pretrained weights for the model. See
402+
:class:`~torchvision.models.quantization.ResNet101_64X4D_QuantizedWeights` below for
403+
more details, and possible values. By default, no pre-trained
404+
weights are used.
405+
progress (bool, optional): If True, displays a progress bar of the
406+
download to stderr. Default is True.
407+
quantize (bool, optional): If True, return a quantized version of the model. Default is False.
408+
**kwargs: parameters passed to the ``torchvision.models.quantization.QuantizableResNet``
409+
base class. Please refer to the `source code
410+
<https://github.com/pytorch/vision/blob/main/torchvision/models/quantization.resnet.py>`_
411+
for more details about this class.
412+
413+
.. autoclass:: torchvision.models.quantization.ResNet101_64X4D_QuantizedWeights
414+
:members:
415+
416+
.. autoclass:: torchvision.models.ResNet101_64X4D_Weights
417+
:members:
418+
:noindex:
359419
"""
360420
weights = (ResNeXt101_64X4D_QuantizedWeights if quantize else ResNeXt101_64X4D_Weights).verify(weights)
361421

0 commit comments

Comments
 (0)