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

Function parse_single_sequence_example

tensorflow/python/ops/parsing_ops.py:1513–1610  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

1511 v1=["io.parse_single_sequence_example",
1512 "parse_single_sequence_example"])
1513def parse_single_sequence_example(
1514 serialized, context_features=None, sequence_features=None,
1515 example_name=None, name=None):
1516 # pylint: disable=line-too-long
1517 """Parses a single `SequenceExample` proto.
1518
1519 Parses a single serialized [`SequenceExample`](https://www.tensorflow.org/code/tensorflow/core/example/example.proto)
1520 proto given in `serialized`.
1521
1522 This op parses a serialized sequence example into a tuple of dictionaries,
1523 each mapping keys to `Tensor` and `SparseTensor` objects.
1524 The first dictionary contains mappings for keys appearing in
1525 `context_features`, and the second dictionary contains mappings for keys
1526 appearing in `sequence_features`.
1527
1528 At least one of `context_features` and `sequence_features` must be provided
1529 and non-empty.
1530
1531 The `context_features` keys are associated with a `SequenceExample` as a
1532 whole, independent of time / frame. In contrast, the `sequence_features` keys
1533 provide a way to access variable-length data within the `FeatureList` section
1534 of the `SequenceExample` proto. While the shapes of `context_features` values
1535 are fixed with respect to frame, the frame dimension (the first dimension)
1536 of `sequence_features` values may vary between `SequenceExample` protos,
1537 and even between `feature_list` keys within the same `SequenceExample`.
1538
1539 `context_features` contains `VarLenFeature` and `FixedLenFeature` objects.
1540 Each `VarLenFeature` is mapped to a `SparseTensor`, and each `FixedLenFeature`
1541 is mapped to a `Tensor`, of the specified type, shape, and default value.
1542
1543 `sequence_features` contains `VarLenFeature` and `FixedLenSequenceFeature`
1544 objects. Each `VarLenFeature` is mapped to a `SparseTensor`, and each
1545 `FixedLenSequenceFeature` is mapped to a `Tensor`, each of the specified type.
1546 The shape will be `(T,) + df.dense_shape` for `FixedLenSequenceFeature` `df`, where
1547 `T` is the length of the associated `FeatureList` in the `SequenceExample`.
1548 For instance, `FixedLenSequenceFeature([])` yields a scalar 1-D `Tensor` of
1549 static shape `[None]` and dynamic shape `[T]`, while
1550 `FixedLenSequenceFeature([k])` (for `int k >= 1`) yields a 2-D matrix `Tensor`
1551 of static shape `[None, k]` and dynamic shape `[T, k]`.
1552
1553 Each `SparseTensor` corresponding to `sequence_features` represents a ragged
1554 vector. Its indices are `[time, index]`, where `time` is the `FeatureList`
1555 entry and `index` is the value's index in the list of values associated with
1556 that time.
1557
1558 `FixedLenFeature` entries with a `default_value` and `FixedLenSequenceFeature`
1559 entries with `allow_missing=True` are optional; otherwise, we will fail if
1560 that `Feature` or `FeatureList` is missing from any example in `serialized`.
1561
1562 `example_name` may contain a descriptive name for the corresponding serialized
1563 proto. This may be useful for debugging purposes, but it has no effect on the
1564 output. If not `None`, `example_name` must be a scalar.
1565
1566 Note that the batch version of this function, `tf.parse_sequence_example`,
1567 is written for better memory efficiency and will be faster on large
1568 `SequenceExample`s.
1569
1570 Args:

Callers

nothing calls this directly

Calls 2

_features_to_raw_paramsFunction · 0.85

Tested by

no test coverage detected