Permalink
Browse files

Remove so many more hourglass imports

Change: 143230429
  • Loading branch information...
1 parent 7815fcb commit e121667dc609de978a223c56ee906368d2c4ceef @jart jart committed with tensorflower-gardener Dec 30, 2016
Showing 396 changed files with 31,742 additions and 25,050 deletions.
@@ -48,9 +48,8 @@ py_library(
"//tensorflow/contrib/solvers:solvers_py",
"//tensorflow/contrib/specs",
"//tensorflow/contrib/stat_summarizer:stat_summarizer_py",
- "//tensorflow/contrib/tensor_forest:tensor_forest_ops_py",
- "//tensorflow/contrib/tensor_forest:tensor_forest_py",
- "//tensorflow/contrib/tensor_forest/hybrid:ops_lib",
+ "//tensorflow/contrib/tensor_forest:init_py",
+ "//tensorflow/contrib/tensor_forest/hybrid:ops_lib", # XXX: no ref but need for pip
"//tensorflow/contrib/tensorboard",
"//tensorflow/contrib/testing:testing_py",
"//tensorflow/contrib/tfprof",
@@ -26,6 +26,8 @@ py_library(
"//tensorflow/python:training",
"//tensorflow/python:util",
"//tensorflow/python:variable_scope",
+ "//third_party/py/numpy",
+ "@six_archive//:six",
],
)
@@ -35,9 +37,16 @@ cuda_py_test(
srcs = ["python/kernel_tests/entropy_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/contrib/layers:layers_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
+ "//tensorflow/python:nn_ops",
"//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
],
)
@@ -47,9 +56,17 @@ cuda_py_test(
srcs = ["python/kernel_tests/stochastic_variables_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
"//tensorflow/python:platform_test",
+ "//tensorflow/python:random_ops",
+ "//tensorflow/python:variable_scope",
+ "//tensorflow/python:variables",
],
)
@@ -59,8 +76,13 @@ cuda_py_test(
srcs = ["python/kernel_tests/monte_carlo_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/contrib/layers:layers_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
"//tensorflow/python:platform_test",
],
)
@@ -71,9 +93,13 @@ cuda_py_test(
srcs = ["python/kernel_tests/special_math_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:gradients",
"//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
],
)
@@ -83,8 +109,14 @@ cuda_py_test(
srcs = ["python/kernel_tests/stochastic_graph_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:gradients",
+ "//tensorflow/python:math_ops",
"//tensorflow/python:platform_test",
],
)
@@ -95,9 +127,15 @@ cuda_py_test(
srcs = ["python/kernel_tests/variational_inference_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/contrib/layers:layers_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:math_ops",
"//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
],
)
@@ -107,7 +145,11 @@ cuda_py_test(
srcs = ["python/kernel_tests/stochastic_tensor_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
@@ -119,9 +161,15 @@ cuda_py_test(
srcs = ["python/kernel_tests/stochastic_gradient_estimators_test.py"],
additional_deps = [
":bayesflow_py",
- "//tensorflow:tensorflow_py",
+ "//third_party/py/numpy",
+ "//tensorflow/contrib/distributions:distributions_py",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:gradients",
+ "//tensorflow/python:math_ops",
"//tensorflow/python:platform_test",
+ "//tensorflow/python:variables",
],
)
@@ -18,12 +18,28 @@
from __future__ import division
from __future__ import print_function
+import sys
+
+# TODO: #6568 Remove this hack that makes dlopen() not crash.
+if hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'):
+ import ctypes
+ sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
+
import numpy as np
-import tensorflow as tf
-distributions = tf.contrib.distributions
-layers = tf.contrib.layers
-entropy = tf.contrib.bayesflow.entropy
+from tensorflow.contrib import distributions as distributions_lib
+from tensorflow.contrib import layers as layers_lib
+from tensorflow.contrib.bayesflow.python.ops import entropy as entropy_lib
+from tensorflow.python.framework import constant_op
+from tensorflow.python.framework import dtypes
+from tensorflow.python.ops import math_ops
+from tensorflow.python.ops import nn_ops
+from tensorflow.python.ops import variables
+from tensorflow.python.platform import test
+
+distributions = distributions_lib
+layers = layers_lib
+entropy = entropy_lib
class NormalNoEntropy(distributions.Normal): # pylint: disable=no-init
@@ -34,10 +50,10 @@ def entropy(self):
def get_train_op(scalar_loss, optimizer='SGD', learning_rate=1.0, decay=0.0):
- global_step = tf.Variable(0)
+ global_step = variables.Variable(0)
def decay_fn(rate, t):
- return rate * (1 + tf.to_float(t))**(-decay)
+ return rate * (1 + math_ops.to_float(t))**(-decay)
train_op = layers.optimize_loss(
scalar_loss,
@@ -59,7 +75,7 @@ def _assert_monotonic_increasing(array, atol=1e-5):
np.testing.assert_array_less(-1 * atol, diff)
-class ElboRatioTest(tf.test.TestCase):
+class ElboRatioTest(test.TestCase):
"""Show sampling converges to true KL values."""
def setUp(self):
@@ -142,7 +158,7 @@ def test_sample_kl_zero_when_p_and_q_are_the_same_distribution(self):
self.assertAllClose(np.zeros(2), sample_kl.eval())
-class EntropyShannonTest(tf.test.TestCase):
+class EntropyShannonTest(test.TestCase):
def test_normal_entropy_default_form_uses_exact_entropy(self):
with self.test_session():
@@ -176,7 +192,7 @@ def test_normal_entropy_sample_form_gets_approximate_answer(self):
self.assertAllClose(exact_entropy.eval(), mc_entropy.eval(), rtol=0.01)
# Make sure there is some error, proving we used samples
- self.assertLess(0.0001, tf.abs(exact_entropy - mc_entropy).eval())
+ self.assertLess(0.0001, math_ops.abs(exact_entropy - mc_entropy).eval())
def test_default_entropy_falls_back_on_sample_if_analytic_not_available(self):
# Tested by showing we get a good answer that is not exact.
@@ -197,10 +213,10 @@ def test_default_entropy_falls_back_on_sample_if_analytic_not_available(self):
self.assertAllClose(exact_entropy.eval(), mc_entropy.eval(), rtol=0.01)
# Make sure there is some error, proving we used samples
- self.assertLess(0.0001, tf.abs(exact_entropy - mc_entropy).eval())
+ self.assertLess(0.0001, math_ops.abs(exact_entropy - mc_entropy).eval())
-class RenyiRatioTest(tf.test.TestCase):
+class RenyiRatioTest(test.TestCase):
"""Show renyi_ratio is minimized when the distributions match."""
def setUp(self):
@@ -216,22 +232,23 @@ def test_fitting_two_dimensional_normal_n_equals_1000(self):
target = distributions.MultivariateNormalCholesky(mu_true, chol_true)
# Set up q distribution by defining mean/covariance as Variables
- mu = tf.Variable(np.zeros(mu_true.shape), dtype=mu_true.dtype, name='mu')
- mat = tf.Variable(
+ mu = variables.Variable(
+ np.zeros(mu_true.shape), dtype=mu_true.dtype, name='mu')
+ mat = variables.Variable(
np.zeros(chol_true.shape), dtype=chol_true.dtype, name='mat')
- chol = distributions.matrix_diag_transform(mat, transform=tf.nn.softplus)
+ chol = distributions.matrix_diag_transform(mat, transform=nn_ops.softplus)
q = distributions.MultivariateNormalCholesky(mu, chol)
for alpha in [0.25, 0.75]:
negative_renyi_divergence = entropy.renyi_ratio(
log_p=target.log_prob, q=q, n=n, alpha=alpha, seed=0)
train_op = get_train_op(
- tf.reduce_mean(-negative_renyi_divergence),
+ math_ops.reduce_mean(-negative_renyi_divergence),
optimizer='SGD',
learning_rate=0.5,
decay=0.1)
- tf.global_variables_initializer().run()
+ variables.global_variables_initializer().run()
renyis = []
for step in range(1000):
sess.run(train_op)
@@ -262,12 +279,12 @@ def test_divergence_between_identical_distributions_is_zero(self):
self.assertAllClose(np.zeros(2), negative_renyi_divergence.eval())
-class RenyiAlphaTest(tf.test.TestCase):
+class RenyiAlphaTest(test.TestCase):
def test_with_three_alphas(self):
with self.test_session():
- for dtype in (tf.float32, tf.float64):
- alpha_min = tf.constant(0.0, dtype=dtype)
+ for dtype in (dtypes.float32, dtypes.float64):
+ alpha_min = constant_op.constant(0.0, dtype=dtype)
alpha_max = 0.5
decay_time = 3
@@ -334,4 +351,4 @@ def test_input_with_wrong_sign_raises(self):
if __name__ == '__main__':
- tf.test.main()
+ test.main()
Oops, something went wrong.

0 comments on commit e121667

Please sign in to comment.