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

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.