tensorflow: Saver can't handle filename only

Hey everyone,

it seems to me like - at least on Windows - the tf saver can’t save model files whose path consists only of the file’s name with no parent path, relative nor absolute. The issue lies at or around saver.py:1363 where it tries to check whether the parent directory of the file is actually a directory. There is no parent directory given (i.e. an empty string) and as such gFile.IsDirectory can’t check anything. It fails and raises a ValueError that the parent directory does not exist.

Expected behavior in my opinion would be that the current working directory is used as the parent path when using no path/just a filename (i.e. a relative path).

Some details about my system specs:

  • Windows 10
  • Python 3.5.2
  • TF 0.12.0 (in a virtual environment; pip install tensorflow --upgrade just executed; issue persists)

So, I’m wondering whether this is an expected behavior and how to deal with it or if it is an actual bug that needs to be addressed.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 25 (14 by maintainers)

Most upvoted comments

I think this isn’t OS-specific, but agree that it’s a bit strange. As a workaround, it might be possible to prepend "./" to the save path, and perhaps we should do that in the cases when os.path.dirname() returns ""?