Learning AI part 2

Not sure I learnt much this day, but maybe it’s sinking in….

Ongoing blog of my attempt to self learn AI, or is it just ML. Part 1 can be found here.

So back to reading and chapter 2, “Think like a machine”. Well this shouldn’t be too hard as I have been accused of being a robot before.

This is starting off like before and talking about the datasets used to help the reinforcement algorithm, very similar to the chapter 1 case, but is now talking about neurons.

Let’s download the code example and see if it runs.

Issue 1 the web link in the book has rather annoyingly a number of spaces and newlines. Remove them and yeah it works.

Issue 2 the version of Tensorflow is V2.X and the code expects a V1.X, looks like it changed quite a bit, see this guide to help. Of course this assumes you know what you are doing to start with, at this point I don’t.

Found a simple fix that makes it run, but obviously this is only for keeping V1 functionality:

You replace the original import:

import tensorflow as tf


import tensorflow.compat.v1 as tf

Later will have to find a better way of doing this, but this should help with the book at least.

Right it’s running and logging into it (localhost:6006) gives an interesting display, no idea what it means yet, but looks interesting:

Issue 3, looks like the numbers in the code don’t match the code in the book. Maybe this is changed later in the chapter. Update in the example diagram it also shows the values from the code and not the earlier book text.

Issue 4, maybe it’s me, but this looks like a typo city in the numbers, for example in the output it shows 0.00028867 (my code shows 0.00028861 but I think that’s due to the earlier number differences). However in the text it refers to this as 0.002. To me that is an order of magnitude bigger and if you are going to round it then it should be 0.0003. Maybe this is minor but as the book seems to be heavily focused on maths then I would really expect this part to be correct.

Issue 5, as it goes on there is talk about the quantities in the warehouses, but nowhere does it say the values (other than a 1 line of code for the X1 case). Maybe you are supposed to just assume this, but this is not helping my learning.

Softmax, this seems to be a process for normalisation of the values.

Issue 6, again maybe just my understanding but the layout on the Sigma notation was not helping my understanding. From the book:

Normally the Sigma part should really be written as:

Only minor, but this reduces the ambiguity considerably (to me) and I would expect this to be much clearer for a maths focused book. Update further down it shows this correctly… I should read on before commenting.

Softmax, basically this just takes all the values of the ‘y’ set and sums up their values when take as ey then give the normaised value back as the individual ey over the sum.

numpy, I keep seeing this used (usually imported as np), but not mentioned (not this book specifically). Quick look at it, and it is a library for giving better handling of mathematical elements to Python, so that makes sense.

Back to the book, and I see how we get the “one hot” value for the matrix, but so far you could just do that by picking the biggest value from the source array, without all the complex maths.

Chapter 3 – Apply Machine Thinking to a Human Problem

Installing the needed code on top of the example python files:

sudo apt install graphviz
pip3 install graphviz
pip3 install pydotplus

The last 2 might not be needed, but I was working backwards from the error messages.

Learning value of Gamma, in the 1st example there was a 0.8 factor on things the process learnt. This is to give it some feedback that the choice is good, but not too much. This explains why the path from D to C was a value of 80 (one step from the 100 ideal). Similarly B C and E all have 64% (0.8*0.8) on going to D (two steps from the 100 ideal).

That’s up to chapter 4, lets come back to that another day.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: