f4c45be6554d717714d6ff5e67ab51bc4ea2e864,cde/density_estimator/NF.py,NormalizingFlowEstimator,_build_model,#NormalizingFlowEstimator#,146

Before Change


            // since we operate with matrices not vectors, the output would have dimension (?,1)
            // and therefor has to be reduce first to have shape (?,)
            if self.data_normalization:
                self.pdf_ = tf.reduce_sum(target_dist.prob(self.y_input), axis=1) / tf.reduce_prod(self.std_y_sym)
                self.log_pdf_ = tf.reduce_sum(target_dist.log_prob(self.y_input), axis=1) - tf.reduce_sum(tf.log(self.std_y_sym))
                self.cdf_ = tf.reduce_sum(target_dist.cdf(self.y_input), axis=1) / tf.reduce_prod(self.std_y_sym)
            else:
                self.pdf_ = tf.reduce_sum(target_dist.prob(self.y_input), axis=1)
                self.log_pdf_ = tf.reduce_sum(target_dist.log_prob(self.y_input), axis=1)
                self.cdf_ = tf.reduce_sum(target_dist.cdf(self.y_input), axis=1)

            self.loss = -tf.reduce_mean(self.pdf_)
            self.log_loss = -tf.reduce_mean(self.log_pdf_)
            self.train_step = tf.train.AdamOptimizer().minimize(self.log_loss)

After Change


            // since we operate with matrices not vectors, the output would have dimension (?,1)
            // and therefor has to be reduce first to have shape (?,)
            if self.data_normalization:
                self.pdf_ = tf.squeeze(target_dist.prob(self.y_input) / tf.reduce_prod(self.std_y_sym), axis=1)
                self.log_pdf_ = tf.squeeze(target_dist.log_prob(self.y_input) - tf.reduce_sum(tf.log(self.std_y_sym)), axis=1)
                self.cdf_ = tf.squeeze(target_dist.cdf(self.y_input), axis=1)
            else:
                self.pdf_ = tf.squeeze(target_dist.prob(self.y_input), axis=1)
                self.log_pdf_ = tf.squeeze(target_dist.log_prob(self.y_input), axis=1)
                self.cdf_ = tf.squeeze(target_dist.cdf(self.y_input), axis=1)

            self.loss = -tf.reduce_prod(self.pdf_)
            self.log_loss = -tf.reduce_sum(self.log_pdf_)
            self.train_step = tf.train.AdamOptimizer().minimize(self.log_loss)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: freelunchtheorem/Conditional_Density_Estimation
Commit Name: f4c45be6554d717714d6ff5e67ab51bc4ea2e864
Time: 2019-05-02
Author: simonboehm@mailbox.org
File Name: cde/density_estimator/NF.py
Class Name: NormalizingFlowEstimator
Method Name: _build_model


Project Name: MorvanZhou/Reinforcement-learning-with-tensorflow
Commit Name: 899acbe7a07e812edbdeefb5492e0b0bf96908f5
Time: 2020-04-21
Author: morvanzhou@tencent.com
File Name: contents/12_Proximal_Policy_Optimization/simply_PPO.py
Class Name: PPO
Method Name: __init__


Project Name: freelunchtheorem/Conditional_Density_Estimation
Commit Name: 33d61460bcda81161f0254b074c3a0eda3ce70ee
Time: 2019-05-02
Author: simonboehm@mailbox.org
File Name: cde/density_estimator/NF.py
Class Name: NormalizingFlowEstimator
Method Name: _build_model