codecamp

TensorFlow函数:解析SequenceExample原型

tf.parse_single_sequence_example 函数

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 原型.

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

context_features 和 sequence_features 中必须提供一个并且不为空.

这些 context_features 键和 SequenceExample 作为一个整体,独立于时间/框架.相比之下,这些 sequence_features 键提供了访问 SequenceExample 原型的 FeatureList 部分内的可变长度数据的方法.虽然 context_features 值的形状是相对于框架固定的,但 sequence_features 值的框架维度(第一维度)可能在SequenceExample 原型之间变化,甚至在具有相同的 SequenceExample 的 feature_list 键之间变化.

context_features 包含 VarLenFeature 和 FixedLenFeature 对象.每个 VarLenFeature 映射到一个 SparseTensor,并且每个 FixedLenFeature 被映射到 Tensor,具有指定的类型、形状和默认值.

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

每个 SparseTensor 对应 sequence_features 代表一个不齐整的向量.它的索引是 [time, index],其中 time 是 FeatureList 条目,并且 index 是与 time 相关的值列表中的值的索引.

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

example_name 可能包含相应序列化原型的描述性名称.这可能对调试有用,但对输出没有影响.如果值不是 None,example_name 一定是一个标量.

参数:

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

返回:

两个 dicts 的元组,每个将键映射到 Tensors 和 SparseTensors;第一个字典包含上下文键/值,第二个字典包含 feature_list 键/值.

可能引发的异常:

  • ValueError:如果有任何功能是无效的.
TensorFlow函数:tf.parse_example
TensorFlow占位符操作:tf.placeholder_with_default
温馨提示
下载编程狮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; }