Here, you can see that we are constructing a series of data augmentation operations, including: Preprocessing.RandomFlip("horizontal_and_vertical"), This method is best explained via code: trainAug = Sequential([ We typically call this method “layers data augmentation” due to the fact that the Sequential class we use for data augmentation is the same class we use for implementing sequential neural networks (e.g., LeNet, VGGNet, AlexNet). Incorporating data augmentation into a tf.data pipeline is most easily achieved by using TensorFlow’s preprocessing module and the Sequential class.
To learn how to perform data augmentation with tf.data, just keep reading.įigure 1: TensorFlow’s “Sequential” class is often used to build neural networks, but can also be used for building data augmentation pipelines ( image source). Inside this tutorial, you’ll learn how to use both data augmentation procedures with tf.data. The second method is slightly more complex (typically because you need to read the TensorFlow documentation to find the exact functions you need), but allows for more fine-grained control over the data augmentation process. The first method is much easier and requires less effort. Apply tf.image functions to manually create the data augmentation routine.Use the Sequential class and the preprocessing module to build a series of data augmentation operations, similar to Keras’ ImageDataGenerator class.TensorFlow provides us with two methods we can use to apply data augmentation to our tf.data pipelines: By applying data augmentation we can increase the ability of our model to generalize and make better, more accurate predictions on data it was not trained on. How can we apply data augmentation inside a tf.data pipeline?ĭata augmentation is a critical aspect of training neural networks that are to be deployed in real-world scenarios. However, one question we haven’t discussed is: Once built, these pipelines can train your neural networks significantly faster than using standard methods. Throughout this series we’ve discovered how fast and efficient the tf.data module is for building data processing pipelines. Data augmentation with tf.data (today’s tutorial).Data pipelines with tf.data and TensorFlow.This tutorial is part in our three part series on the tf.data module: