TensorFlow---基础---GFile

  使用TensorFlow的时候经常遇到 tf.gfile.exists()....

  关于gfile,一个googler是这样给出的解释:

The main roles of the tf.gfile module are:

  1. To provide an API that is close to Python's file objects, and

  2. To provide an implementation based on TensorFlow's C++ FileSystem API.

The C++ FileSystem API supports multiple file system implementations, including local files, Google Cloud Storage (using a gs:// prefix), and HDFS (using an hdfs:// prefix). TensorFlow exports these as tf.gfile so that you can uses these implementations for saving and loading checkpoints, writing TensorBoard logs, and accessing training data (among other uses). However, if all of your files are local, you can use the regular Python file API without any problem.

   大概意思是:

    1. 提供了一个处理Python文件类型的API

    2. 提供了一种基于TensorFlow的C++文件系统的API实现

   总之,就是为了更好的可扩展性(C++文件系统API支持多种文件系统的实现,比如本地文件,谷歌云、HDFS)。所以不管你底层是以上的那种文件系统,都是用gfile来进行文件操作就ok了! 当然如果你只是单机本地跑的话,那么直接使用普通的py下 file-API也是ok的!

原文地址:https://www.cnblogs.com/luntai/p/6748877.html