Tuesday, July 17, 2018

Tensorflow: first book (continued)

Before moving to the next book, first a posting on an example given in the Tensorflow book by Ramsundar and Zadeh.

The chapter on convolutional neural networks discusses training a tensorflow architecture to recognize handwritten digits taken from the MNIST dataset. The given Python code automatically downloads the dataset from the Web and partitions the labeled data into a train, validation, and test set (as explained in the book, used to train the network, validate the performance of the model, and test the final model, respectively).

The ultimate objective of the algorithm is, given the tensor with handwritten digits shown below to the left, finding the tensor with labels shown below to the right. 

[7 2 1 0 4 1 4 9
 5 9 0 6 9 0 1 5
 9 7 3 4 9 6 6 5
 4 0 7 4 0 1 3 1
 3 4 7 2 7 1 2 1
 1 7 4 2 3 5 1 2
 4 4 6 3 5 5 6 0
 4 1 9 5 7 8 9 3]


Clearly a fun example, since recognizing digits is an intuitive, but non-straightforward problem. I highly recommend running and modifying the code to become more familiar with such a network (as I did to generate the examples above), and see how the guesses become better with each next iteration of the algorithm.