Query the Network
Learn about the query() function, which is used to train the neural network, and its simple matrix form implementation.
We'll cover the following...
The query()
function
Before we start working on the code that trains the neural network by fleshing out the currently empty train()
function, we’ll work on the simpler query()
function. This will give us more time to build confidence and get some practice at using both Python and these weight matrices inside the neural network object.
The query()
function takes the input to a neural network and returns the network’s output. That’s simple enough, but to do that, we need to pass the input signals from the input layer of nodes, through the hidden layer and out of the final output layer. We’ll also need to remember that we use the link weights to moderate the signals as they feed into any given hidden or output node. Moreover, we also use the sigmoid activation function to squish the signal coming out of those nodes.
If we had lots of nodes, we’d have the time-intensive task of writing out the Python code for each of those nodes, doing the weight moderating, summing signals, and applying the activation function. And the more nodes we have, the more code we need.
Simple implementation
Luckily, we don’t have to do that because we worked ...