diff options
Diffstat (limited to 'tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py')
-rw-r--r-- | tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py b/tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py index 5ce64cbe3d..81e40dbe5e 100644 --- a/tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py +++ b/tensorflow/contrib/bayesflow/python/kernel_tests/stochastic_tensor_test.py @@ -19,16 +19,16 @@ from __future__ import division from __future__ import print_function import numpy as np - +from tensorflow.contrib import distributions as distributions_lib from tensorflow.contrib.bayesflow.python.ops import stochastic_gradient_estimators from tensorflow.contrib.bayesflow.python.ops import stochastic_tensor_impl -from tensorflow.contrib.distributions.python.ops import normal from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.platform import test +distributions = distributions_lib sge = stochastic_gradient_estimators st = stochastic_tensor_impl @@ -42,20 +42,20 @@ class StochasticTensorTest(test.TestCase): sigma2 = constant_op.constant([0.1, 0.2, 0.3]) prior_default = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma)) self.assertTrue(isinstance(prior_default.value_type, st.SampleValue)) prior_0 = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), dist_value_type=st.SampleValue()) self.assertTrue(isinstance(prior_0.value_type, st.SampleValue)) with st.value_type(st.SampleValue()): - prior = st.StochasticTensor(normal.Normal(loc=mu, scale=sigma)) + prior = st.StochasticTensor(distributions.Normal(loc=mu, scale=sigma)) self.assertTrue(isinstance(prior.value_type, st.SampleValue)) likelihood = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=prior, scale=sigma2)) self.assertTrue(isinstance(likelihood.value_type, st.SampleValue)) @@ -85,7 +85,7 @@ class StochasticTensorTest(test.TestCase): sigma = constant_op.constant([1.1, 1.2, 1.3]) with st.value_type(st.MeanValue()): - prior = st.StochasticTensor(normal.Normal(loc=mu, scale=sigma)) + prior = st.StochasticTensor(distributions.Normal(loc=mu, scale=sigma)) self.assertTrue(isinstance(prior.value_type, st.MeanValue)) prior_mean = prior.mean() @@ -102,7 +102,7 @@ class StochasticTensorTest(test.TestCase): with st.value_type(st.SampleValue()): prior_single = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma)) prior_single_value = prior_single.value() @@ -113,7 +113,7 @@ class StochasticTensorTest(test.TestCase): with st.value_type(st.SampleValue(1)): prior_single = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma)) self.assertTrue(isinstance(prior_single.value_type, st.SampleValue)) @@ -125,7 +125,7 @@ class StochasticTensorTest(test.TestCase): with st.value_type(st.SampleValue(2)): prior_double = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma)) prior_double_value = prior_double.value() @@ -139,10 +139,10 @@ class StochasticTensorTest(test.TestCase): mu = [0.0, -1.0, 1.0] sigma = constant_op.constant([1.1, 1.2, 1.3]) with st.value_type(st.MeanValue()): - prior = st.StochasticTensor(normal.Normal(loc=mu, scale=sigma)) + prior = st.StochasticTensor(distributions.Normal(loc=mu, scale=sigma)) entropy = prior.entropy() deep_entropy = prior.distribution.entropy() - expected_deep_entropy = normal.Normal( + expected_deep_entropy = distributions.Normal( loc=mu, scale=sigma).entropy() entropies = sess.run([entropy, deep_entropy, expected_deep_entropy]) self.assertAllEqual(entropies[2], entropies[0]) @@ -155,7 +155,7 @@ class StochasticTensorTest(test.TestCase): # With default with st.value_type(st.MeanValue(stop_gradient=True)): - dt = st.StochasticTensor(normal.Normal(loc=mu, scale=sigma)) + dt = st.StochasticTensor(distributions.Normal(loc=mu, scale=sigma)) loss = dt.loss([constant_op.constant(2.0)]) self.assertTrue(loss is not None) self.assertAllClose( @@ -163,7 +163,7 @@ class StochasticTensorTest(test.TestCase): # With passed-in loss_fn. dt = st.StochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), dist_value_type=st.MeanValue(stop_gradient=True), loss_fn=sge.get_score_function_with_constant_baseline( @@ -199,7 +199,7 @@ class ObservedStochasticTensorTest(test.TestCase): sigma = constant_op.constant([1.1, 1.2, 1.3]) obs = array_ops.zeros((2, 3)) z = st.ObservedStochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), value=obs) [obs_val, z_val] = sess.run([obs, z.value()]) self.assertAllEqual(obs_val, z_val) @@ -212,14 +212,14 @@ class ObservedStochasticTensorTest(test.TestCase): sigma = array_ops.placeholder(dtypes.float32) obs = array_ops.placeholder(dtypes.float32) z = st.ObservedStochasticTensor( - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), value=obs) mu2 = array_ops.placeholder(dtypes.float32, shape=[None]) sigma2 = array_ops.placeholder(dtypes.float32, shape=[None]) obs2 = array_ops.placeholder(dtypes.float32, shape=[None, None]) z2 = st.ObservedStochasticTensor( - normal.Normal( + distributions.Normal( loc=mu2, scale=sigma2), value=obs2) coll = ops.get_collection(st.STOCHASTIC_TENSOR_COLLECTION) @@ -231,19 +231,19 @@ class ObservedStochasticTensorTest(test.TestCase): self.assertRaises( ValueError, st.ObservedStochasticTensor, - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), value=array_ops.zeros((3,))) self.assertRaises( ValueError, st.ObservedStochasticTensor, - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), value=array_ops.zeros((3, 1))) self.assertRaises( ValueError, st.ObservedStochasticTensor, - normal.Normal( + distributions.Normal( loc=mu, scale=sigma), value=array_ops.zeros( (1, 2), dtype=dtypes.int32)) |