提交 49684837 编写于 作者: G Gunhan Gulsoy 提交者: TensorFlower Gardener

Fix race conditions in tests due to using same folders for saver.

Change: 137881303
上级 ce92434f
......@@ -21,6 +21,7 @@ from __future__ import print_function
import itertools
import os
import tempfile
import numpy as np
import tensorflow as tf
......@@ -609,7 +610,10 @@ class FeatureColumnTest(tf.test.TestCase):
{embedding_col: input_tensor}, [embedding_col])
save = tf.train.Saver()
checkpoint_path = os.path.join(self.get_temp_dir(), "model.ckpt")
ckpt_dir_prefix = os.path.join(
self.get_temp_dir(), "init_embedding_col_w_from_ckpt")
ckpt_dir = tempfile.mkdtemp(prefix=ckpt_dir_prefix)
checkpoint_path = os.path.join(ckpt_dir, "model.ckpt")
with self.test_session() as sess:
sess.run(tf.initialize_all_variables())
......@@ -670,7 +674,10 @@ class FeatureColumnTest(tf.test.TestCase):
assign_op = tf.assign(weight[0], weight[0] + 0.5)
save = tf.train.Saver()
checkpoint_path = os.path.join(self.get_temp_dir(), "model.ckpt")
ckpt_dir_prefix = os.path.join(
self.get_temp_dir(), "init_crossed_col_w_from_ckpt")
ckpt_dir = tempfile.mkdtemp(prefix=ckpt_dir_prefix)
checkpoint_path = os.path.join(ckpt_dir, "model.ckpt")
with self.test_session() as sess:
sess.run(tf.initialize_all_variables())
......
......@@ -18,6 +18,7 @@ from __future__ import division
from __future__ import print_function
import os
import tempfile
import numpy as np
import six
import tensorflow as tf
......@@ -296,7 +297,8 @@ class MutableHashTableOpTest(tf.test.TestCase):
self.assertAllEqual([0, 1, 2], sorted_values)
def testSaveRestore(self):
save_path = os.path.join(self.get_temp_dir(), "hash")
save_dir = os.path.join(self.get_temp_dir(), "save_restore")
save_path = os.path.join(tempfile.mkdtemp(prefix=save_dir), "hash")
with self.test_session(graph=tf.Graph()) as sess:
v0 = tf.Variable(10.0, name="v0")
......@@ -867,7 +869,8 @@ class MutableDenseHashTableOpTest(tf.test.TestCase):
[100, 0], [100, 0], [100, 0]], pairs)
def testSaveRestore(self):
save_path = os.path.join(self.get_temp_dir(), "hash")
save_dir = os.path.join(self.get_temp_dir(), "save_restore")
save_path = os.path.join(tempfile.mkdtemp(prefix=save_dir), "hash")
with self.test_session(graph=tf.Graph()) as sess:
default_value = -1
......@@ -922,7 +925,8 @@ class MutableDenseHashTableOpTest(tf.test.TestCase):
self.assertAllEqual([-1, 0, 1, 2, -1], output.eval())
def testVectorSaveRestore(self):
save_path = os.path.join(self.get_temp_dir(), "hash")
save_dir = os.path.join(self.get_temp_dir(), "vector_save_restore")
save_path = os.path.join(tempfile.mkdtemp(prefix=save_dir), "hash")
with self.test_session(graph=tf.Graph()) as sess:
empty_key = tf.constant([11, 13], tf.int64)
......
......@@ -18,6 +18,7 @@ from __future__ import division
from __future__ import print_function
import os.path
import tempfile
import six
import tensorflow as tf
......@@ -40,7 +41,9 @@ class MovingAverageOptimizerTest(tf.test.TestCase):
tf.train.GradientDescentOptimizer(learning_rate=2.0),
average_decay=0.5,
sequential_update=sequential_update)
save_path = os.path.join(self.get_temp_dir(), 'model')
save_dir = tempfile.mkdtemp(
prefix=os.path.join(self.get_temp_dir(), 'run_1'))
save_path = os.path.join(save_dir, 'model')
update = opt.apply_gradients(
list(six.moves.zip([grads0, grads1], [var0, var1])))
train_saver = opt.swapping_saver()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册