Exemplo n.º 1
0
    def logLike(self):
        entrySample = self.dataManager.createTensorForEntry(self.outputVariables[0])
        diffSample = entrySample - self.tn_mean

        return - 0.5 * tfutils.sum(tf.square(tf.matrix_triangular_solve(self.tn_stdMatrix, tf.transpose(diffSample))), axis=0) \
               - 0.5 * np.log(2.0 * np.pi) * self.dimOutput \
               - tfutils.sum(tf.log(tf.diag_part(self.tn_stdMatrix)))
Exemplo n.º 2
0
    def logLike(self):
        entrySample = self.dataManager.createTensorForEntry(self.outputVariables[0])


        return - 0.5 * tfutils.sum(tf.multiply(tf.transpose(entrySample),tf.matmul(self.tn_precision, tf.transpose(entrySample))), axis=0) \
               - 0.5 * tf.matmul(self.tn_linearTerm, tf.transpose(entrySample)) - 0.5 * tfutils.sum(tf.multiply(self.tn_linearTerm,tf.linalg.solve(self.tn_precision, tf.transpose(self.tn_linearTerm))))\
               - 0.5 * np.log(2.0 * np.pi) * self.dimOutput \
               + tfutils.sum(tf.log(tf.diag_part(self.tn_precisionSqrt)))
Exemplo n.º 3
0
 def entropy(self):
     return tfutils.sum(self.tn_logStd + .5 * np.log(2.0 * np.pi * np.e), axis=-1)
Exemplo n.º 4
0
 def logLike(self):
     entrySample = self.dataManager.createTensorForEntry(self.outputVariables[0])
     return - 0.5 * tfutils.sum(tf.square((entrySample - self.tn_mean) / self.tn_std), axis=-1) \
            - 0.5 * np.log(2.0 * np.pi) * tf.to_float(tf.shape(entrySample)[-1]) \
            - tfutils.sum(self.tn_logStd, axis=-1)
Exemplo n.º 5
0
 def entropy(self):
     return tfutils.sum(-tf.log(tf.diag_part(self.tn_precisionSqrt)) + .5 * np.log(2.0 * np.pi * np.e), axis=-1)
Exemplo n.º 6
0
 def klDivergence(self, other):
     assert isinstance(other, DiagonalGaussian_Base)
     return tfutils.sum(other.tn_logStd - self.tn_logStd + (tf.square(self.tn_std) + tf.square(self.tn_mean - other.tn_mean)) / (2.0 * tf.square(other.tn_std)) - 0.5, axis=-1)
Exemplo n.º 7
0
    def klDivergence(self, other):
        assert isinstance(other, FullGaussian_Base)

        return tfutils.sum(tf.log(tf.diag_part(other.tn_stdMatrix)) - tf.log(tf.diag_part(self.tn_stdMatrix)) - 0.5) +  0.5 * tf.trace(tf.matrix_solve(other.tn_covMatrix, self.tn_covMatrix)) + \
            0.5 * tfutils.sum(tf.square(tf.matrix_triangular_solve(other.tn_stdMatrix, tf.transpose(other.tn_mean - self.tn_mean))), axis=0)
Exemplo n.º 8
0
 def entropy(self):
     return tfutils.sum(tf.log(tf.diag_part(self.tn_stdMatrix)) + .5 * np.log(2.0 * np.pi * np.e), axis=-1)
Exemplo n.º 9
0
    def output(self):
        entrySample = self.getAllInputTensor()

        meanTensor = tfutils.sum(tf.multiply(tf.transpose(entrySample),tf.matmul(self.tn_quadraticTerm, tf.transpose(entrySample))), axis=0) \
               + tf.matmul(tf.transpose(self.tn_linearTerm), tf.transpose(entrySample)) + self.tn_constantTerm
        return meanTensor