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

Training

Let's go ahead and kick off the training process:

num_epochs = 10train_batch_size = 1000contextual_window_size = 10with train_graph.as_default():    saver = tf.train.Saver()with tf.Session(graph=train_graph) as sess:        iteration_num = 1    average_loss = 0        #Initializing all the vairables    sess.run(tf.global_variables_initializer())    for e in range(1, num_epochs+1):                #Generating random batch for training        batches = generate_random_batches(training_words, train_batch_size, contextual_window_size)               #Iterating through the batch samples        for input_vals, target in batches:                        #Creating the feed dict            feed_dict = {inputs_values: input_vals,                    labels_values: np.array(target)[:, None]}             train_loss, _ = sess.run([model_cost, model_optimizer], feed_dict=feed_dict) ...

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