Revision 48270681afc13081094f7f398a1e194c6b07ba9b authored by vdutor on 03 January 2018, 17:44:53 UTC, committed by Mark van der Wilk on 03 January 2018, 17:44:53 UTC
* Outline of new expectations code. * Quadrature code now uses TensorFlow shape inference. * General expectations work. * Expectations RBF kern, not tested * Add Identity mean function * General unittests for Expectations * Add multipledispatch package to travis * Update tests_expectations * Expectations of mean functions * Mean function uncertain conditional * Uncertain conditional with mean_function. Tested. * Support for Add and Prod kernels and quadrature fallback decorator * Refactor expectations unittests * Psi stats Linear kernel * Split expectations in different files * Expectation Linear kernel and Linear mean function * Remove None's from expectations api * Removed old ekernels framework * Add multipledispatch to setup file * Work on PR feedback, not finished * Addressed PR feedback * Support for pairwise xKxz * Enable expectations unittests * Renamed `TimeseriesGaussian` to `MarkovGaussian` and added tests. * Rename some variable, plus note for later test of <x Kxz>_q. * Update conditionals.py Add comment * Change order of inputs to (feat, kern) * Stef/expectations (#601) * adding gaussmarkov quad * don't override the markvogaussian in the quadrature * can't test * adding external test * quadrature code done and works for MarkovGauss * MarkovGaussian with quad implemented. All tests pass * Shape comments. * Removed superfluous autoflow functions for kernel expectations * Update kernels.py * Update quadrature.py
1 parent 2182bf0
test_util.py
# Copyright 2017 Artem Artemev @awav
#
# 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 contextlib
import tensorflow as tf
class session_context(contextlib.ContextDecorator):
def __init__(self, graph=None, close_on_exit=True, **kwargs):
self.graph = graph
self.close_on_exit = close_on_exit
self.session = None
self.session_args = kwargs
def __enter__(self):
graph = tf.Graph() if self.graph is None else self.graph
session = tf.Session(graph=graph, **self.session_args)
self.session = session
session.__enter__()
return session
def __exit__(self, *exc):
session = self.session
session.__exit__(*exc)
if self.close_on_exit:
session.close()
return False
class GPflowTestCase(tf.test.TestCase):
"""
Wrapper for TensorFlow TestCase to avoid massive duplication of resetting
Tensorflow Graph.
"""
_multiprocess_can_split_ = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.test_graph = tf.Graph()
@contextlib.contextmanager
def test_context(self, graph=None):
graph = self.test_graph if graph is None else graph
with graph.as_default(), self.test_session(graph=graph) as session:
yield session
Computing file changes ...