tfds.decode.make_decoder
Stay organized with collections
Save and categorize content based on your preferences.
Decorator to create a decoder.
tfds.decode.make_decoder(
output_dtype=None
)
The decorated function should have the signature (example, feature, *args,
**kwargs) -> decoded_example
.
example
: Serialized example before decoding
feature
: FeatureConnector
associated with the example
*args, **kwargs
: Optional additional kwargs forwarded to the function
Example:
@tfds.decode.make_decoder(output_dtype=tf.string)
def no_op_decoder(example, feature):
"""Decoder simply decoding feature normally."""
return feature.decode_example(example)
tfds.load('mnist', split='train', decoders: {
'image': no_op_decoder(),
})
Args |
output_dtype
|
The output dtype after decoding. Required only if the decoded
example has a different type than the FeatureConnector.dtype and is used
to decode features inside sequences (ex: videos)
|
Returns |
The decoder object
|
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.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tfds.decode.make_decoder\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/decode/base.py#L161-L200) |\n\nDecorator to create a decoder. \n\n tfds.decode.make_decoder(\n output_dtype=None\n )\n\nThe decorated function should have the signature `(example, feature, *args,\n**kwargs) -\u003e decoded_example`.\n\n- `example`: Serialized example before decoding\n- `feature`: `FeatureConnector` associated with the example\n- `*args, **kwargs`: Optional additional kwargs forwarded to the function\n\n#### Example:\n\n @tfds.decode.make_decoder(output_dtype=tf.string)\n def no_op_decoder(example, feature):\n \"\"\"Decoder simply decoding feature normally.\"\"\"\n return feature.decode_example(example)\n\n tfds.load('mnist', split='train', decoders: {\n 'image': no_op_decoder(),\n })\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `output_dtype` | The output dtype after decoding. Required only if the decoded example has a different type than the [`FeatureConnector.dtype`](../../tfds/features/FeatureConnector#dtype) and is used to decode features inside sequences (ex: videos) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The decoder object ||\n\n\u003cbr /\u003e"]]