There's quite a bit going on in this equation, so let's unpack it piece by piece. aa is the vector of activations of the second layer of neurons. To obtain a′a′ we multiply aa by the weight matrix ww, and add the vector bb of biases. We then apply the function σσelementwise to every entry in the vector wa+bwa+b. (This is calledvectorizing the function σσ.) It's easy to verify that Equation (22)gives the same result as our earlier rule, Equation (4), for computing the output of a sigmoid neuron.
Exercise
• Write out Equation (22) in component form, and verify that it gives the same result as the rule (4) for computing the output of a sigmoid neuron.
With all this in mind, it's easy to write code computing the output from a Network instance. We begin by defining the sigmoid function: