Skip to content

Commit b061b78

Browse files
authored
Docs/update 20 12 (#1018)
* + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * +
1 parent ccef2c7 commit b061b78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+715
-319
lines changed

CHANGELOG.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
99

1010
### Added
1111

12+
- CVS Logger ([#1005](https://github.com/catalyst-team/catalyst/pull/1005))
1213
- ([#1002](https://github.com/catalyst-team/catalyst/pull/1002))
13-
- a few docs
14+
- a few docs
15+
- ([#998](https://github.com/catalyst-team/catalyst/pull/998))
16+
- ``reciprocal_rank`` metric
17+
- unified recsys metrics preprocessing
18+
- ([#1018](https://github.com/catalyst-team/catalyst/pull/1014))
19+
- readme examples for all supported metrics under ``catalyst.metrics``
20+
- ``wrap_metric_fn_with_activation`` for model outputs wrapping with activation
21+
- extra tests for metrics
1422

1523
### Changed
1624

17-
25+
- docs update ([#1000](https://github.com/catalyst-team/catalyst/pull/1000))
26+
- ``AMPOptimizerCallback`` and ``OptimizerCallback`` were merged ([#1007](https://github.com/catalyst-team/catalyst/pull/1007))
1827
- ([#1017](https://github.com/catalyst-team/catalyst/pull/1017))
1928
- fixed bug in `SchedulerCallback`
2029
- Log LRs and momentums for all param groups, not only for the first one
21-
2230
- ([#1002](https://github.com/catalyst-team/catalyst/pull/1002))
2331
- ``tensorboard, ipython, matplotlib, pandas, scikit-learn`` moved to optional requirements
2432
- ``PerplexityMetricCallback`` moved to ``catalyst.callbacks`` from ``catalyst.contrib.callbacks``
@@ -29,6 +37,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2937
- ``catalyst.utils``, ``catalyst.data.utils`` and ``catalyst.contrib.utils`` restructured
3038
- ``ReaderSpec`` renamed to ``IReader``
3139
- ``SupervisedExperiment`` renamed to ``AutoCallbackExperiment``
40+
- gain functions renamed for ``dcg``/``ndcg`` metrics ([#998](https://github.com/catalyst-team/catalyst/pull/998))
41+
- ([#1014](https://github.com/catalyst-team/catalyst/pull/1014))
42+
- requirements respecification: ``catalyst[cv]``, ``catalyst[dev]``, ``catalyst[log]``, ``catalyst[ml]``, ``catalyst[nlp]``,``catalyst[tune]``
43+
- settings respecification
44+
- extra tests for settings
45+
- contrib refactoring
3246

3347
### Removed
3448

@@ -38,11 +52,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3852
- ``catalyst.data.utils``
3953
- unnecessary ``catalyst.tools.meters``
4054
- todos for unnecessary docs
55+
- ([#1014](https://github.com/catalyst-team/catalyst/pull/1014))
56+
- transformers-based contrib (too unstable)
57+
- ([#1018](https://github.com/catalyst-team/catalyst/pull/1014))
58+
- ClasswiseIouCallback/ClasswiseJaccardCallback as deprecated on (should be refactored in future releases)
59+
4160

4261

4362
### Fixed
4463

4564
- prevented modifying config during the experiment and runner initialization ([#1004](https://github.com/catalyst-team/catalyst/pull/1004))
65+
- a few test for RecSys MAP computation ([#1018](https://github.com/catalyst-team/catalyst/pull/1014))
4666

4767

4868

@@ -63,6 +83,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6383

6484
- update Catalyst version to `20.10.1` for tutorials ([#967](https://github.com/catalyst-team/catalyst/pull/967))
6585
- added link to dl-course ([#967](https://github.com/catalyst-team/catalyst/pull/967))
86+
- ``IRunner`` -> simplified ``IRunner`` ([#984](https://github.com/catalyst-team/catalyst/pull/984))
6687
- docs were restructured ([#985](https://github.com/catalyst-team/catalyst/pull/985))
6788
- `set_global_seed` moved from `utils.seed` to `utils.misc` ([#986](https://github.com/catalyst-team/catalyst/pull/986))
6889

@@ -177,7 +198,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
177198
- kornia augmentations `BatchTransformCallback` ([#862](https://github.com/catalyst-team/catalyst/issues/862))
178199
- `average_precision` and `mean_average_precision` metrics ([#883](https://github.com/catalyst-team/catalyst/pull/883))
179200
- `MultiLabelAccuracyCallback`, `AveragePrecisionCallback` and `MeanAveragePrecisionCallback` callbacks ([#883](https://github.com/catalyst-team/catalyst/pull/883))
180-
- minimal examples for multi-class and milti-label classification ([#883](https://github.com/catalyst-team/catalyst/pull/883))
201+
- minimal examples for multiclass and multilabel classification ([#883](https://github.com/catalyst-team/catalyst/pull/883))
181202
- experimental TPU support ([#893](https://github.com/catalyst-team/catalyst/pull/893))
182203
- add `Imagenette`, `Imagewoof`, and `Imagewang` datasets ([#902](https://github.com/catalyst-team/catalyst/pull/902))
183204
- `IMetricCallback`, `IBatchMetricCallback`, `ILoaderMetricCallback`, `BatchMetricCallback`, `LoaderMetricCallback` abstractions ([#897](https://github.com/catalyst-team/catalyst/pull/897))

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2018-2020 Sergey Kolesnikov
1+
Copyright 2018- Sergey Kolesnikov
22

33
Apache License
44
Version 2.0, January 2004

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ runner.train(
216216

217217

218218
<details>
219-
<summary>ML - multi-class classification</summary>
219+
<summary>ML - multiclass classification</summary>
220220
<p>
221221

222222
```python
@@ -258,7 +258,7 @@ runner.train(
258258

259259

260260
<details>
261-
<summary>ML - multi-label classification</summary>
261+
<summary>ML - multilabel classification</summary>
262262
<p>
263263

264264
```python
@@ -759,7 +759,7 @@ runner.train(
759759
</details>
760760

761761
<details>
762-
<summary>ML - multi-class classification (fp16 training version)</summary>
762+
<summary>ML - multiclass classification (fp16 training version)</summary>
763763
<p>
764764

765765
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1q8BPg1XpQn2J5vWV9OYKSBo-k9wA2jYS?usp=sharing)
@@ -804,7 +804,7 @@ runner.train(
804804
</details>
805805

806806
<details>
807-
<summary>ML - multi-class classification (advanced fp16 training version)</summary>
807+
<summary>ML - multiclass classification (advanced fp16 training version)</summary>
808808
<p>
809809

810810
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1q8BPg1XpQn2J5vWV9OYKSBo-k9wA2jYS?usp=sharing)
@@ -976,7 +976,7 @@ utils.distributed_cmd_run(train)
976976
</details>
977977

978978
<details>
979-
<summary>ML - multi-class classification (TPU version)</summary>
979+
<summary>ML - multiclass classification (TPU version)</summary>
980980
<p>
981981

982982
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1AhvNzTRb3gd3AYhzUfm3dzw8TddlsfhD?usp=sharing)

catalyst/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "20.11.1"
1+
__version__ = "20.12"

catalyst/callbacks/meter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
If None, defaults to indices for each class, starting from 0.
4545
num_classes: Number of classes; must be > 1
4646
activation: An torch.nn activation applied to the logits.
47-
Must be one of ['none', 'Sigmoid', 'Softmax2d']
47+
Must be one of ['none', 'Sigmoid', 'Softmax']
4848
"""
4949
super().__init__(CallbackOrder.metric)
5050
self.metric_names = metric_names

catalyst/callbacks/metric.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ def __init__(
243243
**metrics_kwargs: extra metric params
244244
to pass for metric computation
245245
"""
246+
# @TODO:
247+
# - add ~(transform: Callable = lambda x: x) for runner
248+
# - add ~(transform: Callable = lambda x: x) for metrics output
246249
super().__init__(
247250
prefix=prefix,
248251
input_key=input_key,

catalyst/callbacks/metrics/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
)
77
from catalyst.callbacks.metrics.auc import AUCCallback
88
from catalyst.callbacks.metrics.cmc_score import CMCScoreCallback
9+
910
from catalyst.callbacks.metrics.dice import (
1011
DiceCallback,
1112
MultiClassDiceMetricCallback,
1213
MulticlassDiceMetricCallback,
1314
)
15+
1416
from catalyst.callbacks.metrics.f1_score import F1ScoreCallback
1517
from catalyst.callbacks.metrics.iou import (
1618
IouCallback,
1719
JaccardCallback,
18-
ClasswiseIouCallback,
19-
ClasswiseJaccardCallback,
2020
)
2121
from catalyst.callbacks.metrics.mrr import MRRCallback
2222
from catalyst.callbacks.metrics.perplexity import (
23-
PerplexityCallback,
2423
PerplexityMetricCallback,
24+
PerplexityCallback,
2525
)
2626
from catalyst.callbacks.metrics.ppv_tpr_f1 import (
2727
PrecisionRecallF1ScoreCallback,

catalyst/callbacks/metrics/accuracy.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
from typing import List
22

33
from catalyst.callbacks.metric import BatchMetricCallback
4-
from catalyst.metrics.accuracy import accuracy, multi_label_accuracy
4+
from catalyst.metrics.accuracy import accuracy, multilabel_accuracy
55
from catalyst.metrics.functional import (
66
get_default_topk_args,
7+
wrap_metric_fn_with_activation,
78
wrap_topk_metric2dict,
89
)
910

1011

1112
class AccuracyCallback(BatchMetricCallback):
1213
"""Accuracy metric callback.
1314
14-
Computes multi-class accuracy@topk for the specified values of `topk`.
15+
Computes multiclass accuracy@topk for the specified values of `topk`.
1516
1617
.. note::
17-
For multi-label accuracy please use
18+
For multilabel accuracy please use
1819
`catalyst.callbacks.metrics.MultiLabelAccuracyCallback`
1920
"""
2021

@@ -23,7 +24,6 @@ def __init__(
2324
input_key: str = "targets",
2425
output_key: str = "logits",
2526
prefix: str = "accuracy",
26-
multiplier: float = 1.0,
2727
topk_args: List[int] = None,
2828
num_classes: int = None,
2929
accuracy_args: List[int] = None,
@@ -42,8 +42,6 @@ def __init__(
4242
[1, 3, 5] - accuracy at 1, 3 and 5
4343
num_classes: number of classes to calculate ``topk_args``
4444
if ``accuracy_args`` is None
45-
activation: An torch.nn activation applied to the outputs.
46-
Must be one of ``"none"``, ``"Sigmoid"``, or ``"Softmax"``
4745
"""
4846
topk_args = (
4947
topk_args or accuracy_args or get_default_topk_args(num_classes)
@@ -54,27 +52,26 @@ def __init__(
5452
metric_fn=wrap_topk_metric2dict(accuracy, topk_args=topk_args),
5553
input_key=input_key,
5654
output_key=output_key,
57-
multiplier=multiplier,
5855
**kwargs,
5956
)
6057

6158

6259
class MultiLabelAccuracyCallback(BatchMetricCallback):
6360
"""Accuracy metric callback.
64-
Computes multi-class accuracy@topk for the specified values of `topk`.
61+
Computes multiclass accuracy@topk for the specified values of `topk`.
6562
6663
.. note::
67-
For multi-label accuracy please use
64+
For multilabel accuracy please use
6865
`catalyst.callbacks.metrics.MultiLabelAccuracyCallback`
6966
"""
7067

7168
def __init__(
7269
self,
7370
input_key: str = "targets",
7471
output_key: str = "logits",
75-
prefix: str = "multi_label_accuracy",
76-
threshold: float = None,
72+
prefix: str = "multilabel_accuracy",
7773
activation: str = "Sigmoid",
74+
threshold: float = None,
7875
):
7976
"""
8077
Args:
@@ -89,11 +86,12 @@ def __init__(
8986
"""
9087
super().__init__(
9188
prefix=prefix,
92-
metric_fn=multi_label_accuracy,
89+
metric_fn=wrap_metric_fn_with_activation(
90+
metric_fn=multilabel_accuracy, activation=activation
91+
),
9392
input_key=input_key,
9493
output_key=output_key,
9594
threshold=threshold,
96-
activation=activation,
9795
)
9896

9997

catalyst/callbacks/metrics/auc.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22

33
from catalyst.callbacks.metric import LoaderMetricCallback
44
from catalyst.metrics.auc import auc
5-
from catalyst.metrics.functional import wrap_class_metric2dict
5+
from catalyst.metrics.functional import (
6+
wrap_class_metric2dict,
7+
wrap_metric_fn_with_activation,
8+
)
69

710

811
class AUCCallback(LoaderMetricCallback):
912
"""Calculates the AUC per class for each loader.
1013
1114
.. note::
12-
Currently, supports binary and multi-label cases.
15+
Currently, supports binary and multilabel cases.
1316
"""
1417

1518
def __init__(
1619
self,
1720
input_key: str = "targets",
1821
output_key: str = "logits",
1922
prefix: str = "auc",
20-
multiplier: float = 1.0,
23+
activation: str = "Sigmoid",
2124
class_args: List[str] = None,
2225
**kwargs,
2326
):
@@ -27,17 +30,22 @@ def __init__(
2730
specifies our ``y_true``.
2831
output_key: output key to use for auc calculation;
2932
specifies our ``y_pred``.
30-
prefix: metric's name.
33+
prefix: key for the metric's name
3134
multiplier: scale factor for the metric.
35+
activation: An torch.nn activation applied to the outputs.
36+
Must be one of ``'none'``, ``'Sigmoid'``, or ``'Softmax'``
3237
class_args: class names to display in the logs.
3338
If None, defaults to indices for each class, starting from 0
3439
"""
40+
metric_fn = wrap_metric_fn_with_activation(
41+
metric_fn=auc, activation=activation
42+
)
43+
metric_fn = wrap_class_metric2dict(metric_fn, class_args=class_args)
3544
super().__init__(
3645
prefix=prefix,
37-
metric_fn=wrap_class_metric2dict(auc, class_args=class_args),
46+
metric_fn=metric_fn,
3847
input_key=input_key,
3948
output_key=output_key,
40-
multiplier=multiplier,
4149
**kwargs,
4250
)
4351

catalyst/callbacks/metrics/dice.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
from catalyst.core.callback import Callback, CallbackOrder
1111
from catalyst.metrics.dice import calculate_dice, dice
12+
from catalyst.metrics.functional import wrap_metric_fn_with_activation
1213

1314
if TYPE_CHECKING:
1415
from catalyst.core.runner import IRunner
@@ -26,17 +27,16 @@ class DiceCallback(BatchMetricCallback):
2627
eps: epsilon to avoid zero division
2728
threshold: threshold for outputs binarization
2829
activation: An torch.nn activation applied to the outputs.
29-
Must be one of ``'none'``, ``'Sigmoid'``, ``'Softmax2d'``
30+
Must be one of ``'none'``, ``'Sigmoid'``, ``'Softmax'``
3031
"""
3132

3233
def __init__(
3334
self,
3435
input_key: str = "targets",
3536
output_key: str = "logits",
3637
prefix: str = "dice",
37-
eps: float = 1e-7,
38-
threshold: float = None,
3938
activation: str = "Sigmoid",
39+
**kwargs,
4040
):
4141
"""
4242
Args:
@@ -45,25 +45,25 @@ def __init__(
4545
output_key: output key to use for iou calculation;
4646
specifies our ``y_pred``
4747
prefix: key to store in logs
48+
activation: An torch.nn activation applied to the model outputs.
49+
Must be one of ``'none'``, ``'Sigmoid'``, ``'Softmax'``
4850
eps: epsilon to avoid zero division
4951
threshold: threshold for outputs binarization
50-
activation: An torch.nn activation applied to the outputs.
51-
Must be one of ``'none'``, ``'Sigmoid'``, ``'Softmax2d'``
5252
"""
5353
super().__init__(
5454
prefix=prefix,
55-
metric_fn=dice,
55+
metric_fn=wrap_metric_fn_with_activation(
56+
metric_fn=dice, activation=activation
57+
),
5658
input_key=input_key,
5759
output_key=output_key,
58-
eps=eps,
59-
threshold=threshold,
60-
activation=activation,
60+
**kwargs,
6161
)
6262

6363

6464
class MultiClassDiceMetricCallback(Callback):
6565
"""
66-
Global Multi-Class Dice Metric Callback: calculates the exact
66+
Global multiclass Dice Metric Callback: calculates the exact
6767
dice score across multiple batches. This callback is good for getting
6868
the dice score with small batch sizes where the batchwise dice is noisier.
6969
"""

0 commit comments

Comments
 (0)