TFRecords Dataset

Create a TFRecords dataset configured specifically for the project's dataset.

Chapter Goals:

  • Create a TFRecords dataset for the input pipeline

A. Dataset from TFRecords file

After setting up the Example spec and feature parsing functions, we’re finally ready to create TensorFlow datasets from the TFRecords files for both training and evaluation.

Press + to interact
import tensorflow as tf
train_file = 'train.tfrecords'
eval_file = 'eval.tfrecords'
train_dataset = tf.data.TFRecordDataset(train_file)
eval_dataset = tf.data.TFRecordDataset(eval_file)

The TFRecords datasets contain serialized Example objects. Using the Example spec and feature parsing functions, we can convert each serialized Example to a tuple ...