2017-09-14 44 views
1

关于Tensorflow的一个简短问题。Tensorflow:tf.gfile.Exist和Env :: FileExists返回True,空文件名

为什么当文件名为空字符串时,tf.gfile.Exist和Env :: FileExists方法的返回值为true?

import tensorflow as tf 
print(tf.gfile.Exists("not_existing_file")) # False 
print(tf.gfile.Exists("")) # True 

cpp方法显示与python方法相同的行为。

auto env = tensorflow::Env::Default(); 
std::cout << env->FileExists("not_existing_file"); # False 
std::cout << env->FileExists(""); # OK 

回答

0

它解析为当前目录:

>>> tf.gfile.Exists("") 
True 
>>> tf.gfile.Exists(".") 
True 
>>> tf.gfile.IsDirectory(".") 
True 
>>> tf.gfile.IsDirectory("") 
True 
>>> tf.gfile.ListDirectory("") 
['lib', 'local', 'pip-selfcheck.json', 'tensorflow-1.3.0-cp27-none-linux_x86_64.whl', 'bin', 'include'] 
>>> tf.gfile.ListDirectory(".") 
['lib', 'local', 'pip-selfcheck.json', 'tensorflow-1.3.0-cp27-none-linux_x86_64.whl', 'bin', 'include']