MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / parse_sequence_example

Function parse_sequence_example

tensorflow/python/ops/parsing_ops.py:1164–1270  ·  view source on GitHub ↗

Parses a batch of `SequenceExample` protos. Parses a vector of serialized [`SequenceExample`](https://www.tensorflow.org/code/tensorflow/core/example/example.proto) protos given in `serialized`. This op parses serialized sequence examples into a tuple of dictionaries, each mapping keys t

(serialized,
                           context_features=None,
                           sequence_features=None,
                           example_names=None,
                           name=None)

Source from the content-addressed store, hash-verified

1162
1163@tf_export("io.parse_sequence_example")
1164def parse_sequence_example(serialized,
1165 context_features=None,
1166 sequence_features=None,
1167 example_names=None,
1168 name=None):
1169 # pylint: disable=line-too-long
1170 """Parses a batch of `SequenceExample` protos.
1171
1172 Parses a vector of serialized
1173 [`SequenceExample`](https://www.tensorflow.org/code/tensorflow/core/example/example.proto)
1174 protos given in `serialized`.
1175
1176 This op parses serialized sequence examples into a tuple of dictionaries,
1177 each mapping keys to `Tensor` and `SparseTensor` objects.
1178 The first dictionary contains mappings for keys appearing in
1179 `context_features`, and the second dictionary contains mappings for keys
1180 appearing in `sequence_features`.
1181
1182 At least one of `context_features` and `sequence_features` must be provided
1183 and non-empty.
1184
1185 The `context_features` keys are associated with a `SequenceExample` as a
1186 whole, independent of time / frame. In contrast, the `sequence_features` keys
1187 provide a way to access variable-length data within the `FeatureList` section
1188 of the `SequenceExample` proto. While the shapes of `context_features` values
1189 are fixed with respect to frame, the frame dimension (the first dimension)
1190 of `sequence_features` values may vary between `SequenceExample` protos,
1191 and even between `feature_list` keys within the same `SequenceExample`.
1192
1193 `context_features` contains `VarLenFeature` and `FixedLenFeature` objects.
1194 Each `VarLenFeature` is mapped to a `SparseTensor`, and each `FixedLenFeature`
1195 is mapped to a `Tensor`, of the specified type, shape, and default value.
1196
1197 `sequence_features` contains `VarLenFeature` and `FixedLenSequenceFeature`
1198 objects. Each `VarLenFeature` is mapped to a `SparseTensor`, and each
1199 `FixedLenSequenceFeature` is mapped to a `Tensor`, each of the specified type.
1200 The shape will be `(B,T,) + df.dense_shape` for `FixedLenSequenceFeature`
1201 `df`, where `B` is the batch size, and `T` is the length of the associated
1202 `FeatureList` in the `SequenceExample`. For instance,
1203 `FixedLenSequenceFeature([])` yields a scalar 2-D `Tensor` of static shape
1204 `[None, None]` and dynamic shape `[B, T]`, while
1205 `FixedLenSequenceFeature([k])` (for `int k >= 1`) yields a 3-D matrix `Tensor`
1206 of static shape `[None, None, k]` and dynamic shape `[B, T, k]`.
1207
1208 Like the input, the resulting output tensors have a batch dimension. This
1209 means that the original per-example shapes of `VarLenFeature`s and
1210 `FixedLenSequenceFeature`s can be lost. To handle that situation, this op also
1211 provides dicts of shape tensors as part of the output. There is one dict for
1212 the context features, and one for the feature_list features. Context features
1213 of type `FixedLenFeature`s will not be present, since their shapes are already
1214 known by the caller. In situations where the input 'FixedLenFeature`s are of
1215 different lengths across examples, the shorter examples will be padded with
1216 default datatype values: 0 for numeric types, and the empty string for string
1217 types.
1218
1219 Each `SparseTensor` corresponding to `sequence_features` represents a ragged
1220 vector. Its indices are `[time, index]`, where `time` is the `FeatureList`
1221 entry and `index` is the value's index in the list of values associated with

Callers

nothing calls this directly

Calls 2

_features_to_raw_paramsFunction · 0.85

Tested by

no test coverage detected