codecamp

TensorFlow如何使用GFile类

函数:tf.gfile.GFile

GFile 类

GFile 类还可以称为:

  • 类 tf.gfile.GFile
  • 类 tf.gfile.Open

定义在:tensorflow/python/platform/gfile.py

GFile 类用来表示没有线程锁定的文件I / O包装器.

函数属性

  • mode
    返回文件打开的模式.
  • name
    返回文件名.

函数方法

  • __init__
    __init__ (  
        name ,  
        mode = 'r' 
    )
  • __enter__
    __enter__ ()

    使用“with”语句.

  • __exit__
    __exit__ (  
        unused_type ,  
        unused_value ,
        unused_traceback
    )

    使用“with”语句.

  • __iter__
    __iter__ ()
  • __next__
    __next__ ()
  • close
    close()

    关闭 FileIO ;应该调用 WritableFile 来进行刷新.

  • flush
    flush()

    刷新可写文件.

    这只能确保数据已经脱离了进程,而不保证它是否写入磁盘.这意味着数据可以在应用程序崩溃时幸存下来,但不一定是操作系统崩溃.

  • next
    next()
  • read
    read(n=-1)

    以字符串形式返回文件的内容.

    从文件中的当前位置开始读取.

    read 方法的参数:

    • n:如果 n!= -1,则读取 'n' 字节,如果 n = -1,则读取到文件末尾.

    返回值: 

    在字符串 (常规) 模式下,以字节模式或字符串的 "n" 字节表示的文件 (或整个文件) 的 "n" 字节.

  • readline
    readline()

    从文件中读取下一行.在结尾处留下'\ n'.

  • readlines
    readlines()

    返回列表中文件的所有行.

  • size
    size()

    返回文件的大小.

  • tell
    tell()

    返回文件中的当前位置.

  • write
    write(file_content)

    将 file_content 写入文件;附加到文件的末尾.


文件I/O包装器
TensorFlow返回模式匹配文件列表
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }