[null,null,["Last updated 2024-02-02 UTC."],[],[],null,["# tfm.core.tf_example_builder.TfExampleBuilder\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L32-L144) |\n\nBuilder class for preparing tf.train.Example. \n\n tfm.core.tf_example_builder.TfExampleBuilder() -\u003e None\n\nRead API doc at \u003chttps://www.tensorflow.org/api_docs/python/tf/train/Example\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Example usage ------------- ||\n|---|---|\n| \u003cbr /\u003e \u003e\u003e\u003e example_builder = TfExampleBuilder() \u003e\u003e\u003e example = ( example_builder.add_bytes_feature('feature_a', 'foobarbaz') .add_ints_feature('feature_b', [1, 2, 3]) .example) \u003cbr /\u003e ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|----------------------|----------------------------------------------------------------------|\n| `example` | Returns a copy of the generated tf.train.Example proto. |\n| `serialized_example` | Returns a serialized string of the generated tf.train.Example proto. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `add_bytes_feature`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L100-L114) \n\n add_bytes_feature(\n key: str, value: BytesValueType\n ) -\u003e TfExampleBuilder\n\nAdds byte(s) or string(s) with `key` to the example.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|------------------------------------------------------|\n| `key` | String key of the feature. |\n| `value` | The byte(s) or string(s) to be added to the example. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The builder object for subsequent method calls. ||\n\n\u003cbr /\u003e\n\n### `add_feature`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L86-L98) \n\n add_feature(\n key: str, feature: tf.train.Feature\n ) -\u003e TfExampleBuilder\n\nAdds predefined `feature` with `key` to the example.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|-----------------------------------------|\n| `key` | String key of the feature. |\n| `feature` | The feature to be added to the example. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The builder object for subsequent method calls. ||\n\n\u003cbr /\u003e\n\n### `add_feature_dict`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L69-L84) \n\n add_feature_dict(\n feature_dict: Mapping[str, tf.train.Feature]\n ) -\u003e TfExampleBuilder\n\nAdds the predefined `feature_dict` to the example.\n| **Note:** Please prefer to using feature-type-specific methods.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------|---------------------------------------------------------------|\n| `feature_dict` | A dictionary from tf.Example feature key to tf.train.Feature. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The builder object for subsequent method calls. ||\n\n\u003cbr /\u003e\n\n### `add_floats_feature`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L131-L144) \n\n add_floats_feature(\n key: str, value: Union[float, Sequence[float]]\n ) -\u003e TfExampleBuilder\n\nAdds float(s) with `key` to the example.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|------------------------------------------|\n| `key` | String key of the feature. |\n| `value` | The float(s) to be added to the example. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The builder object for subsequent method calls. ||\n\n\u003cbr /\u003e\n\n### `add_ints_feature`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L116-L129) \n\n add_ints_feature(\n key: str, value: Union[int, Sequence[int]]\n ) -\u003e TfExampleBuilder\n\nAdds integer(s) with `key` to the example.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|--------------------------------------------|\n| `key` | String key of the feature. |\n| `value` | The integer(s) to be added to the example. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The builder object for subsequent method calls. ||\n\n\u003cbr /\u003e\n\n### `reset`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L63-L66) \n\n reset() -\u003e TfExampleBuilder\n\nResets the example to an empty proto.\n\n### `set`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/tf_example_builder.py#L58-L61) \n\n set(\n example: tf.train.Example\n ) -\u003e TfExampleBuilder\n\nSets the example."]]