Model training

Let's kick off the training process by creating a session variable that will be responsible for executing the computational graph that we defined earlier:

session = tf.Session()

Also, we need to initialize the variables that we have defined so far:

session.run(tf.global_variables_initializer())

We are going to feed the images in batches to avoid an out-of-memory error:

train_batch_size = 64

Before kicking the training process, we are going to define a helper function that will perform the optimization process by iterating through the training batches:

# number of optimization iterations performed so fartotal_iterations = 0def optimize(num_iterations): # Update globally the total number of iterations performed so far. ...

Get Deep Learning By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.