Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions ignite/metrics/accumulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class VariableAccumulation(Metric):
- `+batch_size` if input is a ND `torch.Tensor`. Batch size is the first dimension (`shape[0]`).

Args:
op (callable): a callable to update accumulator. Method's signature is `(accumulator, output)`.
op: a callable to update accumulator. Method's signature is `(accumulator, output)`.
For example, to compute arithmetic mean value, `op = lambda a, x: a + x`.
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.

Expand Down Expand Up @@ -112,11 +112,11 @@ class Average(VariableAccumulation):
# state.metrics['mean_custom_var'] -> average of output['custom_var']

Args:
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.
"""
Expand Down Expand Up @@ -159,11 +159,11 @@ class GeometricAverage(VariableAccumulation):
is aggregated and added to the accumulator: `accumulator *= prod(x, dim=0)`

Args:
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.

Expand Down
6 changes: 3 additions & 3 deletions ignite/metrics/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def thresholded_output_transform(output):


Args:
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
is_multilabel (bool, optional): flag to use in multilabel case. By default, False.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
is_multilabel: flag to use in multilabel case. By default, False.
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.

Expand Down
30 changes: 15 additions & 15 deletions ignite/metrics/confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class ConfusionMatrix(Metric):
predicted classes.

Args:
num_classes (int): Number of classes, should be > 1. See notes for more details.
average (str, optional): confusion matrix values averaging schema: None, "samples", "recall", "precision".
num_classes: Number of classes, should be > 1. See notes for more details.
average: confusion matrix values averaging schema: None, "samples", "recall", "precision".
Default is None. If `average="samples"` then confusion matrix values are normalized by the number of seen
samples. If `average="recall"` then confusion matrix values are normalized such that diagonal values
represent class recalls. If `average="precision"` then confusion matrix values are normalized such that
diagonal values represent class precisions.
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.

Expand Down Expand Up @@ -161,8 +161,8 @@ def IoU(cm: ConfusionMatrix, ignore_index: Optional[int] = None) -> MetricsLambd
.. math:: \text{J}(A, B) = \frac{ \lvert A \cap B \rvert }{ \lvert A \cup B \rvert }

Args:
cm (ConfusionMatrix): instance of confusion matrix metric
ignore_index (int, optional): index to ignore, e.g. background index
cm: instance of confusion matrix metric
ignore_index: index to ignore, e.g. background index

Returns:
MetricsLambda
Expand Down Expand Up @@ -212,8 +212,8 @@ def mIoU(cm: ConfusionMatrix, ignore_index: Optional[int] = None) -> MetricsLamb
"""Calculates mean Intersection over Union using :class:`~ignite.metrics.ConfusionMatrix` metric.

Args:
cm (ConfusionMatrix): instance of confusion matrix metric
ignore_index (int, optional): index to ignore, e.g. background index
cm: instance of confusion matrix metric
ignore_index: index to ignore, e.g. background index

Returns:
MetricsLambda
Expand All @@ -240,7 +240,7 @@ def cmAccuracy(cm: ConfusionMatrix) -> MetricsLambda:
"""Calculates accuracy using :class:`~ignite.metrics.ConfusionMatrix` metric.

Args:
cm (ConfusionMatrix): instance of confusion matrix metric
cm: instance of confusion matrix metric

Returns:
MetricsLambda
Expand All @@ -255,8 +255,8 @@ def cmPrecision(cm: ConfusionMatrix, average: bool = True) -> MetricsLambda:
"""Calculates precision using :class:`~ignite.metrics.ConfusionMatrix` metric.

Args:
cm (ConfusionMatrix): instance of confusion matrix metric
average (bool, optional): if True metric value is averaged over all classes
cm: instance of confusion matrix metric
average: if True metric value is averaged over all classes
Returns:
MetricsLambda
"""
Expand All @@ -274,8 +274,8 @@ def cmRecall(cm: ConfusionMatrix, average: bool = True) -> MetricsLambda:
"""
Calculates recall using :class:`~ignite.metrics.ConfusionMatrix` metric.
Args:
cm (ConfusionMatrix): instance of confusion matrix metric
average (bool, optional): if True metric value is averaged over all classes
cm: instance of confusion matrix metric
average: if True metric value is averaged over all classes
Returns:
MetricsLambda
"""
Expand All @@ -293,8 +293,8 @@ def DiceCoefficient(cm: ConfusionMatrix, ignore_index: Optional[int] = None) ->
"""Calculates Dice Coefficient for a given :class:`~ignite.metrics.ConfusionMatrix` metric.

Args:
cm (ConfusionMatrix): instance of confusion matrix metric
ignore_index (int, optional): index to ignore, e.g. background index
cm: instance of confusion matrix metric
ignore_index: index to ignore, e.g. background index
"""

if not isinstance(cm, ConfusionMatrix):
Expand Down
8 changes: 4 additions & 4 deletions ignite/metrics/epoch_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class EpochMetric(Metric):
e.g. ``[[0, 1, 0, 1], ]``.

Args:
compute_fn (callable): a callable with the signature (`torch.tensor`, `torch.tensor`) takes as the input
compute_fn: a callable with the signature (`torch.tensor`, `torch.tensor`) takes as the input
`predictions` and `targets` and returns a scalar. Input tensors will be on specified ``device``
(see arg below).
output_transform (callable, optional): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
check_compute_fn (bool): if True, ``compute_fn`` is run on the first batch of data to ensure there are no
check_compute_fn: if True, ``compute_fn`` is run on the first batch of data to ensure there are no
issues. If issues exist, user is warned that there might be an issue with the ``compute_fn``.
Default, True.
device (str or torch.device, optional): optional device specification for internal storage.
device: optional device specification for internal storage.

Warnings:
EpochMetricWarning: User is warned that there are issues with ``compute_fn`` on a batch of data processed.
Expand Down
12 changes: 6 additions & 6 deletions ignite/metrics/fbeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def Fbeta(
where :math:`\beta` is a positive real factor.

Args:
beta (float): weight of precision in harmonic mean
average (bool, optional): if True, F-beta score is computed as the unweighted average (across all classes
beta: weight of precision in harmonic mean
average: if True, F-beta score is computed as the unweighted average (across all classes
in multiclass case), otherwise, returns a tensor with F-beta score for each class in multiclass case.
precision (Precision, optional): precision object metric with `average=False` to compute F-beta score
recall (Precision, optional): recall object metric with `average=False` to compute F-beta score
output_transform (callable, optional): a callable that is used to transform the
precision: precision object metric with `average=False` to compute F-beta score
recall: recall object metric with `average=False` to compute F-beta score
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. It is used only if precision or recall are not provided.
device (str or torch.device): specifies which device updates are accumulated on. Setting the metric's
device: specifies which device updates are accumulated on. Setting the metric's
device to be the same as your ``update`` arguments ensures the ``update`` method is non-blocking. By
default, CPU.

Expand Down
8 changes: 4 additions & 4 deletions ignite/metrics/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ class Loss(Metric):
Calculates the average loss according to the passed loss_fn.

Args:
loss_fn (callable): a callable taking a prediction tensor, a target
loss_fn: a callable taking a prediction tensor, a target
tensor, optionally other arguments, and returns the average loss
over all observations in the batch.
output_transform (callable): a callable that is used to transform the
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric.
This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
The output is expected to be a tuple `(prediction, target)` or
(prediction, target, kwargs) where kwargs is a dictionary of extra
keywords arguments. If extra keywords arguments are provided they are passed to `loss_fn`.
batch_size (callable): a callable taking a target tensor that returns the
batch_size: a callable taking a target tensor that returns the
first dimension size (usually the batch size).
device (str or torch.device): specifies which device updates are accumulated on. Setting the
device: specifies which device updates are accumulated on. Setting the
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
non-blocking. By default, CPU.

Expand Down
10 changes: 10 additions & 0 deletions ignite/metrics/mean_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class MeanAbsoluteError(Metric):
where :math:`y_{i}` is the prediction tensor and :math:`x_{i}` is ground true tensor.

- ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.

Args:
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
device: specifies which device updates are accumulated on. Setting the
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
non-blocking. By default, CPU.
"""

@reinit__is_reduced
Expand Down
12 changes: 12 additions & 0 deletions ignite/metrics/mean_pairwise_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ class MeanPairwiseDistance(Metric):
Average of pairwise distances computed on provided batches.

- ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.

Args:
p: the norm degree. Default: 2
eps: Small value to avoid division by zero. Default: 1e-6
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
device: specifies which device updates are accumulated on. Setting the
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
non-blocking. By default, CPU.
"""

def __init__(
Expand Down
10 changes: 10 additions & 0 deletions ignite/metrics/mean_squared_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class MeanSquaredError(Metric):
where :math:`y_{i}` is the prediction tensor and :math:`x_{i}` is ground true tensor.

- ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.

Args:
output_transform: a callable that is used to transform the
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. This can be useful if, for example, you have a multi-output model and
you want to compute the metric with respect to one of the outputs.
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
device: specifies which device updates are accumulated on. Setting the
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
non-blocking. By default, CPU.
"""

@reinit__is_reduced
Expand Down
Loading