Compute the QualityWithNoReference metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute QualityWithNoReference, or asks how to score with QualityWithNoReference.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add qhjqhj00/research-skills-pool --skill qualitywithnoreference --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Qualitywithnoreference?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/qhjqhj00-qualitywithnoreference)More formats (shields.io, HTML) on the badges page.
---
name: qualitywithnoreference
description: Compute the QualityWithNoReference metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute QualityWithNoReference, or asks how to score with QualityWithNoReference.
metadata:
skill_kind: metric
source_lib: torchmetrics
import_path: torchmetrics.image.QualityWithNoReference
source: library_introspection
---
# qualitywithnoreference
> Metric `QualityWithNoReference` from `torchmetrics` (torchmetrics.image.QualityWithNoReference)
## When to invoke this skill
The user has predictions + ground truth and asks to evaluate with QualityWithNoReference, or
mentions `torchmetrics.image.QualityWithNoReference` directly, or wants the standard torchmetrics implementation.
## Reference signature
```python
from torchmetrics.image import QualityWithNoReference
# QualityWithNoReference(alpha: float = 1, beta: float = 1, norm_order: int = 1, window_size: int = 7, reduction: Literal['elementwise_mean', 'sum', 'none'] = 'elementwise_mean', **kwargs: Any) -> None
```
## Library docstring
```
Compute Quality with No Reference (QualityWithNoReference_) also now as QNR.
The metric is used to compare the joint spectral and spatial distortion between two images.
As input to ``forward`` and ``update`` the metric accepts the following input
- ``preds`` (:class:`~torch.Tensor`): High resolution multispectral image of shape ``(N,C,H,W)``.
- ``target`` (:class:`~Dict`): A dictionary containing the following keys:
- ``ms`` (:class:`~torch.Tensor`): Low resolution multispectral image of shape ``(N,C,H',W')``.
- ``pan`` (:class:`~torch.Tensor`): High resolution panchromatic image of shape ``(N,C,H,W)``.
- ``pan_lr`` (:class:`~torch.Tensor`): (optional) Low resolution panchromatic image of shape ``(N,C,H',W')``.
where H and W must be multiple of H' and W'.
When ``pan_lr`` is ``None``, a uniform filter will be applied on ``pan`` to produce a degraded image. The degraded
image is then resized to match the size of ``ms`` and served as ``pan_lr`` in the calculation.
As output of `forward` and `compute` the metric returns the following output
- ``qnr`` (:class:`~torch.Tensor`): if ``reduction!='none'`` returns float scalar tensor with average QNR value
over sample else returns tensor of shape ``(N,)`` with QNR values per sample
Args:
alpha: Relevance of spectral distortion.
beta: Relevance of spatial distortion.
norm_order: Order of the norm applied on the difference.
window_size: Window size of the filter applied to degrade the high resolution panchromatic image.
reduction: a method to reduce metric score over labels.
- ``'elementwise_mean'``: takes the mean (default)
- ``'sum'``: takes the sum
- ``'none'``: no reduction will be applied
kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
Example:
>>> from torch import rand
>>> from torchmetrics.image import QualityWithNoReference
>>> preds = rand([16, 3, 32, 32])
>>> target = {
... 'ms': rand([16, 3, 16, 16]),
... 'pan': rand([16, 3, 32, 32]),
... }
>>> qnr = QualityWithNoReference()
>>> qnr(preds, target)
tensor(0.9694)
```
## Quick recipe
```python
import torchmetrics.image as _m
score = _m.QualityWithNoReference(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!