While NumPy is definitely not the go-to package for training a neural network in real-time scenarios, learning to implement it in NumPy brings out the flexibility and might of NumPy for doing complex matrix computations and also provides a better understanding of neural networks.
First, let's synthetically generate a dataset for a binary classification problem that will be used for training the neural network. The data will be from two different Gaussian distributions, and the model will be trained to classify this data into either of the two categories. Let's generate the data with 1,000 samples in each category:
N = 1000
X1 = np.random.randn(N, 2) + np.array([0.9, 0.9])
X2 = np.random.randn(N, 2) + np.array([-0.9, -0.9])
Now we have two 1000 x 2 arrays. For the predictor variable, we can use the zeros and ones functions to create...