tfm.core.tf_example_builder.TfExampleBuilder

Builder class for preparing tf.train.Example.

Read API doc at https://www.tensorflow.org/api_docs/python/tf/train/Example

>>> example_builder = TfExampleBuilder()
>>> example = (
        example_builder.add_bytes_feature('feature_a', 'foobarbaz')
        .add_ints_feature('feature_b', [1, 2, 3])
        .example)

example Returns a copy of the generated tf.train.Example proto.
serialized_example Returns a serialized string of the generated tf.train.Example proto.

Methods

add_bytes_feature

View source

Adds byte(s) or string(s) with key to the example.

Args
key String key of the feature.
value The byte(s) or string(s) to be added to the example.

Returns
The builder object for subsequent method calls.

add_feature

View source

Adds predefined feature with key to the example.

Args
key String key of the feature.
feature The feature to be added to the example.

Returns
The builder object for subsequent method calls.

add_feature_dict

View source

Adds the predefined feature_dict to the example.

Args
feature_dict A dictionary from tf.Example feature key to tf.train.Feature.

Returns
The builder object for subsequent method calls.

add_floats_feature

View source

Adds float(s) with key to the example.

Args
key String key of the feature.
value The float(s) to be added to the example.

Returns
The builder object for subsequent method calls.

add_ints_feature

View source

Adds integer(s) with key to the example.

Args
key String key of the feature.
value The integer(s) to be added to the example.

Returns
The builder object for subsequent method calls.

reset

View source

Resets the example to an empty proto.

set

View source

Sets the example.