Stats¶
Statistical functions.
- class anomalib.models.components.stats.GaussianKDE(dataset: Optional[Tensor] = None)[source]¶
Bases:
DynamicBufferModule
Gaussian Kernel Density Estimation.
- Parameters:
dataset (Tensor | None, optional) – Dataset on which to fit the KDE model. Defaults to None.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- static cov(tensor: Tensor) Tensor [source]¶
Calculate the unbiased covariance matrix.
- Parameters:
tensor (Tensor) – Input tensor from which covariance matrix is computed.
- Returns:
Output covariance matrix.
- class anomalib.models.components.stats.MultiVariateGaussian(n_features, n_patches)[source]¶
Bases:
Module
Multi Variate Gaussian Distribution.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- fit(embedding: Tensor) list[torch.Tensor] [source]¶
Fit multi-variate gaussian distribution to the input embedding.
- Parameters:
embedding (Tensor) – Embedding vector extracted from CNN.
- Returns:
Mean and the covariance of the embedding.
- forward(embedding: Tensor) list[torch.Tensor] [source]¶
Calculate multivariate Gaussian distribution.
- Parameters:
embedding (Tensor) – CNN features whose dimensionality is reduced via either random sampling or PCA.
- Returns:
mean and inverse covariance of the multi-variate gaussian distribution that fits the features.