Model training

Now, we'll define a loop that iterates num_iterations times. And for each loop, it runs training, feeding in values from input_values_train and target_values_train using feed_dict.

In order to calculate accuracy, it will test the model against the unseen data in input_values_test :

for i in range(num_iterations+1):    sess.run(train, feed_dict={input_values: input_values_train, output_values: target_values_train})    if i%100 == 0:        print('Training Step:' + str(i) + ' Accuracy = ' + str(sess.run(model_accuracy, feed_dict={input_values: input_values_test, output_values: target_values_test})) + ' Loss = ' + str(sess.run(model_cross_entropy, {input_values: input_values_train, output_values: target_values_train})))Output:Training Step:0 ...

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.