This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movie_name_list = tf.train.BytesList(value=[b'The Shawshank Redemption', b'Fight Club']) | |
| movie_rating_list = tf.train.FloatList(value=[9.0, 9.7]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movie_names = tf.train.Feature(bytes_list=movie_name_list) | |
| movie_ratings = tf.train.Feature(float_list=movie_rating_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movie_dict = { | |
| 'Movie Names': movie_names, | |
| 'Movie Ratings': movie_ratings | |
| } | |
| movies = tf.train.Features(feature=movie_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| example = tf.train.Example(features=movies) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movie_1_actors = tf.train.Feature( | |
| bytes_list=tf.train.BytesList( | |
| value=[b'Tim Robbins', b'Morgan Freeman'])) | |
| movie_2_actors = tf.train.Feature( | |
| bytes_list=tf.train.BytesList( | |
| value=[b'Brad Pitt', b'Edward Norton', b'Helena Bonham Carter'])) | |
| movie_actors_list = [movie_1_actors, movie_2_actors] | |
| movie_actors = tf.train.FeatureList(feature=movie_actors_list) | |
| # Short form |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movies_dict = { | |
| 'Movie Names': movie_names, | |
| 'Movie Ratings': movie_ratings, | |
| 'Movie Actors': movie_actors | |
| } | |
| movies = tf.train.FeatureLists(feature_list=movies_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # We can also add context features (short form) | |
| customer = tf.train.Features(feature={ | |
| 'Age': tf.train.Feature(int64_list=tf.train.Int64List(value=[19])), | |
| }) | |
| example = tf.train.SequenceExample( | |
| context=customer, | |
| feature_lists=movies) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # "example" is of type tf.train.Example. | |
| with tf.python_io.TFRecordWriter('movie_ratings.tfrecord') as writer: | |
| writer.write(example.SerializeToString()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer