diff --git a/CHANGELOG.md b/CHANGELOG.md index 57762a7bd6d..b2f065d7b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +- Deprecated method `compute_on_step` ([#792](https://github.com/PyTorchLightning/metrics/pull/792)) + ### Removed diff --git a/docs/source/pages/implement.rst b/docs/source/pages/implement.rst index 417b73edac6..35d3829082e 100644 --- a/docs/source/pages/implement.rst +++ b/docs/source/pages/implement.rst @@ -64,7 +64,7 @@ The cache is first emptied on the next call to ``update``. ``forward`` serves the dual purpose of both returning the metric on the current data and updating the internal metric state for accumulating over multiple batches. The ``forward()`` method achieves this by combining calls -to ``update`` and ``compute`` in the following way (assuming metric is initialized with ``compute_on_step=True``): +to ``update`` and ``compute`` in the following way: 1. Calls ``update()`` to update the global metric state (for accumulation over multiple batches) 2. Caches the global state. diff --git a/docs/source/pages/overview.rst b/docs/source/pages/overview.rst index 60820544d57..5cbe94023b1 100644 --- a/docs/source/pages/overview.rst +++ b/docs/source/pages/overview.rst @@ -27,7 +27,7 @@ This metrics API is independent of PyTorch Lightning. Metrics can directly be us from torchmetrics.classification import Accuracy train_accuracy = Accuracy() - valid_accuracy = Accuracy(compute_on_step=False) + valid_accuracy = Accuracy() for epoch in range(epochs): for x, y in train_data: @@ -35,16 +35,24 @@ This metrics API is independent of PyTorch Lightning. Metrics can directly be us # training step accuracy batch_acc = train_accuracy(y_hat, y) + print(f"Accuracy of batch{i} is {batch_acc}") for x, y in valid_data: y_hat = model(x) - valid_accuracy(y_hat, y) + valid_accuracy.update(y_hat, y) - # total accuracy over all training batches - total_train_accuracy = train_accuracy.compute() + # total accuracy over all training batches + total_train_accuracy = train_accuracy.compute() - # total accuracy over all validation batches - total_valid_accuracy = valid_accuracy.compute() + # total accuracy over all validation batches + total_valid_accuracy = valid_accuracy.compute() + + print(f"Training acc for epoch {epoch}: {total_train_accuracy}") + print(f"Validation acc for epoch {epoch}: {total_valid_accuracy}") + + # Reset metric states after each epoch + train_accuracy.reset() + valid_accuracy.reset() .. note:: diff --git a/tests/bases/test_composition.py b/tests/bases/test_composition.py index 36aec46b817..36516c9997a 100644 --- a/tests/bases/test_composition.py +++ b/tests/bases/test_composition.py @@ -553,26 +553,3 @@ def test_compositional_metrics_update(): assert compos.metric_a._num_updates == 3 assert compos.metric_b._num_updates == 3 - - -@pytest.mark.parametrize("compute_on_step", [True, False]) -@pytest.mark.parametrize("metric_b", [4, DummyMetric(4)]) -def test_compositional_metrics_forward(compute_on_step, metric_b): - """test forward method of compositional metrics.""" - metric_a = DummyMetric(5) - metric_a.compute_on_step = compute_on_step - compos = metric_a + metric_b - - assert isinstance(compos, CompositionalMetric) - for _ in range(3): - val = compos() - assert val == 9 if compute_on_step else val is None - - assert isinstance(compos.metric_a, DummyMetric) - assert compos.metric_a._num_updates == 3 - - if isinstance(metric_b, DummyMetric): - assert isinstance(compos.metric_b, DummyMetric) - assert compos.metric_b._num_updates == 3 - - compos.reset() diff --git a/tests/wrappers/test_multioutput.py b/tests/wrappers/test_multioutput.py index 35ab90af092..78521c3837f 100644 --- a/tests/wrappers/test_multioutput.py +++ b/tests/wrappers/test_multioutput.py @@ -24,7 +24,7 @@ def __init__( self, base_metric_class, num_outputs: int = 1, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Any = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/aggregation.py b/torchmetrics/aggregation.py index 3b586748471..15bd1268f13 100644 --- a/torchmetrics/aggregation.py +++ b/torchmetrics/aggregation.py @@ -34,8 +34,11 @@ class BaseAggregator(Metric): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -59,7 +62,7 @@ def __init__( fn: Union[Callable, str], default_value: Union[Tensor, List], nan_strategy: Union[str, float] = "error", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -120,8 +123,11 @@ class MaxMetric(BaseAggregator): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -147,7 +153,7 @@ class MaxMetric(BaseAggregator): def __init__( self, nan_strategy: Union[str, float] = "warn", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -185,8 +191,11 @@ class MinMetric(BaseAggregator): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -212,7 +221,7 @@ class MinMetric(BaseAggregator): def __init__( self, nan_strategy: Union[str, float] = "warn", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -250,8 +259,11 @@ class SumMetric(BaseAggregator): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -277,7 +289,7 @@ class SumMetric(BaseAggregator): def __init__( self, nan_strategy: Union[str, float] = "warn", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -308,8 +320,11 @@ class CatMetric(BaseAggregator): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -335,7 +350,7 @@ class CatMetric(BaseAggregator): def __init__( self, nan_strategy: Union[str, float] = "warn", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -371,8 +386,11 @@ class MeanMetric(BaseAggregator): - a float: if a float is provided will impude any `nan` values with this value compute_on_step: - Forward only calls ``update()`` and returns None if this is - set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -398,7 +416,7 @@ class MeanMetric(BaseAggregator): def __init__( self, nan_strategy: Union[str, float] = "warn", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/audio/pesq.py b/torchmetrics/audio/pesq.py index 6f977798469..5a980a76141 100644 --- a/torchmetrics/audio/pesq.py +++ b/torchmetrics/audio/pesq.py @@ -44,7 +44,11 @@ class PerceptualEvaluationSpeechQuality(Metric): keep_same_device: whether to move the pesq value to the device of preds compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -89,7 +93,7 @@ def __init__( self, fs: int, mode: str, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, diff --git a/torchmetrics/audio/pit.py b/torchmetrics/audio/pit.py index e69a078ccd7..69f247c38dc 100644 --- a/torchmetrics/audio/pit.py +++ b/torchmetrics/audio/pit.py @@ -39,6 +39,10 @@ class PermutationInvariantTraining(Metric): or the larger the better. compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -78,7 +82,7 @@ def __init__( self, metric_func: Callable, eval_func: str = "max", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, diff --git a/torchmetrics/audio/sdr.py b/torchmetrics/audio/sdr.py index feb47a49cb4..ddfe41e2b54 100644 --- a/torchmetrics/audio/sdr.py +++ b/torchmetrics/audio/sdr.py @@ -49,6 +49,10 @@ class SignalDistortionRatio(Metric): signals may sometimes be zero compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -110,7 +114,7 @@ def __init__( filter_length: int = 512, zero_mean: bool = False, load_diag: Optional[float] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, @@ -168,6 +172,10 @@ class ScaleInvariantSignalDistortionRatio(Metric): if to zero mean target and preds or not compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -206,7 +214,7 @@ class ScaleInvariantSignalDistortionRatio(Metric): def __init__( self, zero_mean: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, diff --git a/torchmetrics/audio/snr.py b/torchmetrics/audio/snr.py index d31613e4348..ffdc39d1fed 100644 --- a/torchmetrics/audio/snr.py +++ b/torchmetrics/audio/snr.py @@ -39,6 +39,10 @@ class SignalNoiseRatio(Metric): if to zero mean target and preds or not compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -77,7 +81,7 @@ class SignalNoiseRatio(Metric): def __init__( self, zero_mean: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, @@ -121,6 +125,10 @@ class ScaleInvariantSignalNoiseRatio(Metric): Args: compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -159,7 +167,7 @@ class ScaleInvariantSignalNoiseRatio(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, diff --git a/torchmetrics/audio/stoi.py b/torchmetrics/audio/stoi.py index 94a92bbeaa0..a7327554c8e 100644 --- a/torchmetrics/audio/stoi.py +++ b/torchmetrics/audio/stoi.py @@ -48,6 +48,10 @@ class ShortTimeObjectiveIntelligibility(Metric): whether to use the extended STOI described in [4] compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -96,7 +100,7 @@ def __init__( self, fs: int, extended: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable[[Tensor], Tensor]] = None, diff --git a/torchmetrics/classification/accuracy.py b/torchmetrics/classification/accuracy.py index b6dec6f8036..8d64862bafe 100644 --- a/torchmetrics/classification/accuracy.py +++ b/torchmetrics/classification/accuracy.py @@ -127,7 +127,11 @@ class Accuracy(StatScores): still applies in both cases, if set. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -179,7 +183,7 @@ def __init__( top_k: Optional[int] = None, multiclass: Optional[bool] = None, subset_accuracy: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/auc.py b/torchmetrics/classification/auc.py index a10fddbe98d..d6b52945721 100644 --- a/torchmetrics/classification/auc.py +++ b/torchmetrics/classification/auc.py @@ -33,7 +33,11 @@ class AUC(Metric): setting this argument to ``True`` will use a stable sorting algorithm to sort the input in descending order compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -50,7 +54,7 @@ class AUC(Metric): def __init__( self, reorder: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/auroc.py b/torchmetrics/classification/auroc.py index 29fd15a44b8..9b8c13f3b98 100644 --- a/torchmetrics/classification/auroc.py +++ b/torchmetrics/classification/auroc.py @@ -47,32 +47,35 @@ class AUROC(Metric): with an warning. Args: - num_classes: integer with number of classes for multi-label and multiclass problems. - Should be set to ``None`` for binary problems - pos_label: integer determining the positive class. Default is ``None`` - which for binary problem is translate to 1. For multiclass problems - this argument should not be set as we iteratively change it in the - range [0,num_classes-1] - average: - - ``'micro'`` computes metric globally. Only works for multilabel problems - - ``'macro'`` computes metric for each class and uniformly averages them - - ``'weighted'`` computes metric for each class and does a weighted-average, - where each class is weighted by their support (accounts for class imbalance) - - ``None`` computes and returns the metric per class - max_fpr: - If not ``None``, calculates standardized partial AUC over the - range [0, max_fpr]. Should be a float between 0 and 1. - compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. - dist_sync_on_step: - Synchronize metric state across processes at each ``forward()`` - before returning the value at the step. - process_group: - Specify the process group on which synchronization is called. - - dist_sync_fn: - Callback that performs the allgather operation on the metric state. When ``None``, DDP - will be used to perform the allgather + num_classes: integer with number of classes for multi-label and multiclass problems. + Should be set to ``None`` for binary problems + pos_label: integer determining the positive class. Default is ``None`` + which for binary problem is translate to 1. For multiclass problems + this argument should not be set as we iteratively change it in the + range [0,num_classes-1] + average: + - ``'micro'`` computes metric globally. Only works for multilabel problems + - ``'macro'`` computes metric for each class and uniformly averages them + - ``'weighted'`` computes metric for each class and does a weighted-average, + where each class is weighted by their support (accounts for class imbalance) + - ``None`` computes and returns the metric per class + max_fpr: + If not ``None``, calculates standardized partial AUC over the + range [0, max_fpr]. Should be a float between 0 and 1. + compute_on_step: + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + + dist_sync_on_step: + Synchronize metric state across processes at each ``forward()`` + before returning the value at the step. + process_group: + Specify the process group on which synchronization is called. + dist_sync_fn: + Callback that performs the allgather operation on the metric state. When ``None``, DDP + will be used to perform the allgather Raises: ValueError: @@ -116,7 +119,7 @@ def __init__( pos_label: Optional[int] = None, average: Optional[str] = "macro", max_fpr: Optional[float] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/avg_precision.py b/torchmetrics/classification/avg_precision.py index 8a8aa0b04d4..dbfcabcbf13 100644 --- a/torchmetrics/classification/avg_precision.py +++ b/torchmetrics/classification/avg_precision.py @@ -58,7 +58,11 @@ class AveragePrecision(Metric): the metric for every class. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -93,7 +97,7 @@ def __init__( num_classes: Optional[int] = None, pos_label: Optional[int] = None, average: Optional[str] = "macro", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/binned_precision_recall.py b/torchmetrics/classification/binned_precision_recall.py index 0abe42b6d6d..0e63710f1a2 100644 --- a/torchmetrics/classification/binned_precision_recall.py +++ b/torchmetrics/classification/binned_precision_recall.py @@ -62,7 +62,11 @@ class BinnedPrecisionRecallCurve(Metric): It is used for computation will lead to more detailed curve and accurate estimates, but will be slower and consume more memory. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -122,7 +126,7 @@ def __init__( self, num_classes: int, thresholds: Union[int, Tensor, List[float], None] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: @@ -210,7 +214,11 @@ class BinnedAveragePrecision(BinnedPrecisionRecallCurve): It is used for computation will lead to more detailed curve and accurate estimates, but will be slower and consume more memory compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + process_group: Specify the process group on which synchronization is called. @@ -262,7 +270,11 @@ class BinnedRecallAtFixedPrecision(BinnedPrecisionRecallCurve): It is used for computation will lead to more detailed curve and accurate estimates, but will be slower and consume more memory compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + process_group: Specify the process group on which synchronization is called. @@ -295,7 +307,7 @@ def __init__( num_classes: int, min_precision: float, thresholds: Union[int, Tensor, List[float], None] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/calibration_error.py b/torchmetrics/classification/calibration_error.py index 3a8d0782efc..f387aebdc9f 100644 --- a/torchmetrics/classification/calibration_error.py +++ b/torchmetrics/classification/calibration_error.py @@ -54,7 +54,12 @@ class CalibrationError(Metric): norm: Norm used to compare empirical and expected probability bins. Defaults to "l1", or Expected Calibration Error. debias: Applies debiasing term, only implemented for l2 norm. Defaults to True. - compute_on_step: Forward only calls ``update()`` and return None if this is set to False. + compute_on_step: + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step process_group: Specify the process group on which synchronization is called. diff --git a/torchmetrics/classification/cohen_kappa.py b/torchmetrics/classification/cohen_kappa.py index 1583405f352..592ebd1c644 100644 --- a/torchmetrics/classification/cohen_kappa.py +++ b/torchmetrics/classification/cohen_kappa.py @@ -59,7 +59,11 @@ class labels. of binary or multi-label inputs. Default value of 0.5 corresponds to input being probabilities. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` @@ -86,7 +90,7 @@ def __init__( num_classes: int, weights: Optional[str] = None, threshold: float = 0.5, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/confusion_matrix.py b/torchmetrics/classification/confusion_matrix.py index e1df6b4ba4f..0a2a0731438 100644 --- a/torchmetrics/classification/confusion_matrix.py +++ b/torchmetrics/classification/confusion_matrix.py @@ -56,7 +56,11 @@ class ConfusionMatrix(Metric): multilabel: determines if data is multilabel or not. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -100,7 +104,7 @@ def __init__( normalize: Optional[str] = None, threshold: float = 0.5, multilabel: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/f_beta.py b/torchmetrics/classification/f_beta.py index 24ad3bc47ca..50e3da60bf5 100644 --- a/torchmetrics/classification/f_beta.py +++ b/torchmetrics/classification/f_beta.py @@ -107,7 +107,11 @@ class FBetaScore(StatScores): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -142,7 +146,7 @@ def __init__( ignore_index: Optional[int] = None, top_k: Optional[int] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -248,7 +252,11 @@ class F1Score(FBetaScore): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -281,7 +289,7 @@ def __init__( ignore_index: Optional[int] = None, top_k: Optional[int] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/hamming.py b/torchmetrics/classification/hamming.py index ea9e34c8ba4..9cbe3256780 100644 --- a/torchmetrics/classification/hamming.py +++ b/torchmetrics/classification/hamming.py @@ -43,7 +43,11 @@ class HammingDistance(Metric): Threshold for transforming probability or logit predictions to binary (0,1) predictions, in the case of binary or multi-label inputs. Default value of 0.5 corresponds to input being probabilities. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -75,7 +79,7 @@ class HammingDistance(Metric): def __init__( self, threshold: float = 0.5, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/hinge.py b/torchmetrics/classification/hinge.py index ac69491d97e..2948bac0dec 100644 --- a/torchmetrics/classification/hinge.py +++ b/torchmetrics/classification/hinge.py @@ -93,7 +93,7 @@ def __init__( self, squared: bool = False, multiclass_mode: Optional[Union[str, MulticlassMode]] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/jaccard.py b/torchmetrics/classification/jaccard.py index 35e7fd4380e..a638fbff1d2 100644 --- a/torchmetrics/classification/jaccard.py +++ b/torchmetrics/classification/jaccard.py @@ -60,7 +60,11 @@ class JaccardIndex(ConfusionMatrix): - ``'none'``: no reduction will be applied compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -87,7 +91,7 @@ def __init__( absent_score: float = 0.0, threshold: float = 0.5, reduction: str = "elementwise_mean", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/kl_divergence.py b/torchmetrics/classification/kl_divergence.py index 1a6f6af1407..a929229bbf5 100644 --- a/torchmetrics/classification/kl_divergence.py +++ b/torchmetrics/classification/kl_divergence.py @@ -71,7 +71,7 @@ def __init__( self, log_prob: bool = False, reduction: Optional[str] = "mean", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/matthews_corrcoef.py b/torchmetrics/classification/matthews_corrcoef.py index c643927f314..2b168a8b328 100644 --- a/torchmetrics/classification/matthews_corrcoef.py +++ b/torchmetrics/classification/matthews_corrcoef.py @@ -54,7 +54,11 @@ class MatthewsCorrCoef(Metric): threshold: Threshold value for binary or multi-label probabilites. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -81,7 +85,7 @@ def __init__( self, num_classes: int, threshold: float = 0.5, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/precision_recall.py b/torchmetrics/classification/precision_recall.py index 627fde14a4b..27b2ff33652 100644 --- a/torchmetrics/classification/precision_recall.py +++ b/torchmetrics/classification/precision_recall.py @@ -93,7 +93,11 @@ class Precision(StatScores): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -132,7 +136,7 @@ def __init__( ignore_index: Optional[int] = None, top_k: Optional[int] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -244,7 +248,11 @@ class Recall(StatScores): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -283,7 +291,7 @@ def __init__( ignore_index: Optional[int] = None, top_k: Optional[int] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/precision_recall_curve.py b/torchmetrics/classification/precision_recall_curve.py index 54ca2c08696..c38bfb7ebab 100644 --- a/torchmetrics/classification/precision_recall_curve.py +++ b/torchmetrics/classification/precision_recall_curve.py @@ -44,7 +44,11 @@ class PrecisionRecallCurve(Metric): this argument should not be set as we iteratively change it in the range [0,num_classes-1] compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -89,7 +93,7 @@ def __init__( self, num_classes: Optional[int] = None, pos_label: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/classification/roc.py b/torchmetrics/classification/roc.py index c52597f0359..de82c825e03 100644 --- a/torchmetrics/classification/roc.py +++ b/torchmetrics/classification/roc.py @@ -45,7 +45,11 @@ class ROC(Metric): this argument should not be set as we iteratively change it in the range [0,num_classes-1] compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -116,7 +120,7 @@ def __init__( self, num_classes: Optional[int] = None, pos_label: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/specificity.py b/torchmetrics/classification/specificity.py index c21ccb8211a..37a49190b4d 100644 --- a/torchmetrics/classification/specificity.py +++ b/torchmetrics/classification/specificity.py @@ -94,7 +94,11 @@ class Specificity(StatScores): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -133,7 +137,7 @@ def __init__( ignore_index: Optional[int] = None, top_k: Optional[int] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/classification/stat_scores.py b/torchmetrics/classification/stat_scores.py index 89337403401..63d885fa10e 100644 --- a/torchmetrics/classification/stat_scores.py +++ b/torchmetrics/classification/stat_scores.py @@ -91,7 +91,11 @@ class StatScores(Metric): for a more detailed explanation and examples. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -143,7 +147,7 @@ def __init__( ignore_index: Optional[int] = None, mdmc_reduce: Optional[str] = None, multiclass: Optional[bool] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/detection/map.py b/torchmetrics/detection/map.py index e26fca8ae79..d1de3ddc16a 100644 --- a/torchmetrics/detection/map.py +++ b/torchmetrics/detection/map.py @@ -169,7 +169,11 @@ class MeanAveragePrecision(Metric): class_metrics: Option to enable per-class metrics for mAP and mAR_100. Has a performance impact. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -235,7 +239,7 @@ def __init__( rec_thresholds: Optional[List[float]] = None, max_detection_thresholds: Optional[List[int]] = None, class_metrics: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/image/fid.py b/torchmetrics/image/fid.py index 5a023bd9425..b3f5b1613c5 100644 --- a/torchmetrics/image/fid.py +++ b/torchmetrics/image/fid.py @@ -162,7 +162,11 @@ class FrechetInceptionDistance(Metric): an ``[N,d]`` matrix where ``N`` is the batch size and ``d`` is the feature size. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step diff --git a/torchmetrics/image/inception.py b/torchmetrics/image/inception.py index a9a2fac1dd1..2601b982419 100644 --- a/torchmetrics/image/inception.py +++ b/torchmetrics/image/inception.py @@ -62,7 +62,11 @@ class InceptionScore(Metric): splits: integer determining how many splits the inception score calculation should be split among compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step diff --git a/torchmetrics/image/kid.py b/torchmetrics/image/kid.py index 4726298ac11..4ccf0201d9c 100644 --- a/torchmetrics/image/kid.py +++ b/torchmetrics/image/kid.py @@ -113,7 +113,11 @@ class KernelInceptionDistance(Metric): coef: Bias term in the polynomial kernel. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step diff --git a/torchmetrics/image/lpip.py b/torchmetrics/image/lpip.py index f492961057c..6e1cfa179e2 100644 --- a/torchmetrics/image/lpip.py +++ b/torchmetrics/image/lpip.py @@ -59,7 +59,11 @@ class LearnedPerceptualImagePatchSimilarity(Metric): net_type: str indicating backbone network type to use. Choose between `'alex'`, `'vgg'` or `'squeeze'` reduction: str indicating how to reduce over the batch dimension. Choose between `'sum'` or `'mean'`. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step @@ -101,7 +105,7 @@ def __init__( self, net_type: str = "alex", reduction: str = "mean", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable[[Tensor], List[Tensor]] = None, diff --git a/torchmetrics/image/psnr.py b/torchmetrics/image/psnr.py index 5f92154ebe4..0108cc5e3f6 100644 --- a/torchmetrics/image/psnr.py +++ b/torchmetrics/image/psnr.py @@ -44,7 +44,11 @@ class PeakSignalNoiseRatio(Metric): Dimensions to reduce PSNR scores over, provided as either an integer or a list of integers. Default is None meaning scores will be reduced across all dimensions and all batches. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -77,7 +81,7 @@ def __init__( base: float = 10.0, reduction: str = "elementwise_mean", dim: Optional[Union[int, Tuple[int, ...]]] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/image/ssim.py b/torchmetrics/image/ssim.py index 1f5aab9973e..b94cbf4ebd3 100644 --- a/torchmetrics/image/ssim.py +++ b/torchmetrics/image/ssim.py @@ -63,7 +63,7 @@ def __init__( data_range: Optional[float] = None, k1: float = 0.01, k2: float = 0.03, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: @@ -161,7 +161,7 @@ def __init__( k2: float = 0.03, betas: Tuple[float, ...] = (0.0448, 0.2856, 0.3001, 0.2363, 0.1333), normalize: Optional[Literal["relu", "simple"]] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/metric.py b/torchmetrics/metric.py index f5620ff5294..d45a9bcaf84 100644 --- a/torchmetrics/metric.py +++ b/torchmetrics/metric.py @@ -13,6 +13,7 @@ # limitations under the License. import functools import inspect +import warnings from abc import ABC, abstractmethod from contextlib import contextmanager from copy import deepcopy @@ -62,6 +63,10 @@ class Metric(Module, ABC): Args: compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -80,7 +85,7 @@ class Metric(Module, ABC): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -93,8 +98,10 @@ def __init__( self._device = torch.device("cpu") + if compute_on_step is not None: + warnings.warn("Argument `decimal_places` is deprecated in v0.8 and will be removed in v0.9") + self.dist_sync_on_step = dist_sync_on_step - self.compute_on_step = compute_on_step self.process_group = process_group self.dist_sync_fn = dist_sync_fn self._to_sync = True @@ -201,29 +208,28 @@ def forward(self, *args: Any, **kwargs: Any) -> Any: with torch.no_grad(): self.update(*args, **kwargs) - if self.compute_on_step: - self._to_sync = self.dist_sync_on_step - # skip restore cache operation from compute as cache is stored below. - self._should_unsync = False + self._to_sync = self.dist_sync_on_step + # skip restore cache operation from compute as cache is stored below. + self._should_unsync = False - # save context before switch - cache = {attr: getattr(self, attr) for attr in self._defaults} + # save context before switch + cache = {attr: getattr(self, attr) for attr in self._defaults} - # call reset, update, compute, on single batch - self.reset() - self.update(*args, **kwargs) - self._forward_cache = self.compute() + # call reset, update, compute, on single batch + self.reset() + self.update(*args, **kwargs) + self._forward_cache = self.compute() - # restore context - for attr, val in cache.items(): - setattr(self, attr, val) - self._is_synced = False + # restore context + for attr, val in cache.items(): + setattr(self, attr, val) + self._is_synced = False - self._should_unsync = True - self._to_sync = True - self._computed = None + self._should_unsync = True + self._to_sync = True + self._computed = None - return self._forward_cache + return self._forward_cache def _sync_dist(self, dist_sync_fn: Callable = gather_all_tensors, process_group: Optional[Any] = None) -> None: input_dict = {attr: getattr(self, attr) for attr in self._reductions} diff --git a/torchmetrics/regression/cosine_similarity.py b/torchmetrics/regression/cosine_similarity.py index 42c1e4d9095..8ff2cbbe9f1 100644 --- a/torchmetrics/regression/cosine_similarity.py +++ b/torchmetrics/regression/cosine_similarity.py @@ -41,7 +41,11 @@ class CosineSimilarity(Metric): reduction: how to reduce over the batch dimension using 'sum', 'mean' or 'none' (taking the individual scores) compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -69,7 +73,7 @@ class CosineSimilarity(Metric): def __init__( self, reduction: str = "sum", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/explained_variance.py b/torchmetrics/regression/explained_variance.py index f4711e67579..b55dc505bf5 100644 --- a/torchmetrics/regression/explained_variance.py +++ b/torchmetrics/regression/explained_variance.py @@ -51,7 +51,11 @@ class ExplainedVariance(Metric): * `'variance_weighted'` scores are weighted by their individual variances compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -88,7 +92,7 @@ class ExplainedVariance(Metric): def __init__( self, multioutput: str = "uniform_average", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/log_mse.py b/torchmetrics/regression/log_mse.py index 70f057b6db8..d59a563cea2 100644 --- a/torchmetrics/regression/log_mse.py +++ b/torchmetrics/regression/log_mse.py @@ -30,7 +30,11 @@ class MeanSquaredLogError(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -56,7 +60,7 @@ class MeanSquaredLogError(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/mae.py b/torchmetrics/regression/mae.py index b4eeecbe62a..f4d623f5f50 100644 --- a/torchmetrics/regression/mae.py +++ b/torchmetrics/regression/mae.py @@ -30,7 +30,11 @@ class MeanAbsoluteError(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -52,7 +56,7 @@ class MeanAbsoluteError(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/mape.py b/torchmetrics/regression/mape.py index d71cc8f6719..f858d4b80b1 100644 --- a/torchmetrics/regression/mape.py +++ b/torchmetrics/regression/mape.py @@ -33,7 +33,11 @@ class MeanAbsolutePercentageError(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -64,7 +68,7 @@ class MeanAbsolutePercentageError(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/mse.py b/torchmetrics/regression/mse.py index 3f3ab129f5a..866aac39650 100644 --- a/torchmetrics/regression/mse.py +++ b/torchmetrics/regression/mse.py @@ -30,7 +30,11 @@ class MeanSquaredError(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -55,7 +59,7 @@ class MeanSquaredError(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/pearson.py b/torchmetrics/regression/pearson.py index 8224a2e112c..492f112a7e4 100644 --- a/torchmetrics/regression/pearson.py +++ b/torchmetrics/regression/pearson.py @@ -69,7 +69,11 @@ class PearsonCorrCoef(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -98,7 +102,7 @@ class PearsonCorrCoef(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, ) -> None: diff --git a/torchmetrics/regression/r2.py b/torchmetrics/regression/r2.py index 07b3815a516..646c0f84bfe 100644 --- a/torchmetrics/regression/r2.py +++ b/torchmetrics/regression/r2.py @@ -59,7 +59,11 @@ class R2Score(Metric): * ``'variance_weighted'`` scores are weighted by their individual variances compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -99,7 +103,7 @@ def __init__( num_outputs: int = 1, adjusted: int = 0, multioutput: str = "uniform_average", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/spearman.py b/torchmetrics/regression/spearman.py index 5e1ce05529c..c43f1adc3cb 100644 --- a/torchmetrics/regression/spearman.py +++ b/torchmetrics/regression/spearman.py @@ -34,7 +34,11 @@ class SpearmanCorrCoef(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -60,7 +64,7 @@ class SpearmanCorrCoef(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/regression/symmetric_mape.py b/torchmetrics/regression/symmetric_mape.py index f05822a6115..e926bc4d6e2 100644 --- a/torchmetrics/regression/symmetric_mape.py +++ b/torchmetrics/regression/symmetric_mape.py @@ -33,7 +33,11 @@ class SymmetricMeanAbsolutePercentageError(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. process_group: @@ -61,7 +65,7 @@ class SymmetricMeanAbsolutePercentageError(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/regression/tweedie_deviance.py b/torchmetrics/regression/tweedie_deviance.py index bf1d37c5f90..ec62915dc62 100644 --- a/torchmetrics/regression/tweedie_deviance.py +++ b/torchmetrics/regression/tweedie_deviance.py @@ -54,7 +54,11 @@ class TweedieDevianceScore(Metric): - power = 3 : Inverse Gaussian distribution. (Requires: targets > 0 and preds > 0.) - otherwise : Positive stable distribution. (Requires: targets > 0 and preds > 0.) compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -82,7 +86,7 @@ class TweedieDevianceScore(Metric): def __init__( self, power: float = 0.0, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/average_precision.py b/torchmetrics/retrieval/average_precision.py index 177b1d6952d..66e02c5b48b 100644 --- a/torchmetrics/retrieval/average_precision.py +++ b/torchmetrics/retrieval/average_precision.py @@ -45,7 +45,11 @@ class RetrievalMAP(RetrievalMetric): ignore_index: Ignore predictions where the target is equal to this number. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. diff --git a/torchmetrics/retrieval/base.py b/torchmetrics/retrieval/base.py index b4a3759bea6..68c6c08ad7f 100644 --- a/torchmetrics/retrieval/base.py +++ b/torchmetrics/retrieval/base.py @@ -54,7 +54,11 @@ class RetrievalMetric(Metric, ABC): ignore_index: Ignore predictions where the target is equal to this number. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -80,7 +84,7 @@ def __init__( self, empty_target_action: str = "neg", ignore_index: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/fall_out.py b/torchmetrics/retrieval/fall_out.py index 2980694465c..9faa6778220 100644 --- a/torchmetrics/retrieval/fall_out.py +++ b/torchmetrics/retrieval/fall_out.py @@ -50,7 +50,11 @@ class RetrievalFallOut(RetrievalMetric): Ignore predictions where the target is equal to this number. k: consider only the top k elements for each query (default: `None`, which considers them all) compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -85,7 +89,7 @@ def __init__( empty_target_action: str = "pos", ignore_index: Optional[int] = None, k: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/hit_rate.py b/torchmetrics/retrieval/hit_rate.py index b70c6ebab07..3a8c5616a92 100644 --- a/torchmetrics/retrieval/hit_rate.py +++ b/torchmetrics/retrieval/hit_rate.py @@ -48,7 +48,11 @@ class RetrievalHitRate(RetrievalMetric): Ignore predictions where the target is equal to this number. k: consider only the top k elements for each query (default: `None`, which considers them all) compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -83,7 +87,7 @@ def __init__( empty_target_action: str = "neg", ignore_index: Optional[int] = None, k: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/ndcg.py b/torchmetrics/retrieval/ndcg.py index 17e23dccd10..3465ecd18db 100644 --- a/torchmetrics/retrieval/ndcg.py +++ b/torchmetrics/retrieval/ndcg.py @@ -48,7 +48,11 @@ class RetrievalNormalizedDCG(RetrievalMetric): Ignore predictions where the target is equal to this number. k: consider only the top k elements for each query (default: `None`, which considers them all) compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -83,7 +87,7 @@ def __init__( empty_target_action: str = "neg", ignore_index: Optional[int] = None, k: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/precision.py b/torchmetrics/retrieval/precision.py index 8f19a74e0bd..8584d672f8b 100644 --- a/torchmetrics/retrieval/precision.py +++ b/torchmetrics/retrieval/precision.py @@ -48,7 +48,11 @@ class RetrievalPrecision(RetrievalMetric): Ignore predictions where the target is equal to this number. k: consider only the top k elements for each query (default: `None`, which considers them all) compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -83,7 +87,7 @@ def __init__( empty_target_action: str = "neg", ignore_index: Optional[int] = None, k: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/r_precision.py b/torchmetrics/retrieval/r_precision.py index 12b530ce0ea..ba350cf2115 100644 --- a/torchmetrics/retrieval/r_precision.py +++ b/torchmetrics/retrieval/r_precision.py @@ -45,7 +45,11 @@ class RetrievalRPrecision(RetrievalMetric): ignore_index: Ignore predictions where the target is equal to this number. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. diff --git a/torchmetrics/retrieval/recall.py b/torchmetrics/retrieval/recall.py index 2e8a1504c61..1674adc6e52 100644 --- a/torchmetrics/retrieval/recall.py +++ b/torchmetrics/retrieval/recall.py @@ -48,7 +48,11 @@ class RetrievalRecall(RetrievalMetric): Ignore predictions where the target is equal to this number. k: consider only the top k elements for each query (default: `None`, which considers them all) compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -83,7 +87,7 @@ def __init__( empty_target_action: str = "neg", ignore_index: Optional[int] = None, k: Optional[int] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/retrieval/reciprocal_rank.py b/torchmetrics/retrieval/reciprocal_rank.py index cdcf25a6213..79a6a4a8e75 100644 --- a/torchmetrics/retrieval/reciprocal_rank.py +++ b/torchmetrics/retrieval/reciprocal_rank.py @@ -45,7 +45,11 @@ class RetrievalMRR(RetrievalMetric): ignore_index: Ignore predictions where the target is equal to this number. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. diff --git a/torchmetrics/text/bert.py b/torchmetrics/text/bert.py index 99cc0f1563d..b53b88b5b0d 100644 --- a/torchmetrics/text/bert.py +++ b/torchmetrics/text/bert.py @@ -97,7 +97,11 @@ class BERTScore(Metric): baseline_url: A url path to the user's own csv/tsv file with the baseline scale. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -148,7 +152,7 @@ def __init__( rescale_with_baseline: bool = False, baseline_path: Optional[str] = None, baseline_url: Optional[str] = None, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/bleu.py b/torchmetrics/text/bleu.py index 31b0c6709dc..dea595f4b44 100644 --- a/torchmetrics/text/bleu.py +++ b/torchmetrics/text/bleu.py @@ -33,9 +33,13 @@ class BLEUScore(Metric): n_gram: Gram value ranged from 1 to 4 (Default 4) smooth: - Whether or not to apply smoothing – see [2] + Whether or not to apply smoothing, see [2] compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -72,7 +76,7 @@ def __init__( self, n_gram: int = 4, smooth: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/text/cer.py b/torchmetrics/text/cer.py index 078bf58b6fc..a60ae6a8eaf 100644 --- a/torchmetrics/text/cer.py +++ b/torchmetrics/text/cer.py @@ -43,7 +43,11 @@ class CharErrorRate(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -70,7 +74,7 @@ class CharErrorRate(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/chrf.py b/torchmetrics/text/chrf.py index 487c26b627f..11cfcce3834 100644 --- a/torchmetrics/text/chrf.py +++ b/torchmetrics/text/chrf.py @@ -65,6 +65,10 @@ class CHRFScore(Metric): An indication whether a sentence-level chrF/chrF++ score to be returned. compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -107,7 +111,7 @@ def __init__( lowercase: bool = False, whitespace: bool = False, return_sentence_level_score: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/text/eed.py b/torchmetrics/text/eed.py index 99c7b90e72a..e7abd71cb13 100644 --- a/torchmetrics/text/eed.py +++ b/torchmetrics/text/eed.py @@ -39,7 +39,11 @@ class ExtendedEditDistance(Metric): insertion: penalty for insertion or substitution of character compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -77,7 +81,7 @@ def __init__( rho: float = 0.3, deletion: float = 0.2, insertion: float = 1.0, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/mer.py b/torchmetrics/text/mer.py index 6d52a842692..96986d2432e 100644 --- a/torchmetrics/text/mer.py +++ b/torchmetrics/text/mer.py @@ -41,7 +41,11 @@ class MatchErrorRate(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -68,7 +72,7 @@ class MatchErrorRate(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/rouge.py b/torchmetrics/text/rouge.py index cf86729b2ed..f8628f602d3 100644 --- a/torchmetrics/text/rouge.py +++ b/torchmetrics/text/rouge.py @@ -44,6 +44,10 @@ class ROUGEScore(Metric): Keys that are allowed are ``rougeL``, ``rougeLsum``, and ``rouge1`` through ``rouge9``. compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -91,7 +95,7 @@ def __init__( use_stemmer: bool = False, accumulate: Literal["avg", "best"] = "best", rouge_keys: Union[str, Tuple[str, ...]] = ("rouge1", "rouge2", "rougeL", "rougeLsum"), # type: ignore - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/text/sacre_bleu.py b/torchmetrics/text/sacre_bleu.py index 196b173d9ff..5e28a689ecc 100644 --- a/torchmetrics/text/sacre_bleu.py +++ b/torchmetrics/text/sacre_bleu.py @@ -47,6 +47,10 @@ class SacreBLEUScore(BLEUScore): If ``True``, BLEU score over lowercased text is calculated. compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -87,7 +91,7 @@ def __init__( smooth: bool = False, tokenize: Literal["none", "13a", "zh", "intl", "char"] = "13a", lowercase: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/text/squad.py b/torchmetrics/text/squad.py index 8f0fa4deb69..22c4cf9a018 100644 --- a/torchmetrics/text/squad.py +++ b/torchmetrics/text/squad.py @@ -33,6 +33,10 @@ class SQuAD(Metric): Args: compute_on_step: Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -64,7 +68,7 @@ class SQuAD(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Optional[Callable] = None, diff --git a/torchmetrics/text/ter.py b/torchmetrics/text/ter.py index df471297018..6f75c28c91a 100644 --- a/torchmetrics/text/ter.py +++ b/torchmetrics/text/ter.py @@ -39,7 +39,11 @@ class TranslationEditRate(Metric): return_sentence_level_score: An indication whether a sentence-level TER to be returned. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -74,7 +78,7 @@ def __init__( lowercase: bool = True, asian_support: bool = False, return_sentence_level_score: bool = False, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/wer.py b/torchmetrics/text/wer.py index 630359f8114..ed6ced11f32 100644 --- a/torchmetrics/text/wer.py +++ b/torchmetrics/text/wer.py @@ -41,7 +41,11 @@ class WordErrorRate(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -68,7 +72,7 @@ class WordErrorRate(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/wil.py b/torchmetrics/text/wil.py index d3940d5db8e..e8ca6686c6a 100644 --- a/torchmetrics/text/wil.py +++ b/torchmetrics/text/wil.py @@ -41,7 +41,11 @@ class WordInfoLost(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -68,7 +72,7 @@ class WordInfoLost(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/text/wip.py b/torchmetrics/text/wip.py index 1a0351999ac..fd1f735c0a3 100644 --- a/torchmetrics/text/wip.py +++ b/torchmetrics/text/wip.py @@ -41,7 +41,11 @@ class WordInfoPreserved(Metric): Args: compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -68,7 +72,7 @@ class WordInfoPreserved(Metric): def __init__( self, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/wrappers/bootstrapping.py b/torchmetrics/wrappers/bootstrapping.py index a06ad03a08e..5172e72aa91 100644 --- a/torchmetrics/wrappers/bootstrapping.py +++ b/torchmetrics/wrappers/bootstrapping.py @@ -56,7 +56,7 @@ def __init__( quantile: Optional[Union[float, Tensor]] = None, raw: bool = False, sampling_strategy: str = "poisson", - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, @@ -88,7 +88,11 @@ class basically keeps multiple copies of the same base metric in memory and when when the number of samples is large. If ``'multinomial'`` is chosen, we will apply true bootstrapping at the batch level to approximate bootstrapping over the hole dataset. compute_on_step: - Forward only calls ``update()`` and return ``None`` if this is set to ``False``. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step diff --git a/torchmetrics/wrappers/minmax.py b/torchmetrics/wrappers/minmax.py index 8386516f7a3..69c90551c96 100644 --- a/torchmetrics/wrappers/minmax.py +++ b/torchmetrics/wrappers/minmax.py @@ -28,7 +28,11 @@ class MinMaxMetric(Metric): base_metric: The metric of which you want to keep track of its maximum and minimum values. compute_on_step: - Forward only calls ``update()`` and return None if this is set to False. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Synchronize metric state across processes at each ``forward()`` before returning the value at the step. @@ -66,7 +70,7 @@ class MinMaxMetric(Metric): def __init__( self, base_metric: Metric, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, diff --git a/torchmetrics/wrappers/multioutput.py b/torchmetrics/wrappers/multioutput.py index e8317b5a903..99a5a948862 100644 --- a/torchmetrics/wrappers/multioutput.py +++ b/torchmetrics/wrappers/multioutput.py @@ -56,7 +56,11 @@ class MultioutputWrapper(Metric): This is sometimes unnecessary but harmless for metrics such as `R2Score` but useful for certain classification metrics that can't handle additional 1-item dimensions. compute_on_step: - Whether to recompute the metric value on each update step. + Forward only calls ``update()`` and returns None if this is set to False. + + .. deprecated:: v0.8 + Argument has no use anymore and will be removed v0.9. + dist_sync_on_step: Required for distributed training support. process_group: @@ -97,7 +101,7 @@ def __init__( output_dim: int = -1, remove_nans: bool = True, squeeze_outputs: bool = True, - compute_on_step: bool = True, + compute_on_step: Optional[bool] = None, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None,