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

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

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