Skip to content

Commit

Permalink
Merge pull request google-research#1 from pichuan/remove_contrib_test…
Browse files Browse the repository at this point in the history
…s_passed

Fix tests.
Merging to shift discussion to one PR at google-research/tf-slim
  • Loading branch information
adrianc-a authored Dec 2, 2019
2 parents 90a8f81 + 3aefcae commit 5f1b1c8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tf_slim/layers/layers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ def testCreateDropoutWithPlaceholder(self):
is_training = array_ops.placeholder(dtype=dtypes.bool, shape=[])
images = random_ops.random_uniform((5, height, width, 3), seed=1)
output = _layers.dropout(images, is_training=is_training)
self.assertEqual(output.op.name, 'Dropout/cond/Merge')
self.assertEqual(output.op.name, 'Dropout/cond/Identity')
output.get_shape().assert_is_compatible_with(images.get_shape())

def testCollectOutputs(self):
Expand Down
4 changes: 2 additions & 2 deletions tf_slim/layers/optimizers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def testGradientNoise(self):
session.run(train, feed_dict={x: 5})
var_value, global_step_value = session.run([var, global_step])
# Due to randomness the following number may change if graph is different.
self.assertAlmostEqual(var_value, 9.86912, 4)
self.assertAlmostEqual(var_value, 10.637937, 4)
self.assertEqual(global_step_value, 1)

def testGradientNoiseWithClipping(self):
Expand All @@ -197,7 +197,7 @@ def testGradientNoiseWithClipping(self):
variables.global_variables_initializer().run()
session.run(train, feed_dict={x: 5})
var_value, global_step_value = session.run([var, global_step])
self.assertAlmostEqual(var_value, 9.86912, 4)
self.assertAlmostEqual(var_value, 10.637937, 4)
self.assertEqual(global_step_value, 1)

def testGradientClip(self):
Expand Down
10 changes: 5 additions & 5 deletions tf_slim/layers/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ def test_constant(self):
self.assertEqual(o.eval(feed_dict={p: v}), expected(v))

def test_variable(self):
fn1 = lambda: variables.Variable('fn1')
fn2 = lambda: variables.Variable('fn2')
expected = lambda v: b'fn1' if v else b'fn2'
p = array_ops.placeholder(dtypes.bool, [])
for v in [True, False, 1, 0]:
o = utils.smart_cond(p, fn1, fn2)
with self.cached_session() as sess:
fn1 = lambda: variables.Variable('fn1')
fn2 = lambda: variables.Variable('fn2')
expected = lambda v: b'fn1' if v else b'fn2'
p = array_ops.placeholder(dtypes.bool, [])
o = utils.smart_cond(p, fn1, fn2)
sess.run(variables.global_variables_initializer())
self.assertEqual(o.eval(feed_dict={p: v}), expected(v))

Expand Down
2 changes: 1 addition & 1 deletion tf_slim/ops/variables_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from tensorflow.python.platform import test
from tensorflow.python.training import device_setter
from tensorflow.python.training import saver as saver_lib
from tensorflow.errors import FailedPreconditionError
from tensorflow.compat.v2.errors import FailedPreconditionError
from unittest import skip

class LocalVariableTest(test.TestCase):
Expand Down

0 comments on commit 5f1b1c8

Please sign in to comment.