class_docstr: DIPVAEExplainer can be used to visualize the changes in the latent space of Disentangled Inferred Prior-VAE
  or DIPVAE [#1]_. This model is a Variational Autoencoder [#2]_ variant that leads to a
  disentangled latent space. This is achieved by matching the covariance of the prior distributions with the
  inferred prior.
  
  References:
      .. [#1] `Variational Inference of Disentangled Latent Concepts from Unlabeled Observations (DIP-VAE), ICLR 2018.
       Kumar, Sattigeri, Balakrishnan. <https://arxiv.org/abs/1711.00848>`_
      .. [#2] `Diederik P Kingma and Max Welling. Auto-encoding variational Bayes. ICLR, 2014. <https://arxiv.org/pdf/1312.6114.pdf>`_
class_docstr_tok: ["DIPVAEExplainer","can","be","used","to","visualize","the","changes","in","the","latent","space","of","Disentangled","Inferred","Prior-VAE","or","DIPVAE","[","#","1","]","_",".","This","model","is","a","Variational","Autoencoder","[","#","2","]","_","variant","that","leads","to","a","disentangled","latent","space",".","This","is","achieved","by","matching","the","covariance","of","the","prior","distributions","with","the","inferred","prior",".","References",":","..","[","#","1","]","`","Variational","Inference","of","Disentangled","Latent","Concepts","from","Unlabeled","Observations","(","DIP-VAE",")",",","ICLR","2018",".","Kumar",",","Sattigeri",",","Balakrishnan",".","<","https",":","\/\/arxiv.org\/abs\/1711.00848",">","`","_","..","[","#","2","]","`","Diederik","P","Kingma","and","Max","Welling",".","Auto-encoding","variational","Bayes",".","ICLR",",","2014",".","<","https",":","\/\/arxiv.org\/pdf\/1312.6114.pdf",">","`","_"]
docstr: Initialize DIPVAEExplainer explainer.
  
  Args:
      model_args: This should contain all the parameter required for the generative model training and
          inference. This includes model type (vae, dipvae-i, dipvae-ii, user-defined). The user-defined model can be
          passed to the parameter net of the fit() function. Each of the model should have encoder and decode function
          defined. See the notebook example for other model specific parameters.
      dataset: The dataset object.
      net: If not None this is the user specified generative model.
      cuda_available: If True use GPU.
docstr_tok: ["Initialize","DIPVAEExplainer","explainer",".","Args",":","model_args",":","This","should","contain","all","the","parameter","required","for","the","generative","model","training","and","inference",".","This","includes","model","type","(","vae",",","dipvae-i",",","dipvae-ii",",","user-defined",")",".","The","user-defined","model","can","be","passed","to","the","parameter","net","of","the","fit","(",")","function",".","Each","of","the","model","should","have","encoder","and","decode","function","defined",".","See","the","notebook","example","for","other","model","specific","parameters",".","dataset",":","The","dataset","object",".","net",":","If","not","None","this","is","the","user","specified","generative","model",".","cuda_available",":","If","True","use","GPU","."]
code: def __init__(
      self, model_args, dataset=None, net=None, cuda_available=None
  ):
      """
      Initialize DIPVAEExplainer explainer.
  
      Args:
          model_args: This should contain all the parameter required for the generative model training and
              inference. This includes model type (vae, dipvae-i, dipvae-ii, user-defined). The user-defined model can be
              passed to the parameter net of the fit() function. Each of the model should have encoder and decode function
              defined. See the notebook example for other model specific parameters.
          dataset: The dataset object.
          net: If not None this is the user specified generative model.
          cuda_available: If True use GPU.
      """
  
      super(DIPVAEExplainer, self).__init__()
      self.model_args = model_args
  
      torch.manual_seed(self.model_args.seed)
  
      if net is None:
          if self.model_args.model == "vae":
              self.net = VAE(
                  num_nodes=self.model_args.num_nodes,
                  activation_type=self.model_args.activation_type,
                  latent_dim=self.model_args.latent_dim,
                  op_dim=np.prod(dataset.data_dims),
                  args=self.model_args,
                  cuda_available=cuda_available,
              )
          elif self.model_args.model == "dipvae-i":
              self.net = DIPVAE(
                  num_nodes=self.model_args.num_nodes,
                  activation_type=self.model_args.activation_type,
                  latent_dim=self.model_args.latent_dim,
                  op_dim=np.prod(dataset.data_dims),
                  args=self.model_args,
                  cuda_available=cuda_available,
                  mode="i",
                  output_activation_type=dataset.output_activation_type,
                  likelihood_type=dataset.likelihood_type,
              )
          elif self.model_args.model == "dipvae-ii":
              self.net = DIPVAE(
                  num_nodes=self.model_args.num_nodes,
                  activation_type=self.model_args.activation_type,
                  latent_dim=self.model_args.latent_dim,
                  op_dim=np.prod(dataset.data_dims),
                  args=self.model_args,
                  cuda_available=cuda_available,
                  mode="ii",
                  output_activation_type=dataset.output_activation_type,
                  likelihood_type=dataset.likelihood_type,
              )
      else:
          self.net = net
  
      self.cuda_available = cuda_available
      self.dataset = dataset
  
      if self.cuda_available:
          self.net = self.net.cuda()
  
file_path: AIX360/aix360/algorithms/dipvae/dipvae.py
imports: from __future__ import print_function
  import torch
  from torch import __init__
  from torch.optim import Adam
  from .dipvae_utils import VAE, DIPVAE
  from .dipvae_utils import plot_reconstructions, plot_latent_traversal
  from aix360.algorithms.die import DIExplainer
  import os
  import sys
  import random
  import time
  import numpy
label_desc: Use image node_id 1 to create a new DIPVAEExplainer object from inherited base classes: DIExplainer with example: obj = DIPVAEExplainer(model_args, dataset, net, cuda_available)