Skip to content

Commit 828d76f

Browse files
jhseurmlarsen
authored andcommitted
Revert "Added absolute path expansion of parent directory check in saver.py, …" (tensorflow#7168)
1 parent 87c7c90 commit 828d76f

File tree

2 files changed

+2
-47
lines changed

2 files changed

+2
-47
lines changed

tensorflow/python/training/saver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ def save(self,
13761376
"'latest_filename' collides with 'save_path': '%s' and '%s'" %
13771377
(latest_filename, save_path))
13781378

1379-
if not gfile.IsDirectory(os.path.dirname(os.path.abspath(save_path))):
1379+
if not gfile.IsDirectory(os.path.dirname(save_path)):
13801380
raise ValueError(
13811381
"Parent directory of {} doesn't exist, can't save.".format(save_path))
13821382

@@ -1453,7 +1453,7 @@ def restore(self, sess, save_path):
14531453
return
14541454
logging.info("Restoring parameters from %s", save_path)
14551455
sess.run(self.saver_def.restore_op_name,
1456-
{self.saver_def.filename_tensor_name: os.path.abspath(save_path)})
1456+
{self.saver_def.filename_tensor_name: save_path})
14571457

14581458
@staticmethod
14591459
def _add_collection_def(meta_graph_def, key, export_scope=None):

tensorflow/python/training/saver_test.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -565,51 +565,6 @@ def testSaveToNonexistingPath(self):
565565
):
566566
save.save(sess, save_path)
567567

568-
def testSaveToCurrentDirectory(self):
569-
570-
temp_dir = self.get_temp_dir()
571-
572-
# Store original current dir for later recovery, set current dir to temp_dir
573-
old_current_dir = os.getcwd()
574-
os.chdir(temp_dir)
575-
576-
try:
577-
578-
# Save to current directory, no ./ prepended to path name
579-
save_path = "variables"
580-
581-
with session.Session("", graph=ops_lib.Graph()) as sess:
582-
583-
one = variables.Variable(1.0)
584-
twos = variables.Variable([2.0, 2.0, 2.0])
585-
586-
init = variables.global_variables_initializer()
587-
save = saver_module.Saver()
588-
589-
init.run()
590-
save.save(sess, save_path)
591-
592-
with session.Session("", graph=ops_lib.Graph()) as sess:
593-
594-
one = variables.Variable(0.0)
595-
twos = variables.Variable([0.0, 0.0, 0.0])
596-
597-
# Saver with no arg, defaults to 'all variables'.
598-
save = saver_module.Saver()
599-
save.restore(sess, save_path)
600-
601-
self.assertAllClose(1.0, one.eval())
602-
self.assertAllClose([2.0, 2.0, 2.0], twos.eval())
603-
604-
# Go back to original current dir
605-
os.chdir(old_current_dir)
606-
607-
except Exception as exception:
608-
609-
# Go back to original current dir and then bubble up the exception
610-
os.chdir(old_current_dir)
611-
raise exception
612-
613568

614569
class SaveRestoreShardedTest(test.TestCase):
615570

0 commit comments

Comments
 (0)