O'Reilly logo

Deep Learning By Example by Ahmed Menshawy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required