To understand all these concepts better, let's implement our own neural network using the sklearn library. We will use the MNIST digits dataset for our task. The steps involved in training our network are:
- Preprocess the dataset by normalizing the pixel values of the images between 0, 1 or -1, and 1 (to make the mean 0).
- Prepare the dataset. Split the dataset into two sets—training set and testing set.
- Start training the dataset over the test data.
- Compute your network's performance over the test dataset.
The following code trains a neural network for classification of handwritten digits (MNIST dataset):
from sklearn.datasets import fetch_mldatafrom sklearn.neural_network import MLPClassifier ...