Want to know in-depth about Deep Learning? Deep Learning has seen significant advancements with companies looking to build intelligent systems using vast amounts of unstructured data. Deep Learning works on the theory of artificial neural networks. In this article, we’ll learn about the basics of Deep Learning with Python and see how neural networks work.

You can successfully prepare for your next deep learning job interview in 2022 with these commonly asked deep learning interview questions.

## What is Deep Learning?

Deep Learning is a part of machine learning that deals with algorithms inspired by the structure and function of the human brain. It uses artificial neural networks to build intelligent models and solve complex problems. We mostly use deep learning with unstructured data.

Let’s now look understand the basics of neural networks in this Deep Learning with Python article.

## What is a Neural Network?

A neural network is a machine modeled on the human brain. Each layer consists of nodes. The connections between the nodes depict the flow of information from one layer to the next. The neurons are connected with the help of weights. It then feeds the inputs to a neuron. After this, it processes the data and gives an output.

The following is an example of a basic neural network.

A neural network has three main layers.

- Input Layer: This layer is responsible for accepting the inputs.
- Hidden Layer: This layer processes the input data to find out hidden information and performs feature extraction.
- Output Layer: This layer gives the desired output.

Depicted below is an example of a neural network that takes the pixels of an image, processes it using the hidden layers, and classifies the shape of the image. Here, it is a triangle.

## Activation Function

The following operations are performed within each neuron,

- The product of each input value and the weight of the channel it has passed over is found.
- It computes the sum of the weighted products. We call this the weighted sum.
- It adds a bias unique to the neuron to the weighted sum.
- We then subject the final sum to a particular function.

There are a number of activation functions available in a neural network.

### Sigmoid Function

The sigmoid function is used for models where we have to predict the probability as an output. It exists between 0 and 1.

### Threshold Function

It is a threshold-based activation function. It makes the function active and fired if the value of x is greater than a certain value, else not.

### Rectifier Function

It is the most widely used activation function and gives an output of X if X is positive and 0 otherwise.

### Hyperbolic Tangent Function

This function is similar to the Sigmoid function and is bound to the range (-1, 1).

## Cost Function

The Cost function returns the difference between the neural network’s predicted output and the actual output from a set of labeled training data. The least-cost value can be obtained by making adjustments to the weights and biases iteratively throughout the training process.

The formula for cost function is:

Where Y hat is the predicted value and Y is the actual output.

## How Do Neural Networks work?

- A network comprises layers of neurons. It associates each neuron with a random number called the bias.
- Neurons present in each layer transmit information to neurons of the next layer over channels.
- These channels are associated with values called weights.
- The weights, along with the biases, determine the information that is passed over from neuron to neuron.
- Neurons from each layer transmit information to neurons of the next layer.
- The output layer gives a predicted output.

Let’s go ahead and build a neural network to predict bike prices based on a few of its features.

- The input features such as cc, mileage, and abs are fed to the input layer.
- The hidden layers help in improving output accuracy.
- Each of the connections has a weight assigned to it. The neuron takes a subset of the inputs and processes it.

----> x1*w1 + x2*w2 + b1

----> Φ(x1* w1 + x2*w2 + b1), where Φ is an activation function.

- The information reaching the neuron’s in the hidden layer is subjected to the respective activation function.
- It sends the processed information to the output layer over the weighted channels.
- It compares the predicted output to the original output value.
- A cost function determines the error in prediction and reports it back to the neural network. We call this backpropagation.
- The weights are adjusted to minimize the error.
- We now train the network using the new weights.
- Once again, it determines the cost, and it continues backpropagation until the cost cannot be reduced any further.
- We consider our neural network trained when the value for the cost function is minimum.

Now, let’s learn more about another topic in the Deep Learning with Python article, i.e., Gradient Descent.

## Gradient Descent

Gradient Descent is an approach to minimize the cost function. The gradient is a numeric calculation that allows us to adjust the parameters of a neural network in order to minimize the output deviation. The cost function is plotted against the predicted value, and the goal is to find the particular value of weight for which the loss is minimum.

## Deep Learning Platforms

Several popular and widely used deep learning frameworks help to build neural network models. Some of the common ones are Tensorflow, Keras, Pytorch, and DL4J.

In our hands-on demo, we have used the TensorFlow library to create the model.

## What is TensorFlow?

Developed by Google, TensorFlow is an open-source library used to define and run computations on tensors. Tensors are just another name for multi-dimensional arrays.

It can run on either CPU or GPU. It can create data flow graphs that have nodes and edges. TensorFlow is popularly used for Machine Learning applications such as Neural Networks.

Now, let’s move on to the final section of our article on Deep Learning with Python, i.e., to build a model that can predict handwritten digits using the MNIST database.

## Deep Learning With Python Demo: Predict Handwritten Digits

- Import the required libraries.
- Load the dataset.
- Check the total number of training and testing samples.
- Visualize the data.
- Build the model.
- Loss and Optimization.
- Test the model and find the accuracy.

As is evident above, our model has an accuracy of 91%, which is decent.

Master deep learning concepts and the TensorFlow open-source framework with the PGP in AI and Machine Learning. Get certified today!

## Conclusion

After completing this article, you would have learned Deep Learning basics and understood how neural networks work. You looked at the different techniques in Deep Learning and implemented a demo to classify handwritten digits using the MNIST database.

If you have any questions related to this article on Deep Learning with Python, please place them in the comments section of this article. Our experts will resolve your queries at the earliest!