CausalEGM.causalEGM.VariationalCausalEGM

class CausalEGM.causalEGM.VariationalCausalEGM(params, timestamp=None, random_seed=None)[source]

Implementation of the variational CausalEGM model. Instead of distribution match with GAN, we use variational inference in the latent space.

Parameters:
  • params – Dict object denoting the hyperparameters for deployments and building the model architecture. See examples under the src/configs folder.

  • timestamp – Str object denoting the timestemp for specificing when the model is instanced. Default: None.

  • random_seed – Int object denoting the random seed for controling randomness. Default: None.

Examples

>>> from CausalEGM import VariationalCausalEGM, Sim_Hirano_Imbens_sampler
>>> import yaml
>>> params = yaml.safe_load(open('src/configs/Sim_Hirano_Imbens.yaml', 'r'))
>>> x,y,v = Sim_Hirano_Imbens_sampler(batch_size=32).load_all()
>>> model = VariationalCausalEGM(params=params,random_seed=12)
>>> model.train(data=[x,y,v],n_iter=30000,save_format='npy')
__init__(params, timestamp=None, random_seed=None)[source]

Methods

__init__(params[, timestamp, random_seed])

encode(v)

Encode process and get both mean and variance.

evaluate(data[, nb_intervals])

Internal evaluation in the training process of variational CausalEGM.

get_config()

Get the parameters CausalEGM model.

initialize_nets([print_summary])

Initialize all the networks in CausalEGM.

log_normal_pdf(sample, mean, logvar[, axis])

Log likelihood of a normal distribution

reparameterize(mean, logvar)

Reparameterization for sample latent features.

sample([eps])

Generate data by decoder.

save(fname, data)

Save the data to the specified path.

train([data, data_file, sep, header, ...])

Train a variational CausalEGM model given the input data.

train_step(data_z, data_v, data_x, data_y)

Training step in the Variational CausalEGM model.