这篇文章主要介绍一下 TensorFlow 中相关的文件 I/O 操作, 我们主要使 tf.gfile 来完成.
- Exists
- tf.gfile.Exists(filename)
用来判断一个路径是否存在, 如果存在符合的文件夹或文件返回 true, 否则返回 false.
- MakeDirs
- tf.gfile.MakeDirs(dirname)
创建一个文件夹路径.
- ListDirectory
- tf.gfile.ListDirectory(dirname)
列出在此目录下的所有子目录 (文件 / 文件夹)
- DeleteRecursively
- tf.gfile.DeleteRecursively(dirname)
循环删除某个文件夹下的所有内容.
其实挺简单的, 感觉就是和 python 的函数差不多, 一些名称有些变化而已啦~~~
官方文档在这里:
https://www.tensorflow.org/api_docs/python/tf/gfile
来源: https://www.cnblogs.com/duwenlu/p/9044020.html