anomalib.models.components.stats.multi_variate_gaussian¶
Multi Variate Gaussian Distribution.
Module Contents¶
Classes¶
Multi Variate Gaussian Distribution. |
- class anomalib.models.components.stats.multi_variate_gaussian.MultiVariateGaussian(n_features, n_patches)[source]¶
Bases:
torch.nn.ModuleMulti Variate Gaussian Distribution.
- static _cov(observations: torch.Tensor, rowvar: bool = False, bias: bool = False, ddof: Optional[int] = None, aweights: torch.Tensor = None) torch.Tensor[source]¶
Estimates covariance matrix like numpy.cov.
- Parameters
observations (Tensor) – A 1-D or 2-D array containing multiple variables and observations. Each row of m represents a variable, and each column a single observation of all those variables. Also see rowvar below.
rowvar (bool) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations. Defaults to False.
bias (bool) – Default normalization (False) is by
(N - 1), whereNis the number of observations given (unbiased estimate). If bias is True, then normalization is byN. These values can be overridden by using the keywordddofin numpy versions >= 1.5. Defaults to Falseddof (Optional, int) – If not
Nonethe default value implied by bias is overridden. Note thatddof=1will return the unbiased estimate, even if both fweights and aweights are specified, andddof=0will return the simple average. See the notes for the details. The default value isNone.aweights (Tensor) – 1-D array of observation vector weights. These relative weights are typically large for observations considered “important” and smaller for observations considered less “important”. If
ddof=0the array of weights can be used to assign probabilities to observation vectors. (Default value = None)
- Returns
The covariance matrix of the variables.
- forward(embedding: torch.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.