tf.io.parse_single_example
Stay organized with collections
Save and categorize content based on your preferences.
Parses a single Example
proto.
tf.io.parse_single_example(
serialized, features, example_names=None, name=None
)
Used in the notebooks
Similar to parse_example
, except:
For dense tensors, the returned Tensor
is identical to the output of
parse_example
, except there is no batch dimension, the output shape is the
same as the shape given in dense_shape
.
For SparseTensor
s, the first (batch) column of the indices matrix is removed
(the indices matrix is a column vector), the values vector is unchanged, and
the first (batch_size
) entry of the shape vector is removed (it is now a
single element vector).
One might see performance advantages by batching Example
protos with
parse_example
instead of using this function directly.
Args |
serialized
|
A scalar string Tensor, a single serialized Example.
|
features
|
A mapping of feature keys to FixedLenFeature or
VarLenFeature values.
|
example_names
|
(Optional) A scalar string Tensor, the associated name.
|
name
|
A name for this operation (optional).
|
Returns |
A dict mapping feature keys to Tensor and SparseTensor values.
|
Raises |
ValueError
|
if any feature is invalid.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.io.parse_single_example\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/parsing_ops.py#L405-L444) |\n\nParses a single `Example` proto. \n\n tf.io.parse_single_example(\n serialized, features, example_names=None, name=None\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [TFRecord and tf.train.Example](https://www.tensorflow.org/tutorials/load_data/tfrecord) - [Introduction to Fairness Indicators](https://www.tensorflow.org/responsible_ai/fairness_indicators/tutorials/Fairness_Indicators_Example_Colab) - [Graph regularization for sentiment classification using synthesized graphs](https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_lstm_imdb) - [Graph regularization for document classification using natural graphs](https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_mlp_cora) - [Recommending movies: retrieval using a sequential model](https://www.tensorflow.org/recommenders/examples/sequential_retrieval) |\n\nSimilar to `parse_example`, except:\n\nFor dense tensors, the returned `Tensor` is identical to the output of\n`parse_example`, except there is no batch dimension, the output shape is the\nsame as the shape given in `dense_shape`.\n\nFor `SparseTensor`s, the first (batch) column of the indices matrix is removed\n(the indices matrix is a column vector), the values vector is unchanged, and\nthe first (`batch_size`) entry of the shape vector is removed (it is now a\nsingle element vector).\n\nOne might see performance advantages by batching `Example` protos with\n`parse_example` instead of using this function directly.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|---------------------------------------------------------------------------|\n| `serialized` | A scalar string Tensor, a single serialized Example. |\n| `features` | A mapping of feature keys to `FixedLenFeature` or `VarLenFeature` values. |\n| `example_names` | (Optional) A scalar string Tensor, the associated name. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `dict` mapping feature keys to `Tensor` and `SparseTensor` values. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------|\n| `ValueError` | if any feature is invalid. |\n\n\u003cbr /\u003e"]]