class_docstr: Model Gaussian distribution over a set of points.
class_docstr_tok: ["Model","Gaussian","distribution","over","a","set","of","points","."]
docstr: Fit a Gaussian model to dataset X.
  
  Covariance matrix is not calculated directly using:
  ``C = X.X^T``
  Instead, it is represented in terms of the Singular Value Decomposition of X:
  ``X = U.S.V^T``
  Hence,
  ``C = U.S^2.U^T``
  This simplifies the calculation of the log-likelihood without requiring full matrix inversion.
  
  Args:
      dataset (Tensor): Input dataset to fit the model.
docstr_tok: ["Fit","a","Gaussian","model","to","dataset","X.","Covariance","matrix","is","not","calculated","directly","using",":","``","C","=","X.X^T","``","Instead",",","it","is","represented","in","terms","of","the","Singular","Value","Decomposition","of","X",":","``","X","=","U.S.V^T","``","Hence",",","``","C","=","U.S^2.U^T","``","This","simplifies","the","calculation","of","the","log-likelihood","without","requiring","full","matrix","inversion",".","Args",":","dataset","(","Tensor",")",":","Input","dataset","to","fit","the","model","."]
code: def fit(self, dataset: Tensor) -> None:
      """Fit a Gaussian model to dataset X.
  
      Covariance matrix is not calculated directly using:
      ``C = X.X^T``
      Instead, it is represented in terms of the Singular Value Decomposition of X:
      ``X = U.S.V^T``
      Hence,
      ``C = U.S^2.U^T``
      This simplifies the calculation of the log-likelihood without requiring full matrix inversion.
  
      Args:
          dataset (Tensor): Input dataset to fit the model.
      """
  
      num_samples = dataset.shape[1]
      self.mean_vec = torch.mean(dataset, dim=1)
      data_centered = (
          dataset - self.mean_vec.reshape(-1, 1)
      ) / math.sqrt(num_samples)
      self.u_mat, self.sigma_mat, _ = torch.linalg.svd(
          data_centered, full_matrices=False
      )
  
file_path: anomalib/src/anomalib/models/dfm/torch_model.py
imports: from __future__ import annotations
  import math
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from anomalib.models.components import PCA, DynamicBufferModule, FeatureExtractor
label_desc: Use image node_id 2 for calling the SingleClassGaussian obj's underlying member method code with example usage: obj.fit(dataset) without return types