Spatial Correlation Coefficient (SCC)¶
Module Interface¶
- class torchmetrics.image.SpatialCorrelationCoefficient(high_pass_filter=None, window_size=8, **kwargs)[source]¶
Compute Spatial Correlation Coefficient (SCC).
As input to
forward
andupdate
the metric accepts the following inputpreds
(Tensor
): Predictions from model of shape(N,C,H,W)
or(N,H,W)
.target
(Tensor
): Ground truth values of shape(N,C,H,W)
or(N,H,W)
.
As output of forward and compute the metric returns the following output
scc
(Tensor
): Tensor with scc score
- Parameters:
Example
>>> from torch import randn >>> from torchmetrics.image import SpatialCorrelationCoefficient as SCC >>> preds = randn([32, 3, 64, 64]) >>> target = randn([32, 3, 64, 64]) >>> scc = SCC() >>> scc(preds, target) tensor(0.0023)
Functional Interface¶
- torchmetrics.functional.image.spatial_correlation_coefficient(preds, target, hp_filter=None, window_size=8, reduction='mean')[source]¶
Compute Spatial Correlation Coefficient (SCC).
- Parameters:
preds¶ (
Tensor
) – predicted images of shape(N,C,H,W)
or(N,H,W)
.target¶ (
Tensor
) – ground truth images of shape(N,C,H,W)
or(N,H,W)
.hp_filter¶ (
Optional
[Tensor
]) – High-pass filter tensor. default: tensor([[-1,-1,-1],[-1,8,-1],[-1,-1,-1]])reduction¶ (
Optional
[Literal
['mean'
,'none'
,None
]]) – Reduction method for output tensor. IfNone
or"none"
, returns a tensor with the per sample results. default:"mean"
.
- Return type:
- Returns:
Tensor with scc score
Example
>>> from torch import randn >>> from torchmetrics.functional.image import spatial_correlation_coefficient as scc >>> x = randn(5, 3, 16, 16) >>> scc(x, x) tensor(1.) >>> x = randn(5, 16, 16) >>> scc(x, x) tensor(1.) >>> x = randn(5, 3, 16, 16) >>> y = randn(5, 3, 16, 16) >>> scc(x, y, reduction="none") tensor([0.0223, 0.0256, 0.0616, 0.0159, 0.0170])