Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions ignite/metrics/gan/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,28 @@ class FID(_BaseInceptionMetric):
non-blocking. By default, CPU.

Examples:

.. code-block:: python

import torch
from ignite.metric.gan import FID
metric = FID()
metric.attach(default_evaluator, "fid")
y_true = torch.rand(10, 3, 299, 299)
y_pred = torch.rand(10, 3, 299, 299)
state = default_evaluator.run([[y_pred, y_true]])
print(state.metrics["fid"])

.. testcode::

metric = FID(num_features=1, feature_extractor=default_model)
metric.attach(default_evaluator, "fid")
y_true = torch.ones(10, 4)
y_pred = torch.ones(10, 4)
state = default_evaluator.run([[y_pred, y_true]])
print(state.metrics["fid"])

.. testoutput::

y_pred, y = torch.rand(10, 3, 299, 299), torch.rand(10, 3, 299, 299)
m = FID()
m.update((y_pred, y))
print(m.compute())
0.0

.. versionadded:: 0.4.6
"""
Expand Down
22 changes: 16 additions & 6 deletions ignite/metrics/gan/inception_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,26 @@ class InceptionScore(_BaseInceptionMetric):
The default Inception model requires the `torchvision` module to be installed.

Examples:

.. code-block:: python

from ignite.metric.gan import InceptionScore
import torch
metric = InceptionScore()
metric.attach(default_evaluator, "is")
y = torch.rand(10, 3, 299, 299)
state = default_evaluator.run([y])
print(state.metrics["is"])

.. testcode::

metric = InceptionScore(num_features=1, feature_extractor=default_model)
metric.attach(default_evaluator, "is")
y = torch.zeros(10, 4)
state = default_evaluator.run([y])
print(state.metrics["is"])

images = torch.rand(10, 3, 299, 299)
.. testoutput::

m = InceptionScore()
m.update(images)
print(m.compute())
1.0

.. versionadded:: 0.4.6
"""
Expand Down