Evaluating a trained model

We have put together all the pieces we need in order to train our model. The last thing before we start training is that we want to create some nodes in our graph that will allow us to test how good our model has done after we have finished training it.

We will create a node that calculates the accuracy of our model.

Tf.equal will return a Boolean list indicating where the two supplied lists are equal. Our two lists, in this case, will be the label and the output of our model, after finding the indices of the max values:

correct_prediction = tf.equal(tf.argmax(model_out,1), tf.argmax(y,1)) 

We can then use reduce_mean again to get the average number of correct predictions. Don't forget to cast our boolean correct_prediction list back to float32:

accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.74.66