You must have heard about deep learning once and you might felt curious about how to implement deep learning. The first thing that comes to me is a Neural Network whenever I hear the word deep learning. Now, what is a neural network, and what is deep learning?
Let's understand a little about them and then without taking much time, we will build our Neural network in just 9 lines of code.
Personally, I call it The Hello World of Deep Learning with Neural Networks.
If you want to work on some projects, kindly refer to this link:
Neural Network: In the easiest terms, we can understand neural networks as the advanced version of Machine learning algorithms.
Neural networks work in the same way as the human brain. They find the underlying pattern that exists with the data.
RELATED POST: UNDERSTANDING MACHINE LEARNING ALGORITHMS
Deep Learning: Deep learning is a subset of Machine Learning. It has the capability to learn unlabeled data very easily.
There are many algorithms in Machine learning which fails when there is a huge amount of unlabeled data. Deep learning provides the best accuracy when we have a huge amount of either labeled or unlabeled data.
You can learn more about machine learning algorithms to understand them better provided in the above link.
Let's begin modeling.
Here, we will build a very basic neural network without any convolutions to understand how does it work and to learn how to get started with Deep Learning and Neural networks.
Step 1: Importing necessary libraries.
There are certain functions used while compiling the model. These functions work together simultaneously.
Parameters of compile function:
- loss: It is the duty of a neural network to calculate how much the loss occurred while guessing the relationship with the data. So, 'mean_squared_error' measures the loss occurred and tells the loss to the optimizer.
- optimizer: The optimizer used here is sgd - Stochastic Gradient Descent. The work of optimizer is to map the relationship correctly in order to reduce the loss that occurred earlier.
- metrics: If you want to see the accuracy of the model then you can use metrics=['accuracy'] as the additional function in the compile function.
Now we are done with fitting the model. It is time to test our neural network. But before testing I want you to calculate yourself what would be the value of y when x=10?
Yes, according to our equation y=2x-2, y would be 18.
You must be wondering why not 18?
You can see that the model has predicted value as 17.968 but now exactly 18.
Neural networks deal with probabilities. We have only provided 6 data points and it almost predicted it correctly. There must be a chance that the relationship would not be y=2x-2. It may change to y-2x-1 when we use 100 data points instead of 6 as used here. Therefore, Neural networks deal with probabilities.
Here is the complete code for you to practice. You have successfully build a neural network in just 9 lines of code.
Hope it helped you to understand the basics of a Neural Network. Kindly subscribe to the Telegram channel for more updates.
Soon I will be uploading a complex neural network with convolutions and models explaining overfitting and other parameters as mentioned in this blog.
Kindly give your choice for the next blog to serve you better. Next Blog?
Thanks!
0 Comments
Thank You!