add comments

This commit is contained in:
bohanjason 2019-11-30 16:38:36 -05:00 committed by Dana Van Aken
parent 7b57eb98a2
commit edb1aba4fc
2 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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)