All writing

Inside the mind of a Deep Neural Network

June 28, 2022

The mind of a neural network can be a complex and mysterious thing, but at its core, it is simply a set of algorithms designed to process and analyze large amounts of data. This data is typically fed into the neural network in the form of input vectors, which are then processed through a series of interconnected nodes, or neurons. Each neuron performs a simple mathematical operation on the data it receives, and the output of these operations is then passed on to the next layer of neurons in the network.

Number Two
Number Nine
The numbers '2' and '9' and how a Deep Neural Network thinks they should look like.

One key aspect of a neural network's "mind" is its ability to learn from the data it is given. This is accomplished through a process called training, in which the neural network is fed a large amount of labeled data and then uses that data to adjust the weights of its neurons in order to improve its performance. Over time, this process allows the neural network to make increasingly accurate predictions or classifications based on the data it has been trained on.

Another interesting aspect of a neural network's mind is its ability to generalize from the data it has been trained on. This means that even if a neural network has only been trained on a limited amount of data, it can still make accurate predictions on new, unseen data. This is because a well-trained neural network has learned the underlying patterns and structures in the data, rather than simply memorizing the specific examples it has been trained on.

However, it is important to note that the mind of a neural network is ultimately limited by the quality and quantity of the data it has been trained on. If a neural network is trained on biased or incomplete data, it will be unable to make accurate predictions on new, unseen data. This has important implications for the use of neural networks in real-world applications, as it highlights the need for careful consideration of the data used for training.

There are several types of Neural Networks. Deep Neural Network (DNN) is a multi layer network that roughly works the same way as a human brain. It has neurons, activators, links and weights. There is an input node layer, a hidden node layer and and an output node layer. All these are connected via some links and these links have weights attached to them. The link weights can be updated by training the model which can be done in two ways, supervised learning and unsupervised learning. The former is more simple and more reliable as it is based on teaching a model what exactly are they operating on. It is just like a toddler who is interacting with the environment and the parents are constantly teaching the kid how to interact and interpret. If you want to learn more about neural networks and machine learning, I would suggest going though this fantastic book "Make Your Own Neural Network" by Tariq Rashid.

Neural Network for recognising numbers

I made this basic model using MNIST dataset. A picture of a handwritten number is composed of pixels (28x28). These pixels have some values associated with them. For simplicity, a greyed out picture is taken in which each pixel value is between 0 (Black) to 255 (white). These are then stored in a .csv file, and this is the MNSIT data that we interact with.

We can easily use this data set to train our neural network. You can find the code here. Once the network is trained, we can test it by comparing against a new input image. You will be surprised how good the network performs.

Backquerry, "Probing the mind of Neural Net"

Once the network is trained meaning, its links weights are set, we can backquerry the network. We can input our querry at the output nodes and see what result it generates at the input layer. The images of '2' and '9' as shown were obtained in this fashion. This is what a neural network thinks how a '0' and a '7' look like.

Number Two
Number Nine

Next, I trained the model using some of my pictures and this is how it thinks how i look. Not bad for a machine to think like this.

Rishabh