Compute the VisualInformationFidelity metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute VisualInformationFidelity, or asks how to score with VisualInformationFidelity.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add qhjqhj00/research-skills-pool --skill visualinformationfidelity --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Visualinformationfidelity?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/qhjqhj00-visualinformationfidelity)More formats (shields.io, HTML) on the badges page.
---
name: visualinformationfidelity
description: Compute the VisualInformationFidelity metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute VisualInformationFidelity, or asks how to score with VisualInformationFidelity.
metadata:
skill_kind: metric
source_lib: torchmetrics
import_path: torchmetrics.image.VisualInformationFidelity
source: library_introspection
---
# visualinformationfidelity
> Metric `VisualInformationFidelity` from `torchmetrics` (torchmetrics.image.VisualInformationFidelity)
## When to invoke this skill
The user has predictions + ground truth and asks to evaluate with VisualInformationFidelity, or
mentions `torchmetrics.image.VisualInformationFidelity` directly, or wants the standard torchmetrics implementation.
## Reference signature
```python
from torchmetrics.image import VisualInformationFidelity
# VisualInformationFidelity(sigma_n_sq: float = 2.0, reduction: Literal['mean', 'none'] = 'mean', **kwargs: Any) -> None
```
## Library docstring
```
Compute Pixel Based Visual Information Fidelity (VIF_).
As input to ``forward`` and ``update`` the metric accepts the following input
- ``preds`` (:class:`~torch.Tensor`): Predictions from model of shape ``(N,C,H,W)`` with H,W ≥ 41
- ``target`` (:class:`~torch.Tensor`): Ground truth values of shape ``(N,C,H,W)`` with H,W ≥ 41
As output of `forward` and `compute` the metric returns the following output
- ``vif-p`` (:class:`~torch.Tensor`):
- If ``reduction='mean'`` (default), returns a Tensor mean VIF score.
- If ``reduction='none'``, returns a tensor of shape ``(N,)`` with VIF values per sample.
Args:
sigma_n_sq: variance of the visual noise
reduction: The reduction method for aggregating scores.
- ``'mean'``: return the average VIF across the batch.
- ``'none'``: return a VIF score for each sample in the batch.
kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
Example:
>>> from torch import randn
>>> from torchmetrics.image import VisualInformationFidelity
>>> preds = randn([32, 3, 41, 41], generator=torch.Generator().manual_seed(42))
>>> target = randn([32, 3, 41, 41], generator=torch.Generator().manual_seed(43))
>>> vif_mean = VisualInformationFidelity(reduction='mean')
>>> vif_mean(preds, target)
tensor(0.0032)
>>> vif_none = VisualInformationFidelity(reduction='none')
>>> vif_none(preds, target)
tensor([0.0040, 0.0049, 0.0017, 0.0039, 0.0041, 0.0043, 0.0030, 0.0028, 0.0012,
0.0067, 0.0010, 0.0014, 0.0030, 0.0048, 0.0050, 0.0038, 0.0037, 0.0025,
0.0041, 0.0019, 0.0007, 0.0034, 0.0037, 0.0016, 0.0026, 0.0021, 0.0038,
0.0033, 0.0031, 0.0020, 0.0036, 0.0057])
```
## Quick recipe
```python
import torchmetrics.image as _m
score = _m.VisualInformationFidelity(y_true, y_pred)
```
## Don'ts
- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!