Introduction
The vectorized operations have been discussed in the last post Maths in a Neural Network: Vectorization. This post will focus on implementing the equations with numpy.
Equations proved in the previous posts [1] [2]:
Note that this network takes one sample input at a time, I’ll discuss batch prediction/training later.
Feed-forward:
Weight update:
Output layer:
Hidden layer:
Notebook:
The following code implemented a 2-3-3-2 network for XOR problem. Note that this network takes one sample input at a time, I’ll discuss batch prediction/training later.
In the end, the Mean Square Error of an epoch converges to a low value, which indicates the training was fine.
Next
- Maths in a Neural Network: Element-wise
- Maths in a Neural Network: Vectorization
- Code a Neural Network with Numpy
- Maths in a Neural Network: Batch Training
2 thoughts on “Code a Neural Network with Numpy”