# Structuralsimilarityindexmeasure

> Compute the StructuralSimilarityIndexMeasure metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute StructuralSimilarityIndexMeasure, or asks how to score with StructuralSimilarityIndexMeasure.

- Skill: `qhjqhj00/structuralsimilarityindexmeasure` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/structuralsimilarityindexmeasure`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/structuralsimilarityindexmeasure/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/structuralsimilarityindexmeasure

---


# structuralsimilarityindexmeasure

> Metric `StructuralSimilarityIndexMeasure` from `torchmetrics` (torchmetrics.StructuralSimilarityIndexMeasure)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with StructuralSimilarityIndexMeasure, or
mentions `torchmetrics.StructuralSimilarityIndexMeasure` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics import StructuralSimilarityIndexMeasure

# _StructuralSimilarityIndexMeasure(gaussian_kernel: bool = True, sigma: Union[float, collections.abc.Sequence[float]] = 1.5, kernel_size: Union[int, collections.abc.Sequence[int]] = 11, reduction: Literal['elementwise_mean', 'sum', 'none', None] = 'elementwise_mean', data_range: Union[float, tuple[float, float], NoneType] = None, k1: float = 0.01, k2: float = 0.03, return_full_image: bool = False, return_contrast_sensitivity: bool = False, **kwargs: Any) -> None
```

## Library docstring

```
Wrapper for deprecated import.

>>> import torch
>>> preds = torch.rand([3, 3, 256, 256])
>>> target = preds * 0.75
>>> ssim = _StructuralSimilarityIndexMeasure(data_range=1.0)
>>> ssim(preds, target)
tensor(0.9219)
```

## Quick recipe

```python
import torchmetrics as _m
score = _m.StructuralSimilarityIndexMeasure(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)`.

