https://github.com/GPflow/GPflow
Revision bb3d1f44865b73b4fd8ad7e98410bac073a57202 authored by st-- on 19 September 2018, 13:48:08 UTC, committed by GitHub on 19 September 2018, 13:48:08 UTC
Minor code changes: - adds rich representation to Parameter(ized) objects so `m.as_pandas_table()` can be replaced by `m` for pretty-printing in jupyter notebooks - updates priors to have prettier printing (and more value checks) Notebooks - coreg_demo.ipynb: clean-up, typo fixes - models.ipynb: clean-up, now actually consistent with current (gpflow-1.0) architecture - kernels.ipynb: clean-up Documentation - updates various links in README.md (JH's webpage, readthedocs, tensorflow installation) - adds all currently existing notebooks to the documentation (under new section "advanced tutorials") Stand-alone .py demo scripts in doc/source/notebooks/ - makes them runnable with current gpflow version - adds "unmaintained" warning header
1 parent 83631b7
Tip revision: bb3d1f44865b73b4fd8ad7e98410bac073a57202 authored by st-- on 19 September 2018, 13:48:08 UTC
Clean up notebooks and documentation (#849)
Clean up notebooks and documentation (#849)
Tip revision: bb3d1f4
test_scaled_euclid_dist.py
# Copyright 2018 the GPflow authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
import numpy as np
import tensorflow as tf
import gpflow.kernels as kernels
from gpflow.test_util import session_tf
from gpflow import settings
rng = np.random.RandomState(0)
class Datum:
num_data = 100
D = 100
X = rng.rand(num_data, D) * 100
@pytest.mark.parametrize('kernel', [kernels.Matern12, kernels.Matern32, kernels.Matern52, kernels.Exponential, kernels.Cosine])
def test_kernel_euclidean_distance(session_tf, kernel):
'''
Tests output & gradients of kernels that are a function of the (scaled) euclidean distance
of the points. We test on a high dimensional space, which can generate very small distances
causing the scaled_square_dist to generate some negative values.
'''
k = kernel(Datum.D)
K = k.compute_K_symm(Datum.X)
assert not np.isnan(K).any(), 'There are NaNs in the output of the ' + kernel.__name__ + ' kernel.'
assert np.isfinite(K).all(), 'There are Infs in the output of the ' + kernel.__name__ + ' kernel.'
X = tf.placeholder(settings.float_type)
dK = session_tf.run(tf.gradients(k.K(X, X), X)[0], feed_dict={X: Datum.X})
assert not np.isnan(dK).any(), 'There are NaNs in the gradient of the ' + kernel.__name__ + ' kernel.'
assert np.isfinite(dK).all(), 'There are Infs in the output of the ' + kernel.__name__ + ' kernel.'
Computing file changes ...