M2M Day 357: Is my algorithmic approach in trouble?
This post is part of Month to Master, a 12-month accelerated learning project. For October, my goal is to defeat world champion Magnus Carlsen at a game of chess.
Yesterday, I deconstructed, line by line, the code that I’m using to generate my chess algorithm. Today, I explored this code a little bit further.
In particular, I wanted to answer two questions today:
Question 1
Once I fully train the machine learning model, how do I output the resulting algorithmic parameters in a readable format (so that I can then proceed to memorize them)?
In my code, the variable W represents the matrix that holds all of the algorithm parameters, so I figured that I could just run the command print(W).
However, unlike normal Python code, Tensorflow does not allow for this kind of syntax.
After a little playing around, I discovered I need to run a Tensorflow Interaction Session in order to extract the values of W.
This isn’t anything theoretically fancy. It’s simply the syntax that Tensorflow requires…
sess = tf.InteractiveSession()
tf.global_variables_initializer().run()for i in range(0,784):
for j in range(0,10):
param = sess.run(W)[i][j]
print(round(param,2))
And here’s the output — a list of all 7840 parameters contained in W:
You’ll notice that I’m using the round function to round all of the parameters to two digits after the decimal point, as this is the limit for what my human brain can handle.
I still need to figure out how to update these values within W, and then validate that the model still works reasonably well with this level of detail. (If it doesn’t, then my algorithmic approach is in big trouble).
Question 2
Does my more sophisticated model actually produce better results? And if it does, are the results better by enough to justify the extra complexity?
If I just run the sample code as it (where the code is trying to identify handwritten numerical digits in input images), the model predicts the correct digit 92% of the time, which isn’t too bad.
If I make the model in the sample code more sophisticated, by adding two hidden layers, and then retesting its predictions, it only correctly identifies digits 11% of the time (i.e. essentially no better than a random guess).
I’m not sure if I simply don’t have enough data to train this more sophisticated model, or if there’s a gap in my understand in regards to building more sophisticated models.
If it’s a data problem, I can resolve that. If it’s a gap in my understand, I can resolve that too, but it may uncover some potential obstacles for my algorithm chess approach.
Hopefully, I can find a way forward. Hopefully, there’s even a way forward.
Read the next post. Read the previous post.