add comments
This commit is contained in:
parent
7b57eb98a2
commit
edb1aba4fc
|
@ -67,6 +67,16 @@ class GPR(object):
|
||||||
self.graph = tf.Graph()
|
self.graph = tf.Graph()
|
||||||
with self.graph.as_default():
|
with self.graph.as_default():
|
||||||
if self.hyperparameter_trainable:
|
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)
|
mag_ = np.log(np.exp(self.magnitude) - 1)
|
||||||
ls_ = np.log(np.exp(self.length_scale) - 1)
|
ls_ = np.log(np.exp(self.length_scale) - 1)
|
||||||
noise_ = np.log(np.exp(self.ridge) - 1)
|
noise_ = np.log(np.exp(self.ridge) - 1)
|
||||||
|
|
|
@ -33,10 +33,10 @@ class TestNN(unittest.TestCase):
|
||||||
|
|
||||||
def test_nn_ypreds(self):
|
def test_nn_ypreds(self):
|
||||||
ypreds_round = ['%.3f' % x[0] for x in self.nn_result]
|
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)
|
self.assertEqual(ypreds_round, expected_ypreds)
|
||||||
|
|
||||||
def test_nn_yrecommend(self):
|
def test_nn_yrecommend(self):
|
||||||
recommends_round = ['%.3f' % x[0] for x in self.nn_recommend.minl]
|
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)
|
self.assertEqual(recommends_round, expected_recommends)
|
||||||
|
|
Loading…
Reference in New Issue