TensorFlow函数教程:tf.io.parse_single_sequence_example

2019-02-22 16:15 更新

tf.io.parse_single_sequence_example函数

别名:

  • tf.io.parse_single_sequence_example
  • tf.parse_single_sequence_example
tf.io.parse_single_sequence_example(
    serialized,
    context_features=None,
    sequence_features=None,
    example_name=None,
    name=None
)

定义在:tensorflow/python/ops/parsing_ops.py。

解析一个SequenceExample原型。

解析serialized中给定的一个序列化的SequenceExample。

此操作将序列化序列示例解析为字典元组,分别映射键到Tensor和SparseTensor对象。第一个字典包含出现在context_features中的键的映射,第二个字典包含出现在sequence_features中的键的映射。

context_features和sequence_features中至少有一个要提供且非空。

context_features键与SequenceExample作为一个整体相关联,与时间/帧无关。相反,sequence_features键提供了一种在SequenceExample原型的FeatureList部分中访问可变长度数据的方法。虽然context_features值的shape相对于帧是固定的,但是sequence_features值的帧维度(第一维)可以在SequenceExample protos之间变化,甚至可以在同一SequenceExample内的feature_list键之间变化。

context_features包含VarLenFeature和FixedLenFeature对象。每个VarLenFeature都映射到一个SparseTensor,并且每个FixedLenFeature映射到Tensor,它具有指定类型,shape和默认值。

sequence_features包含VarLenFeature和FixedLenSequenceFeature对象。每个VarLenFeature都映射到SparseTensor,并且每个FixedLenSequenceFeature映射到Tensor,每个都具有指定的类型。对于FixedLenSequenceFeature df,shape将是(T,) + df.dense_shape为FixedLenSequenceFeature df,其中T是SequenceExample中关联的FeatureList的长度。例如,FixedLenSequenceFeature([])产生静态shape [None]和动态shape [T]的标量1-DTensor,而FixedLenSequenceFeature([k])(for int k >= 1)产生静态shape [None, k]和动态shape [T, k]的2-D矩阵Tensor。

每个SparseTensor对应的sequence_features代表一个参差不齐的矢量。它的索引是[time, index],其中time是FeatureList条目,index是与该时间关联的值列表中的值索引。

带有default_value的FixedLenFeature条目和带有allow_missing=True的FixedLenSequenceFeature条目是可选的;否则,如果serialized中的任何示例中缺少Feature或FeatureList,我们将失败。

example_name可能包含相应序列化原型的描述性名称。这可能对调试有用,但它对输出没有影响。如果不是None,则example_name必须是标量。

参数:

  • serialized:字符串类型的标量(0-D Tensor),单个二进制序列化SequenceExample原型。
  • context_features:dict映射功能键到FixedLenFeature或VarLenFeature值。这些功能与SequenceExample作为一个整体相关。
  • sequence_features:dict映射功能键到FixedLenSequenceFeature或VarLenFeature值。这些功能与SequenceExample原型的FeatureList部分中的数据相关联。
  • example_name:字符串的标量(0-D Tensor)(可选),序列化原型的名称。
  • name:此操作的名称(可选)。

返回:

两个dicts的元组,每个都映射到Tensors和SparseTensors的键。 第一个dict包含上下文键/值。 第二个dict包含feature_list键/值。

可能引发的异常:

  • ValueError:如果任何功能无效。


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy