class_docstr: Variational auto encoder
  Encoder maps X onto a latent space Z
  Decoder samples Z from N(0,1)
  VAE_loss = Reconstruction_loss + KL_loss
  
  Reference
  See :cite:`kingma2013auto` Kingma, Diederik, Welling
  'Auto-Encodeing Variational Bayes'
  https://arxiv.org/abs/1312.6114 for details.
  
  beta VAE
  In Loss, the emphasis is on KL_loss
  and capacity of a bottleneck:
  VAE_loss = Reconstruction_loss + gamma*KL_loss
  
  Reference
  See :cite:`burgess2018understanding` Burges et al
  'Understanding disentangling in beta-VAE'
  https://arxiv.org/pdf/1804.03599.pdf for details.
  
  
  Parameters
  ----------
  encoder_neurons : list, optional (default=[128, 64, 32])
      The number of neurons per hidden layer in encoder.
  
  decoder_neurons : list, optional (default=[32, 64, 128])
      The number of neurons per hidden layer in decoder.
  
  hidden_activation : str, optional (default='relu')
      Activation function to use for hidden layers.
      All hidden layers are forced to use the same type of activation.
      See https://keras.io/activations/
  
  output_activation : str, optional (default='sigmoid')
      Activation function to use for output layer.
      See https://keras.io/activations/
  
  loss : str or obj, optional (default=keras.losses.mean_squared_error
      String (name of objective function) or objective function.
      See https://keras.io/losses/
  
  gamma : float, optional (default=1.0)
      Coefficient of beta VAE regime.
      Default is regular VAE.
  
  capacity : float, optional (default=0.0)
      Maximum capacity of a loss bottle neck.
  
  optimizer : str, optional (default='adam')
      String (name of optimizer) or optimizer instance.
      See https://keras.io/optimizers/
  
  epochs : int, optional (default=100)
      Number of epochs to train the model.
  
  batch_size : int, optional (default=32)
      Number of samples per gradient update.
  
  dropout_rate : float in (0., 1), optional (default=0.2)
      The dropout to be used across all layers.
  
  l2_regularizer : float in (0., 1), optional (default=0.1)
      The regularization strength of activity_regularizer
      applied on each layer. By default, l2 regularizer is used. See
      https://keras.io/regularizers/
  
  validation_size : float in (0., 1), optional (default=0.1)
      The percentage of data to be used for validation.
  
  preprocessing : bool, optional (default=True)
      If True, apply standardization on the data.
  
  verbose : int, optional (default=1)
      verbose mode.
  
      - 0 = silent
      - 1 = progress bar
      - 2 = one line per epoch.
  
      For verbose >= 1, model summary may be printed.
  
  random_state : random_state: int, RandomState instance or None, opti
      (default=None)
      If int, random_state is the seed used by the random
      number generator; If RandomState instance, random_state is the r
      number generator; If None, the random number generator is the
      RandomState instance used by `np.random`.
  
  contamination : float in (0., 0.5), optional (default=0.1)
      The amount of contamination of the data set, i.e.
      the proportion of outliers in the data set. When fitting this is
      to define the threshold on the decision function.
  
  Attributes
  ----------
  encoding_dim_ : int
      The number of neurons in the encoding layer.
  
  compression_rate_ : float
      The ratio between the original feature and
      the number of neurons in the encoding layer.
  
  model_ : Keras Object
      The underlying AutoEncoder in Keras.
  
  history_: Keras Object
      The AutoEncoder training history.
  
  decision_scores_ : numpy array of shape (n_samples,)
      The outlier scores of the training data.
      The higher, the more abnormal. Outliers tend to have higher
      scores. This value is available once the detector is
      fitted.
  
  threshold_ : float
      The threshold is based on ``contamination``. It is the
      ``n_samples * contamination`` most abnormal samples in
      ``decision_scores_``. The threshold is calculated for generating
      binary outlier labels.
  
  labels_ : int, either 0 or 1
      The binary labels of the training data. 0 stands for inliers
      and 1 for outliers/anomalies. It is generated by applying
      ``threshold_`` on ``decision_scores_``.
class_docstr_tok: ["Variational","auto","encoder","Encoder","maps","X","onto","a","latent","space","Z","Decoder","samples","Z","from","N","(","0,1",")","VAE_loss","=","Reconstruction_loss","+","KL_loss","Reference","See",":","cite",":","`","kingma2013auto","`","Kingma",",","Diederik",",","Welling","'Auto-Encodeing","Variational","Bayes'","https",":","\/\/arxiv.org\/abs\/1312.6114","for","details",".","beta","VAE","In","Loss",",","the","emphasis","is","on","KL_loss","and","capacity","of","a","bottleneck",":","VAE_loss","=","Reconstruction_loss","+","gamma","*","KL_loss","Reference","See",":","cite",":","`","burgess2018understanding","`","Burges","et","al","'Understanding","disentangling","in","beta-VAE'","https",":","\/\/arxiv.org\/pdf\/1804.03599.pdf","for","details",".","Parameters","--","--","--","--","--","encoder_neurons",":","list",",","optional","(","default=","[","128",",","64",",","32","]",")","The","number","of","neurons","per","hidden","layer","in","encoder",".","decoder_neurons",":","list",",","optional","(","default=","[","32",",","64",",","128","]",")","The","number","of","neurons","per","hidden","layer","in","decoder",".","hidden_activation",":","str",",","optional","(","default='relu","'",")","Activation","function","to","use","for","hidden","layers",".","All","hidden","layers","are","forced","to","use","the","same","type","of","activation",".","See","https",":","\/\/keras.io\/activations\/","output_activation",":","str",",","optional","(","default='sigmoid","'",")","Activation","function","to","use","for","output","layer",".","See","https",":","\/\/keras.io\/activations\/","loss",":","str","or","obj",",","optional","(","default=keras.losses.mean_squared_error","String","(","name","of","objective","function",")","or","objective","function",".","See","https",":","\/\/keras.io\/losses\/","gamma",":","float",",","optional","(","default=1.0",")","Coefficient","of","beta","VAE","regime",".","Default","is","regular","VAE",".","capacity",":","float",",","optional","(","default=0.0",")","Maximum","capacity","of","a","loss","bottle","neck",".","optimizer",":","str",",","optional","(","default='adam","'",")","String","(","name","of","optimizer",")","or","optimizer","instance",".","See","https",":","\/\/keras.io\/optimizers\/","epochs",":","int",",","optional","(","default=100",")","Number","of","epochs","to","train","the","model",".","batch_size",":","int",",","optional","(","default=32",")","Number","of","samples","per","gradient","update",".","dropout_rate",":","float","in","(","0.",",","1",")",",","optional","(","default=0.2",")","The","dropout","to","be","used","across","all","layers",".","l2_regularizer",":","float","in","(","0.",",","1",")",",","optional","(","default=0.1",")","The","regularization","strength","of","activity_regularizer","applied","on","each","layer",".","By","default",",","l2","regularizer","is","used",".","See","https",":","\/\/keras.io\/regularizers\/","validation_size",":","float","in","(","0.",",","1",")",",","optional","(","default=0.1",")","The","percentage","of","data","to","be","used","for","validation",".","preprocessing",":","bool",",","optional","(","default=True",")","If","True",",","apply","standardization","on","the","data",".","verbose",":","int",",","optional","(","default=1",")","verbose","mode",".","-","0","=","silent","-","1","=","progress","bar","-","2","=","one","line","per","epoch",".","For","verbose",">","=","1",",","model","summary","may","be","printed",".","random_state",":","random_state",":","int",",","RandomState","instance","or","None",",","opti","(","default=None",")","If","int",",","random_state","is","the","seed","used","by","the","random","number","generator",";","If","RandomState","instance",",","random_state","is","the","r","number","generator",";","If","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","contamination",":","float","in","(","0.",",","0.5",")",",","optional","(","default=0.1",")","The","amount","of","contamination","of","the","data","set",",","i.e",".","the","proportion","of","outliers","in","the","data","set",".","When","fitting","this","is","to","define","the","threshold","on","the","decision","function",".","Attributes","--","--","--","--","--","encoding_dim_",":","int","The","number","of","neurons","in","the","encoding","layer",".","compression_rate_",":","float","The","ratio","between","the","original","feature","and","the","number","of","neurons","in","the","encoding","layer",".","model_",":","Keras","Object","The","underlying","AutoEncoder","in","Keras",".","history_",":","Keras","Object","The","AutoEncoder","training","history",".","decision_scores_",":","numpy","array","of","shape","(","n_samples",",",")","The","outlier","scores","of","the","training","data",".","The","higher",",","the","more","abnormal",".","Outliers","tend","to","have","higher","scores",".","This","value","is","available","once","the","detector","is","fitted",".","threshold_",":","float","The","threshold","is","based","on","``","contamination","``",".","It","is","the","``","n_samples","*","contamination","``","most","abnormal","samples","in","``","decision_scores_","``",".","The","threshold","is","calculated","for","generating","binary","outlier","labels",".","labels_",":","int",",","either","0","or","1","The","binary","labels","of","the","training","data",".","0","stands","for","inliers","and","1","for","outliers\/anomalies",".","It","is","generated","by","applying","``","threshold_","``","on","``","decision_scores_","``","."]
docstr: Fit detector. y is optional for unsupervised methods.
  
  Parameters
  ----------
  X : numpy array of shape (n_samples, n_features)
      The input samples.
  
  y : numpy array of shape (n_samples,), optional (default=None)
      The ground truth of the input samples (labels).
docstr_tok: ["Fit","detector",".","y","is","optional","for","unsupervised","methods",".","Parameters","--","--","--","--","--","X",":","numpy","array","of","shape","(","n_samples",",","n_features",")","The","input","samples",".","y",":","numpy","array","of","shape","(","n_samples",",",")",",","optional","(","default=None",")","The","ground","truth","of","the","input","samples","(","labels",")","."]
code: def fit(self, X, y=None):
      """Fit detector. y is optional for unsupervised methods.
  
      Parameters
      ----------
      X : numpy array of shape (n_samples, n_features)
          The input samples.
  
      y : numpy array of shape (n_samples,), optional (default=None)
          The ground truth of the input samples (labels).
      """
      # validate inputs X and y (optional)
      X = check_array(X)
      self._set_n_classes(y)
  
      # Verify and construct the hidden units
      self.n_samples_, self.n_features_ = X.shape[0], X.shape[1]
  
      # Standardize data for better performance
      if self.preprocessing:
          self.scaler_ = StandardScaler()
          X_norm = self.scaler_.fit_transform(X)
      else:
          X_norm = np.copy(X)
  
      # Shuffle the data for validation as Keras do not shuffling for
      # Validation Split
      np.random.shuffle(X_norm)
  
      # Validate and complete the number of hidden neurons
      if np.min(self.encoder_neurons) > self.n_features_:
          raise ValueError(
              "The number of neurons should not exceed "
              "the number of features"
          )
  
      # Build VAE model & fit with X
      self.model_ = self._build_model()
      self.history_ = self.model_.fit(
          X_norm,
          epochs=self.epochs,
          batch_size=self.batch_size,
          shuffle=True,
          validation_split=self.validation_size,
          verbose=self.verbose,
      ).history
      # Predict on X itself and calculate the reconstruction error as
      # the outlier scores. Noted X_norm was shuffled has to recreate
      if self.preprocessing:
          X_norm = self.scaler_.transform(X)
      else:
          X_norm = np.copy(X)
  
      pred_scores = self.model_.predict(X_norm)
      self.decision_scores_ = pairwise_distances_no_broadcast(
          X_norm, pred_scores
      )
      self._process_decision_scores()
      return self
  
file_path: pyod/pyod/models/vae.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from .base import BaseDetector
  from .base_dl import _get_tensorflow_version
  from ..utils.stat_models import pairwise_distances_no_broadcast
  from ..utils.utility import check_parameter
label_desc: Use image node_id 5 for calling the VAE obj's underlying member method code with example usage: obj.fit(X, y) and returns: self