Understanding the Neural Network using PyTorch
An artificial neural network is an interconnected group of nodes, similar to the vast network of neurons in a brain. It is the building block of deep learning models it has mainly 3 layers Input Layer, a hidden layer and output layer every node has its own activation function weights and biases attached to it according to which its output is calculated and fed into the next layer except the input layer which only has input.
Now we will make a simple Neural Network with Input Layer containing 2 Nodes a single Hidden Layer with 2 Nodes and an output Layer with 1 Node
Now we will do a forward pass in your neural network we will pass the random weights and biases through our network and calculate the output and use it to get the error and then we will do a backpropagation to reduce the error.
Now let us give the input value as 1 and 2 and use it to calculate the value of all the nodes in the network
We want the target to be1 but we get the output as 0.59 so now we calculate the error the same way as for mean squared error.
Now comes backpropagation we have got the error we will use it to calculate the new biases and weights
All this maths seems pretty daunting lucky for us and PyTorch has a simple function to calculate this.
The above step will calculate the partial derivative and update the weights and biases accordingly
A fully connected neural network is the heart of deep learning in my next post I would talk about what is convolution neural network and how by combing convolution neural network and fully connected neural network we can classify images.
If you want to know more about Neural Network you can check this out https://www.youtube.com/watch?v=aircAruvnKk https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html
Originally published at medium.com on January 5, 2019.