Data Science, Artificial Intelligence, Machine Learning has risen exponentially in the last decade largely due to the amount of the data that’s get generated and the huge computation power of modern computers.
Deep Learning is the sub-field of Machine Learning which makes better predictions compared to the traditional Machine Learning techniques as the amount of data increases. It works on the principle of neural networks which is similar to the neurons in our brain. The neurons or the hidden layers in the deep learning framework learns patterns from the data and more often than not gives accurate predictions. Image Classification, Digit Recognition, etc., are some of the use cases where Deep learning used.
Suppose to predict the price of a house, we take the variables as size and price. Linear Regression could be applied over here but Deep Learning algorithms would produce much better results. The neurons would receive the input and apply activation functions like Rectified Linear Unit or ReLU to generate the output. An activation function is a real number and the output is that number.
Supervised Learning is a process where we get an output after the input is mapped to it via a certain function. The types of neural networks vary according to the application. On one hand, where Convolutional Neural Networks is used for Image classification, speech recognition is achieved by the Recurrent Neural Networks.
As the data increases, algorithms like Support Vector Machines, Linear Regression, etc., doesn’t improve much but more data improves the deep learning algorithm. The choice of an activation function is also an important factor in Deep Learning with Python as using the sigmoid function increases the computation time which is resolved by the ReLU function.
In Deep Learning, writing less code would give outstanding results provided that the right parameters are used and the hyperparameters are fine-tuned.
Deep Learning Frameworks
So far we got a brief intuition about Deep Learning. Based on the Deep Learning Framework popularity, below are the 5 Deep Learning framework list you could use in your next project. We have provided sample code for 3 out of the 5 frameworks implemented in Python.
Developed and maintained by Francois Chollet, Keras is a user-friendly application programming interface which minimizes the user actions number and provides clear feedback on error. You could easily add new modules in Keras and all are described in Python code.
The model is the core data structure of Keras, and the Sequential model could be imported by –
You can add layers to this model using the .add() method.
The model is configured using the compile () statement.
Based on the number of epochs set, the model is trained.
The .evaluate () method would evaluate the performance and the .predict () method would give the results. Keras could be installed using the sudo pip install keras command.
The methods which are common in the layers of Keras are – .get_weights() , .set_wights(weights) , and .get_config(). The input and the output tensor of a single node layer could be found with the .input, .output, .input_shape, and the .output_shape command. Below are some of the other layers in Keras and their representation in Python.
Locally Connected Layers
Developed by Google, TensorFlow is the most popular Deep Learning framework used. Here, the tensors which are multi-dimensional array acts as the input. The versatility of this framework makes it extremely popular. TensorFlow’s single API allows it to run on different platforms like cloud, desktop, and so on. The architecture of TensorFlow is written in C++ language which makes it fast. It could also be operated using languages like Python.
TensorFlow could be installed using the pip install TensorFlow command. Please note that you would need to set up a local virtual environment to install TensorFlow. Below is a TensorFlow code in Python.
- Importing the libraries –
- The MNIST dataset is loaded and it is split into train and test set.
- The model is fine-tuned and several parameters are set.
- The model is trained and evaluated.
The TensorBoard, a feature of TensorFlow allows to graphically display and monitor the work of a TensorFlow. The node in a dataflow graph of a TensorFlow represents the tensors. Both Linear and Non-Linear models could be built using this framework. Additionally, the vast collection of tools makes it flexible with other Machine Learning algorithms. The auto-differentiation of TensorFlow benefits gradient descent algorithms.
Developed by Facebook, PyTorch is that Deep Learning framework which uses GPUs and provides flexibility and speed. In layman terms, PyTorch uses Tensors similar to Numpy with GPU.
Below is a sample code of using PyTorch on a random data of a two-layer network. The forward and backward passes are manually implemented.
The manual implementation of a backward pass could be prevented using the automatic differentiation mechanism provide by the Autograd package in PyTorch.
In PyTorch, you could easily make the transition for speed, functionality to graph node which works in C++ runtime environments. The front end in PyTorch is hybrid in nature providing flexibility in its workflow. It allows P2P communications as well. PyTorch could be used with libraries such as Numba, Cython. There are several tools used in areas of deep learning such as torchvision.
Developed by Berkley AI Research, Caffe framework exhibits speed, modularity, and functionality. In Caffe, you could set a single flag and switch between GPU and CPU. After its first release, several changes have been made in support of its code and the models. Nearly sixty million images could be processed per day using the Caffe framework. The community is large as well which supports several research works and large scale applications like computer vision.
MXNet supports various programming languages and it is an open source, flexible, lean and ultra-scalable framework which models like Convolutional Neural Networks and Long short-term memory. Using a distributed server, it is deployed on the cloud infrastructure and supports both symbolic and imperative programming.
The model built on this framework could be improved as it is much easier to fine-tune the hyperparameters and debug better. The backend is built on C++ with other languages supporting the frontend. A model could be deployed on a low-end device using the MXNet framework.
There are several frameworks available in Deep learning and recent developments have resulted in the rise of more such frameworks. All are efficient and capable building accurate models. However, the choice of uses is dependent on the application.