Revision 6c35a7a8544dfecfe92ef9b559b90fcb40b364eb authored by Mark van der Wilk on 20 November 2017, 17:43:17 UTC, committed by GitHub on 20 November 2017, 17:43:17 UTC
* Add Features base classes * Convert SGPR and SVGP models to use InducingFeatures (including backwards compatibility) * Fix tests * Added Multiscale feature. To show the generality of the inter-domain code. * Fixed py2 metaclass issue, as per John Bradshaw's suggestion. * Improve docstrings, register Multiscale feature * Change SGPR models to determine feature length dynamically [but feature.__len__() still needs to be made dynamic as well!] * Bits and pieces missed in the merge. * Add features to __init__. * Fixed incorrect parameter dtype assignment on compile. * Two bugfixs. - Static assignment of len(feature) - Upper bound mixin referred to Z. * Fixed bugs in multiscale & added features. * Added tests for `Multiscale` inducing features. * Updated `RELEASE.md`, and small changes for tests. * add test for len(feature) * Deprecation property for `Z`, relative imports, improved test. * `SGPMC` has inducing features now + better docstrings. * Fixed `SGPMC`. * Testing now uses tf1.4. * `feat` now `feature` + other changes. * Update _version.py * change exception
1 parent 0741f86
test_session.py
# Copyright 2017 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.from __future__ import print_function
# pylint: disable=W0212
import numpy as np
import tensorflow as tf
import gpflow
from gpflow import settings
from gpflow import session_manager
from gpflow.test_util import GPflowTestCase
class TestSessionConfiguration(GPflowTestCase):
def prepare(self):
with gpflow.defer_build():
return gpflow.models.GPR(
np.ones((1, 1)),
np.ones((1, 1)),
kern=gpflow.kernels.Matern52(1))
def test_option_persistance(self):
'''
Test configuration options are passed to tensorflow session
'''
dop = 3
settings.session.intra_op_parallelism_threads = dop
settings.session.inter_op_parallelism_threads = dop
settings.session.allow_soft_placement = True
session = gpflow.session_manager.get_session()
self.assertTrue(session._config.inter_op_parallelism_threads == dop)
self.assertTrue(isinstance(session._config.inter_op_parallelism_threads, int))
self.assertTrue(session._config.allow_soft_placement)
self.assertTrue(isinstance(session._config.allow_soft_placement, bool))
# m = self.prepare()
# m.compile()
# opt = gpflow.train.ScipyOptimizer()
# opt.minimize(m, maxiter=1)
def test_option_mutability(self):
'''
Test configuration options are passed to tensorflow session
'''
dop = 33
settings.session.intra_op_parallelism_threads = dop
settings.session.inter_op_parallelism_threads = dop
graph = tf.Graph()
tf_session = session_manager.get_session(
graph=graph,
output_file_name=settings.profiling.output_file_name + "_objective",
output_directory=settings.profiling.output_directory,
each_time=settings.profiling.each_time)
self.assertTrue(tf_session._config.intra_op_parallelism_threads == dop)
self.assertTrue(tf_session._config.inter_op_parallelism_threads == dop)
tf_session.close()
# change maximum degree of parallelism
dopOverride = 12
tf_session = session_manager.get_session(
graph=graph,
output_file_name=settings.profiling.output_file_name + "_objective",
output_directory=settings.profiling.output_directory,
each_time=settings.profiling.each_time,
config=tf.ConfigProto(intra_op_parallelism_threads=dopOverride,
inter_op_parallelism_threads=dopOverride))
self.assertTrue(tf_session._config.intra_op_parallelism_threads == dopOverride)
self.assertTrue(tf_session._config.inter_op_parallelism_threads == dopOverride)
tf_session.close()
def test_session_default_graph(self):
tf_session = session_manager.get_session()
self.assertEqual(tf_session.graph, tf.get_default_graph())
tf_session.close()
if __name__ == '__main__':
tf.test.main()
Computing file changes ...