tf.python_io

目录

Classes

Functions

tf.io.TFRecordCompressionType

Class TFRecordCompressionType

Class Members

Class TFRecordOptions

__init__

Methods

get_compression_type_string

Class Members

TFRecordWriter

tf.io.tf_record_iterator


Python functions for directly manipulating TFRecord-formatted files.

Classes

Functions

tf.io.TFRecordCompressionType

Class TFRecordCompressionType

The type of compression for the record.

Aliases:

Class Members

  • GZIP = 2
  • NONE = 0
  • ZLIB = 1

Class TFRecordOptions

Options used for manipulating TFRecord files.

Aliases:

__init__

View source

__init__(
    compression_type=None,
    flush_mode=None,
    input_buffer_size=None,
    output_buffer_size=None,
    window_bits=None,
    compression_level=None,
    compression_method=None,
    mem_level=None,
    compression_strategy=None
)

Creates a TFRecordOptions instance.

Options only effect TFRecordWriter when compression_type is not None. Documentation, details, and defaults can be found in zlib_compression_options.h and in the zlib manual. Leaving an option as None allows C++ to set a reasonable default.

Args:

  • compression_type: "GZIP", "ZLIB", or "" (no compression).
  • flush_mode: flush mode or None, Default: Z_NO_FLUSH.
  • input_buffer_size: int or None.
  • output_buffer_size: int or None.
  • window_bits: int or None.
  • compression_level: 0 to 9, or None.
  • compression_method: compression method or None.
  • mem_level: 1 to 9, or None.
  • compression_strategy: strategy or None. Default: Z_DEFAULT_STRATEGY.

Returns:

  • A TFRecordOptions object.

Raises:

  • ValueError: If compression_type is invalid.

Methods

get_compression_type_string

View source

@classmethod
get_compression_type_string(
    cls,
    options
)

Convert various option types to a unified string.

Args:

  • options: TFRecordOption, TFRecordCompressionType, or string.

Returns:

  • Compression type as string (e.g. 'ZLIB', 'GZIP', or '').

Raises:

  • ValueError: If compression_type is invalid.

Class Members

  • compression_type_map

TFRecordWriter

将记录写入TFRecords文件的类。这个类实现了_enter__和_exit__,可以像普通文件一样与块一起使用。

方法:

__init__

__init__(
    path,
    options=None
)

打开文件路径并创建一个TFRecordWriter写入文件。 

参数:

  • path:  TFRecords文件的路径。
  • options:  (可选)TFRecordOptions对象。

可能产生的异常:

  • IOError: If path cannot be opened for writing.

__enter__

__enter__()

输入一个block。

__exit__

__exit__(
    unused_type,
    unused_value,
    unused_traceback
)

退出bloack,关闭文件。

close

close()

flush

flush()

刷新文件。

write

write(record)

向文件中写入字符串记录。 

参数:

  • record:  str

tf.io.tf_record_iterator

An iterator that read the records from a TFRecords file. (deprecated)

Aliases:

tf.io.tf_record_iterator(
    path,
    options=None
)

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use eager execution and: tf.data.TFRecordDataset(path)

Args:

  • path: The path to the TFRecords file.
  • options: (optional) A TFRecordOptions object.

Yields:

  • Strings.

Raises:

  • IOError: If path cannot be opened for reading.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Wanderer001

ROIAlign原理

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值