Skip to content

Commit

Permalink
Fix docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
sadra-barikbin committed Jul 31, 2024
1 parent bd8e88b commit 8471c4c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ignite/metrics/metric_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ class MetricGroup(Metric):
We construct a group of metrics, attach them to the engine at once and retrieve their result.
.. code-block:: python
metric_group = MetricGroup({'acc': Accuracy(), 'precision': Precision(), 'loss': Loss(nn.NLLLoss())})
metric_group.attach(default_evaluator, "eval_metrics")
y_true = torch.tensor([1, 0, 1, 1, 0, 1])
y_pred = torch.tensor([1, 0, 1, 0, 1, 1])
state = default_evaluator.run([[y_pred, y_true]])
import torch
# Metrics individually available in `state.metrics`
state.metrics["acc"], state.metrics["precision"], state.metrics["loss"]
metric_group = MetricGroup({'acc': Accuracy(), 'precision': Precision(), 'loss': Loss(nn.NLLLoss())})
metric_group.attach(default_evaluator, "eval_metrics")
y_true = torch.tensor([1, 0, 1, 1, 0, 1])
y_pred = torch.tensor([1, 0, 1, 0, 1, 1])
state = default_evaluator.run([[y_pred, y_true]])
# And also altogether
state.metrics["eval_metrics]
# Metrics individually available in `state.metrics`
state.metrics["acc"], state.metrics["precision"], state.metrics["loss"]
# And also altogether
state.metrics["eval_metrics]
"""

_state_dict_all_req_keys = ("metrics",)
Expand Down

0 comments on commit 8471c4c

Please sign in to comment.