Builder class for preparing tf.train.Example.
tfm . core . tf_example_builder . TfExampleBuilder () -> None
Read API doc at https://www.tensorflow.org/api_docs/python/tf/train/Example
Example usage
>>> example_builder = TfExampleBuilder ()
>>> example = (
example_builder . add_bytes_feature ( 'feature_a' , 'foobarbaz' )
. add_ints_feature ( 'feature_b' , [ 1 , 2 , 3 ])
. example )
Attributes
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
add_bytes_feature (
key : str , value : BytesValueType
) -> TfExampleBuilder
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
add_feature (
key : str , feature : tf . train . Feature
) -> TfExampleBuilder
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
add_feature_dict (
feature_dict : Mapping [ str , tf . train . Feature ]
) -> TfExampleBuilder
Adds the predefined feature_dict
to the example.
Note: Please prefer to using feature-type-specific methods.
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
add_floats_feature (
key : str , value : Union [ float , Sequence [ float ]]
) -> TfExampleBuilder
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
add_ints_feature (
key : str , value : Union [ int , Sequence [ int ]]
) -> TfExampleBuilder
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
reset () -> TfExampleBuilder
Resets the example to an empty proto.
set
View source
set (
example : tf . train . Example
) -> TfExampleBuilder
Sets the example.