Training an artificial neural network
Now that we have seen an NN in action and have gained a basic understanding of how it works by looking over the code, let's dig a little bit deeper into some of the concepts, such as the logistic cost function and the backpropagation algorithm that we implemented to learn the weights.
Computing the logistic cost function
The logistic cost function that we implemented as the _compute_cost
method is actually pretty simple to follow since it is the same cost function that we described in the logistic regression section in Chapter 3, A Tour of Machine Learning Classifiers Using scikit-learn:
Here, is the sigmoid activation of the ith sample in the dataset, which we compute in the forward propagation step:
Again, note that in this context, the superscript [i] is an index for training examples, not layers.
Now, let's add a regularization term, which allows us to reduce the degree of overfitting. As you recall from earlier...