From edb1aba4fc1ab58b720a468312591b5b146ccf8b Mon Sep 17 00:00:00 2001 From: bohanjason Date: Sat, 30 Nov 2019 16:38:36 -0500 Subject: [PATCH] add comments --- server/analysis/gp_tf.py | 10 ++++++++++ server/analysis/tests/test_nn.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/analysis/gp_tf.py b/server/analysis/gp_tf.py index b3c1646..8eeb6a9 100644 --- a/server/analysis/gp_tf.py +++ b/server/analysis/gp_tf.py @@ -67,6 +67,16 @@ class GPR(object): self.graph = tf.Graph() with self.graph.as_default(): if self.hyperparameter_trainable: + r""" + A transform of the form + .. math:: + + y = \log(1 + \exp(x)) + + x is a free variable, y is always positive. + This function is known as 'softplus' in tensorflow. + This transformation gaurantees y value is always positive + """ mag_ = np.log(np.exp(self.magnitude) - 1) ls_ = np.log(np.exp(self.length_scale) - 1) noise_ = np.log(np.exp(self.ridge) - 1) diff --git a/server/analysis/tests/test_nn.py b/server/analysis/tests/test_nn.py index 0705435..302e2ee 100644 --- a/server/analysis/tests/test_nn.py +++ b/server/analysis/tests/test_nn.py @@ -33,10 +33,10 @@ class TestNN(unittest.TestCase): def test_nn_ypreds(self): ypreds_round = ['%.3f' % x[0] for x in self.nn_result] - expected_ypreds = ['21.279', '22.668', '23.115', '27.228', '25.892', '23.967'] + expected_ypreds = ['20.021', '22.578', '22.722', '26.889', '24.362', '23.258'] self.assertEqual(ypreds_round, expected_ypreds) def test_nn_yrecommend(self): recommends_round = ['%.3f' % x[0] for x in self.nn_recommend.minl] - expected_recommends = ['21.279', '21.279', '21.279', '21.279', '21.279', '21.279'] + expected_recommends = ['13.321', '15.482', '15.621', '18.648', '16.982', '15.986'] self.assertEqual(recommends_round, expected_recommends)