tensorflow#

TensorFlow models are used in out of distribution detectors in the dataeval.detectors.ood module.

DataEval provides basic default models through the utility dataeval.utils.tensorflow.create_model().

Functions#

dataeval.utils.tensorflow.create_model(model_type: Literal['AE', 'AEGMM', 'PixelCNN', 'VAE', 'VAEGMM'], input_shape: tuple[int, int, int], encoding_dim: int | None = None, n_gmm: int | None = None, gmm_latent_dim: int | None = None) Any#

Create a default model for the specified model type.

Parameters:
  • model_type (Literal["AE", "AEGMM", "PixelCNN", "VAE", "VAEGMM"]) – The model type to create.

  • input_shape (Tuple[int, int, int]) – The input shape of the data used.

  • encoding_dim (int, optional - default None) – The target encoding dimensionality.

  • n_gmm (int, optional - default None) – Number of components used in the GMM layer.

  • gmm_latent_dim (int, optional - default None) – Latent dimensionality of the GMM layer.

Loss Function Classes#

class dataeval.utils.tensorflow.loss.Elbo(cov_type: Literal['cov_full', 'cov_diag'] | float = 1.0, x: Tensor | ndarray[Any, dtype[float32]] | None = None)#

Compute ELBO loss.

The covariance matrix can be specified by passing the full covariance matrix, the matrix diagonal, or a scale identity multiplier. Only one of these should be specified. If none are specified, the identity matrix is used.

Parameters:
  • cov_type (Union[Literal["cov_full", "cov_diag"], float], default 1.0) – Full covariance matrix, diagonal variance matrix, or scale identity multiplier.

  • x (ArrayLike, optional - default None) – Dataset used to calculate the covariance matrix. Required for full and diagonal covariance matrix types.

class dataeval.utils.tensorflow.loss.LossGMM(w_recon: float = 1e-07, w_energy: float = 0.1, w_cov_diag: float = 0.005, elbo: Elbo | None = None)#

Loss function used for AE and VAE with GMM.

Parameters:
  • w_recon (float, default 1e-7) – Weight on elbo loss term.

  • w_energy (float, default 0.1) – Weight on sample energy loss term.

  • w_cov_diag (float, default 0.005) – Weight on covariance regularizing loss term.

  • elbo (Elbo, optional - default None) – ELBO loss function used to calculate w_recon.