Ejemplo n.º 1
0
    def compute_logpx(self, x, y, z):
	px_in = tf.reshape(tf.concat([y,z], axis=-1), [-1, self.n_y+self.n_z])
	if self.x_dist == 'Gaussian':
            mean, log_var = dgm.forwardPassGauss(px_in, self.px_yz, self.n_hid, self.nonlinearity, self.bn, scope='px_yz')
	    mean, log_var = tf.reshape(mean, [self.mc_samples, -1, self.n_x]),  tf.reshape(log_var, [self.mc_samples, -1, self.n_x])
            return dgm.gaussianLogDensity(x, mean, log_var)
        elif self.x_dist == 'Bernoulli':
            logits = dgm.forwardPassCatLogits(px_in, self.px_yz, self.n_hid, self.nonlinearity, self.bn, scope='px_yz')
	    logits = tf.reshape(logits, [self.mc_samples, -1, self.n_x])
            return dgm.bernoulliLogDensity(x, logits) 
Ejemplo n.º 2
0
 def compute_logpx(self, x, z):
     px_in = tf.reshape(z, [-1, self.n_z])
     if self.x_dist == 'Gaussian':
         mean, log_var = self.p_x_z_mean(px_in), self.p_x_z_log_var(px_in)
         mean = tf.reshape(mean, [self.mc_samples, -1, self.n_x])
         log_var = tf.reshape(log_var, [self.mc_samples, -1, self.n_x])
         return dgm.gaussianLogDensity(x, mean, log_var)
     elif self.x_dist == 'Bernoulli':
         logits = self.p_x_z_mean(px_in)
         logits = tf.reshape(logits, [self.mc_samples, -1, self.n_x])
         return dgm.bernoulliLogDensity(x, logits)
Ejemplo n.º 3
0
    def compute_logpx(self, x, z):
	""" compute the log density of x under p(x|z) """
	px_in = tf.reshape(z, [-1, self.n_z])
	if self.x_dist == 'Gaussian':
            mean, log_var = dgm.forwardPassGauss(px_in, self.px_z, self.n_hid, self.nonlinearity, self.bn, scope='px_z')
	    mean, log_var = tf.reshape(mean, [self.mc_samples, -1, self.n_x]),  tf.reshape(log_var, [self.mc_samples, -1, self.n_x])
            return dgm.gaussianLogDensity(x, mean, log_var)
        elif self.x_dist == 'Bernoulli':
            logits = dgm.forwardPassCatLogits(px_in, self.px_z, self.n_hid, self.nonlinearity, self.bn, scope='px_z')
	    logits = tf.reshape(logits, [self.mc_samples, -1, self.n_x])
            return dgm.bernoulliLogDensity(x, logits) 
Ejemplo n.º 4
0
 def compute_logpx(self, x, y, z):
     px_in = tf.reshape(tf.concat([y, z], axis=-1),
                        [-1, self.n_y + self.n_z])
     if self.x_dist == 'Gaussian':
         mean, log_var = self.p_x_yz_mean(px_in), self.p_x_yz_log_var(px_in)
         mean, log_var = tf.reshape(
             mean, [self.mc_samples, -1, self.n_x]), tf.reshape(
                 log_var, [self.mc_samples, -1, self.n_x])
         return dgm.gaussianLogDensity(x, mean, log_var)
     elif self.x_dist == 'Bernoulli':
         logits = self.p_x_yz_mean_model(px_in)
         logits = tf.reshape(logits, [self.mc_samples, -1, self.n_x])
         return dgm.bernoulliLogDensity(x, logits)
Ejemplo n.º 5
0
 def compute_logpx(self, x, y, z, a):
     """ compute the log density of x under p(x|y,z,a) """
     px_in = tf.reshape(tf.concat([y, z, a], axis=-1),
                        [-1, self.n_y + self.n_z + self.n_a])
     if self.x_dist == 'Gaussian':
         mean, logVar = dgm.forwardPassGauss(px_in,
                                             self.px_yza,
                                             self.n_hid,
                                             self.nonlinearity,
                                             self.bn,
                                             scope='px_yza')
         mean, logVar = tf.reshape(
             mean, [self.mc_samples, -1, self.n_x]), tf.reshape(
                 logVar, [self.mc_samples, -1, self.n_x])
         return dgm.gaussianLogDensity(x, mean, logVar)
     elif self.x_dist == 'Bernoulli':
         logits = dgm.forwardPassCatLogits(px_in,
                                           self.px_yza,
                                           self.n_hid,
                                           self.nonlinearity,
                                           self.bn,
                                           scope='px_yza')
         logits = tf.reshape(logits, [self.mc_samples, -1, self.n_x])
         return dgm.bernoulliLogDensity(x, logits)