Defining a tf.data.Dataset
Learn to create the TensorFlow data pipeline.
Helper functions
Now, let’s look at how we can create a tf.data.Dataset
using the data. We’ll first write a few helper functions. Namely, we’ll define:
parse_image()
to load and process an image from afilepath
.generate_tokenizer()
to generate a tokenizer trained on the data passed to the function.
The parse_image()
function
First, let’s discuss the parse_image()
function. It takes three arguments:
filepath
: Location of the imageresize_height
: Height to resize the image toresize_width
: Width to resize the image to
The function is defined as follows:
Get hands-on with 1400+ tech skills courses.