Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix small mistakes in docs #1984

Merged
merged 6 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,7 @@
.. _Seamless Scene Segmentation paper: https://arxiv.org/abs/1905.01220
.. _Fleiss kappa: https://en.wikipedia.org/wiki/Fleiss%27_kappa
.. _VIF: https://ieeexplore.ieee.org/abstract/document/1576816
.. _CIOU: https://arxiv.org/abs/2005.03572
.. _DIOU: https://arxiv.org/abs/1911.08287v1
.. _GIOU: https://arxiv.org/abs/1902.09630
.. _pycocotools: https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools
4 changes: 2 additions & 2 deletions src/torchmetrics/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def plot(
class RunningMean(Running):
"""Aggregate a stream of value into their mean over a running window.

Using this metric compared to `MeanMetric` allows for calculating metrics over a running window of values, instead
Using this metric compared to `MeanMetric`_ allows for calculating metrics over a running window of values, instead
of the whole history of values. This is beneficial when you want to get a better estimate of the metric during
training and don't want to wait for the whole training to finish to get epoch level estimates.

Expand Down Expand Up @@ -673,7 +673,7 @@ def __init__(
class RunningSum(Running):
"""Aggregate a stream of value into their sum over a running window.

Using this metric compared to `MeanMetric` allows for calculating metrics over a running window of values, instead
Using this metric compared to `SumMetric`_ allows for calculating metrics over a running window of values, instead
of the whole history of values. This is beneficial when you want to get a better estimate of the metric during
training and don't want to wait for the whole training to finish to get epoch level estimates.

Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/audio/sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ class ScaleInvariantSignalDistortionRatio(Metric):
As input to `forward` and `update` the metric accepts the following input

- ``preds`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``
- ``target`` (: :class:`~torch.Tensor`): float tensor with shape ``(...,time)``
- ``target`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``

As output of `forward` and `compute` the metric returns the following output

- ``si_sdr`` (: :class:`~torch.Tensor`): float scalar tensor with average SI-SDR value over samples
- ``si_sdr`` (:class:`~torch.Tensor`): float scalar tensor with average SI-SDR value over samples

Args:
zero_mean: if to zero mean target and preds or not
Expand Down
14 changes: 7 additions & 7 deletions src/torchmetrics/audio/snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ class ScaleInvariantSignalNoiseRatio(Metric):
As input to `forward` and `update` the metric accepts the following input

- ``preds`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``
- ``target`` (: :class:`~torch.Tensor`): float tensor with shape ``(...,time)``
- ``target`` (:class:`~torch.Tensor`): float tensor with shape ``(...,time)``

As output of `forward` and `compute` the metric returns the following output

- ``si_snr`` (: :class:`~torch.Tensor`): float scalar tensor with average SI-SNR value over samples
- ``si_snr`` (:class:`~torch.Tensor`): float scalar tensor with average SI-SNR value over samples

Args:
kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
Expand Down Expand Up @@ -245,15 +245,15 @@ class ComplexScaleInvariantSignalNoiseRatio(Metric):

As input to `forward` and `update` the metric accepts the following input

- ``preds`` (:class:`~torch.Tensor`): real/complex float tensor with shape ``(..., frequency, time, 2)``\
/ ``(..., frequency, time)``
- ``preds`` (:class:`~torch.Tensor`): real float tensor with shape ``(...,frequency,time,2)`` or complex float
tensor with shape ``(..., frequency,time)``

- ``target`` (: :class:`~torch.Tensor`): real/complex float tensor with shape ``(..., frequency, time, 2)``\
/ ``(..., frequency, time)``
- ``target`` (:class:`~torch.Tensor`): real float tensor with shape ``(...,frequency,time,2)`` or complex float
tensor with shape ``(..., frequency,time)``

As output of `forward` and `compute` the metric returns the following output

- ``c_si_snr`` (: :class:`~torch.Tensor`): float scalar tensor with average C-SI-SNR value over samples
- ``c_si_snr`` (:class:`~torch.Tensor`): float scalar tensor with average C-SI-SNR value over samples

Args:
zero_mean: if to zero mean target and preds or not
Expand Down
5 changes: 2 additions & 3 deletions src/torchmetrics/detection/_mean_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ class MeanAveragePrecision(Metric):
The default properties are also accessible via fields and will raise an ``AttributeError`` if not available.

.. note::
This metric is following the mAP implementation of
`pycocotools <https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools>`_,
a standard implementation for the mAP metric for object detection.
This metric is following the mAP implementation of `pycocotools`_ a standard implementation for the mAP metric
for object detection.

.. note::
This metric requires you to have `torchvision` version 0.8.0 or newer installed
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/detection/ciou.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class CompleteIntersectionOverUnion(IntersectionOverUnion):
r"""Computes Complete Intersection Over Union (CIoU) <https://arxiv.org/abs/2005.03572>`_.
r"""Computes Complete Intersection Over Union (`CIoU`_).

As input to ``forward`` and ``update`` the metric accepts the following input:

Expand Down Expand Up @@ -55,7 +55,7 @@ class CompleteIntersectionOverUnion(IntersectionOverUnion):
- ``ciou_dict``: A dictionary containing the following key-values:

- ciou: (:class:`~torch.Tensor`)
- ciou/cl_{cl}: (:class:`~torch.Tensor`), if argument ``class metrics=True``
- ciou/cl_{cl}: (:class:`~torch.Tensor`), if argument ``class_metrics=True``

Args:
box_format:
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/detection/diou.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class DistanceIntersectionOverUnion(IntersectionOverUnion):
r"""Computes Distance Intersection Over Union (DIoU) <https://arxiv.org/abs/1911.08287v1>`_.
r"""Computes Distance Intersection Over Union (`DIoU`_).

As input to ``forward`` and ``update`` the metric accepts the following input:

Expand Down Expand Up @@ -55,7 +55,7 @@ class DistanceIntersectionOverUnion(IntersectionOverUnion):
- ``diou_dict``: A dictionary containing the following key-values:

- diou: (:class:`~torch.Tensor`)
- diou/cl_{cl}: (:class:`~torch.Tensor`), if argument ``class metrics=True``
- diou/cl_{cl}: (:class:`~torch.Tensor`), if argument ``class_metrics=True``

Args:
box_format:
Expand Down
3 changes: 2 additions & 1 deletion src/torchmetrics/detection/giou.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class GeneralizedIntersectionOverUnion(IntersectionOverUnion):
r"""Compute Generalized Intersection Over Union (GIoU) <https://arxiv.org/abs/1902.09630>`_.
r"""Compute Generalized Intersection Over Union (`GIoU`_).

As input to ``forward`` and ``update`` the metric accepts the following input:

Expand Down Expand Up @@ -90,6 +90,7 @@ class GeneralizedIntersectionOverUnion(IntersectionOverUnion):
Raises:
ModuleNotFoundError:
If torchvision is not installed with version 0.8.0 or newer.

"""
_iou_type: str = "giou"
_invalid_val: float = -1.0
Expand Down
14 changes: 7 additions & 7 deletions src/torchmetrics/detection/panoptic_qualities.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
class PanopticQuality(Metric):
r"""Compute the `Panoptic Quality`_ for panoptic segmentations.

.. math::
PQ = \frac{IOU}{TP + 0.5 FP + 0.5 FN}
.. math::
PQ = \frac{IOU}{TP + 0.5 FP + 0.5 FN}

where IOU, TP, FP and FN are respectively the sum of the intersection over union for true positives,
the number of true postitives, false positives and false negatives. This metric is inspired by the PQ
implementation of panopticapi, a standard implementation for the PQ metric for panoptic segmentation.
where IOU, TP, FP and FN are respectively the sum of the intersection over union for true positives,
the number of true postitives, false positives and false negatives. This metric is inspired by the PQ
implementation of panopticapi, a standard implementation for the PQ metric for panoptic segmentation.

.. note:
Points in the target tensor that do not map to a known category ID are automatically ignored in the metric
Expand Down Expand Up @@ -226,8 +226,8 @@ class ModifiedPanopticQuality(Metric):
.. math::
PQ^{\dagger}_c = \frac{IOU_c}{|S_c|}

where IOU_c is the sum of the intersection over union of all matching segments for a given class, and \|S_c| is
the overall number of segments in the ground truth for that class.
where :math:`IOU_c` is the sum of the intersection over union of all matching segments for a given class, and
:math:`|S_c|` is the overall number of segments in the ground truth for that class.

.. note:
Points in the target tensor that do not map to a known category ID are automatically ignored in the metric
Expand Down
8 changes: 5 additions & 3 deletions src/torchmetrics/functional/audio/snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,18 @@ def complex_scale_invariant_signal_noise_ratio(preds: Tensor, target: Tensor, ze
"""`Complex scale-invariant signal-to-noise ratio`_ (C-SI-SNR).

Args:
preds: real/complex float tensor with shape ``(..., frequency, time, 2)``/``(..., frequency, time)``
target: real/complex float tensor with shape ``(..., frequency, time, 2)``/``(..., frequency, time)``
preds: real float tensor with shape ``(...,frequency,time,2)`` or complex float tensor with
shape ``(..., frequency,time)``
target: real float tensor with shape ``(...,frequency,time,2)`` or complex float tensor with
shape ``(..., frequency,time)``
zero_mean: When set to True, the mean of all signals is subtracted prior to computation of the metrics

Returns:
Float tensor with shape ``(...,)`` of C-SI-SNR values per sample

Raises:
RuntimeError:
If ``preds`` is not the shape (..., frequency, time, 2) (after being converted to real if it is complex).
If ``preds`` is not the shape (...,frequency,time,2) (after being converted to real if it is complex).
If ``preds`` and ``target`` does not have the same shape.

Example:
Expand Down
3 changes: 2 additions & 1 deletion src/torchmetrics/functional/detection/ciou.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def complete_intersection_over_union(
replacement_val: float = 0,
aggregate: bool = True,
) -> torch.Tensor:
r"""Compute `Complete Intersection over Union <https://arxiv.org/abs/2005.03572>`_ between two sets of boxes.
r"""Compute Complete Intersection over Union (`CIOU`_) between two sets of boxes.
Both sets of boxes are expected to be in (x1, y1, x2, y2) format with 0 <= x1 < x2 and 0 <= y1 < y2.
Expand All @@ -71,6 +71,7 @@ def complete_intersection_over_union(
>>> target = torch.Tensor([[110, 110, 210, 210]])
>>> complete_intersection_over_union(preds, target)
tensor(0.6724)
"""
if not _TORCHVISION_GREATER_EQUAL_0_13:
raise ModuleNotFoundError(
Expand Down
3 changes: 2 additions & 1 deletion src/torchmetrics/functional/detection/diou.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def distance_intersection_over_union(
replacement_val: float = 0,
aggregate: bool = True,
) -> torch.Tensor:
r"""Compute `Distance Intersection over Union <https://arxiv.org/abs/1911.08287v1>`_ between two sets of boxes.
r"""Compute Distance Intersection over Union (`DIOU`_) between two sets of boxes.
Both sets of boxes are expected to be in (x1, y1, x2, y2) format with 0 <= x1 < x2 and 0 <= y1 < y2.
Expand All @@ -71,6 +71,7 @@ def distance_intersection_over_union(
>>> target = torch.Tensor([[110, 110, 210, 210]])
>>> distance_intersection_over_union(preds, target)
tensor(0.6724)
"""
if not _TORCHVISION_GREATER_EQUAL_0_13:
raise ModuleNotFoundError(
Expand Down
3 changes: 2 additions & 1 deletion src/torchmetrics/functional/detection/giou.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generalized_intersection_over_union(
replacement_val: float = 0,
aggregate: bool = True,
) -> torch.Tensor:
r"""Compute `Generalized Intersection over Union <https://arxiv.org/abs/1902.09630>`_ between two sets of boxes.
r"""Compute Generalized Intersection over Union (`GIOU`_) between two sets of boxes.
Both sets of boxes are expected to be in (x1, y1, x2, y2) format with 0 <= x1 < x2 and 0 <= y1 < y2.
Expand All @@ -71,6 +71,7 @@ def generalized_intersection_over_union(
>>> target = torch.Tensor([[110, 110, 210, 210]])
>>> generalized_intersection_over_union(preds, target)
tensor(0.6641)
"""
if not _TORCHVISION_GREATER_EQUAL_0_8:
raise ModuleNotFoundError(
Expand Down
7 changes: 3 additions & 4 deletions src/torchmetrics/functional/detection/panoptic_qualities.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def panoptic_quality(
true postitives, false positives and false negatives. This metric is inspired by the PQ implementation of
panopticapi, a standard implementation for the PQ metric for object detection.


.. note:
Points in the target tensor that do not map to a known category ID are automatically ignored in the metric
computation.
Expand Down Expand Up @@ -120,8 +119,8 @@ def modified_panoptic_quality(
.. math::
PQ^{\dagger}_c = \frac{IOU_c}{|S_c|}

where IOU_c is the sum of the intersection over union of all matching segments for a given class, and \|S_c| is
the overall number of segments in the ground truth for that class.
where :math:`IOU_c` is the sum of the intersection over union of all matching segments for a given class, and
:math:`|S_c|` is the overall number of segments in the ground truth for that class.

.. note:
Points in the target tensor that do not map to a known category ID are automatically ignored in the metric
Expand Down Expand Up @@ -151,7 +150,7 @@ def modified_panoptic_quality(
TypeError:
If ``preds`` or ``target`` is not an ``torch.Tensor``.
ValueError:
If ``preds`` or ``target`` has different shape.
If ``preds`` or ``target`` has different shape.
ValueError:
If ``preds`` has less than 3 dimensions.
ValueError:
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/image/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class FrechetInceptionDistance(Metric):
The metric was originally proposed in `fid ref1`_.

Using the default feature extraction (Inception v3 using the original weights from `fid ref2`_), the input is
expected to be mini-batches of 3-channel RGB images of shape ``(3 x H x W)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0, 1]`` range, else if
expected to be mini-batches of 3-channel RGB images of shape ``(3xHxW)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0,1]`` range, else if
``normalize`` is set to ``False`` images are expected to have dtype ``uint8`` and take values in the ``[0, 255]``
range. All images will be resized to 299 x 299 which is the size of the original training data. The boolian
flag ``real`` determines if the images should update the statistics of the real distribution or the
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/image/inception.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class InceptionScore(Metric):
`inception ref1`_.

Using the default feature extraction (Inception v3 using the original weights from `inception ref2`_), the input
is expected to be mini-batches of 3-channel RGB images of shape ``(3 x H x W)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0, 1]`` range, else if
is expected to be mini-batches of 3-channel RGB images of shape ``(3xHxW)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0,1]`` range, else if
``normalize`` is set to ``False`` images are expected to have dtype uint8 and take values in the ``[0, 255]``
range. All images will be resized to 299 x 299 which is the size of the original training data.

Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/image/kid.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class KernelInceptionDistance(Metric):
subsets to be able to both get the mean and standard deviation of KID.

Using the default feature extraction (Inception v3 using the original weights from `kid ref2`_), the input is
expected to be mini-batches of 3-channel RGB images of shape ``(3 x H x W)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0, 1]`` range, else if
expected to be mini-batches of 3-channel RGB images of shape ``(3xHxW)``. If argument ``normalize``
is ``True`` images are expected to be dtype ``float`` and have values in the ``[0,1]`` range, else if
``normalize`` is set to ``False`` images are expected to have dtype ``uint8`` and take values in the ``[0, 255]``
range. All images will be resized to 299 x 299 which is the size of the original training data. The boolian
flag ``real`` determines if the images should update the statistics of the real distribution or the
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/image/ssim.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class MultiScaleStructuralSimilarityIndexMeasure(Metric):

As output of `forward` and `compute` the metric returns the following output

- ``msssim`` (: :class:`~torch.Tensor`): if ``reduction!='none'`` returns float scalar tensor with average MSSSIM
- ``msssim`` (:class:`~torch.Tensor`): if ``reduction!='none'`` returns float scalar tensor with average MSSSIM
value over sample else returns tensor of shape ``(N,)`` with SSIM values per sample

Args:
Expand Down
13 changes: 7 additions & 6 deletions src/torchmetrics/regression/minkowski.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
class MinkowskiDistance(Metric):
r"""Compute `Minkowski Distance`_.

.. math:: d_{\text{Minkowski}} = \\sum_{i}^N (| y_i - \\hat{y_i} |^p)^\frac{1}{p}
.. math::
d_{\text{Minkowski}} = \sum_{i}^N (| y_i - \hat{y_i} |^p)^\frac{1}{p}

where
:math: `y` is a tensor of target values,
:math: `\hat{y}` is a tensor of predictions,
:math: `\p` is a non-negative integer or floating-point number

This metric can be seen as generalized version of the standard euclidean distance which corresponds to minkowski
distance with p=2.

where
:math:`y` is a tensor of target values,
:math:`\\hat{y}` is a tensor of predictions,
:math: `\\p` is a non-negative integer or floating-point number

Args:
p: int or float larger than 1, exponent to which the difference between preds and target is to be raised
kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
Expand Down
Loading