def mapping(self, x): # Transform unconstrained parameters to lie on simplex. pi = Variable("pi", [self.num_factors, self.K - 1]) pi_const = tf.sigmoid(pi) pi_const = tf.concat( 1, [pi_const, tf.expand_dims(1.0 - tf.reduce_sum(pi_const), 0)]) return [pi_const]
def mapping(self, x): p = Variable("p", [self.num_params]) # Constrain parameters to lie on simplex. p_const = tf.sigmoid(p) if self.num_vars > 1: p_const = tf.concat( 0, [p_const, tf.expand_dims(1.0 - tf.reduce_sum(p_const), 0)]) return [p_const]
def mapping(self, x): # Transform a real (K-1)-vector to K-dimensional simplex. pi = Variable("pi", [self.num_factors, self.K - 1]) eq = -tf.log( tf.cast(self.K - 1 - tf.range(self.K - 1), dtype=tf.float32)) z = tf.sigmoid(eq + pi) pil = tf.concat(1, [z, tf.ones([self.num_factors, 1])]) piu = tf.concat(1, [tf.ones([self.num_factors, 1]), 1.0 - z]) # cumulative product along 1st axis S = tf.pack([cumprod(piu_x) for piu_x in tf.unpack(piu)]) return [S * pil]
def mapping(self, x): params = Variable("params", [self.num_vars]) return [self.transform(params)]
def mapping(self, x): mean = Variable("mu", [self.num_vars]) stddev = Variable("sigma", [self.num_vars]) return [tf.identity(mean), tf.nn.softplus(stddev)]
def mapping(self, x): alpha = Variable("alpha", [self.num_vars]) beta = Variable("beta", [self.num_vars]) return [tf.nn.softplus(alpha) + 1e-2, tf.nn.softplus(beta) + 1e-2]
def mapping(self, x): alpha = Variable("dirichlet_alpha", [self.num_factors, self.K]) return [tf.nn.softplus(alpha)]
def mapping(self, x): p = Variable("p", [self.num_params]) return [tf.sigmoid(p)]