TensorFlow is a free and open-source library for machine learning, Main usage of Tensorflow is to train and develop Neural Networks. It is comprehensive, a flexible ecosystem of tools, libraries, and community resources that help to learn and master ML and developers to build, maintain and deploy state-of-the-art Machine learning and deep learning models with minimum monitoring.
Examples of commonly used models include Neural Networks to identify clothes, sneakers and shirt images on the database, Identify handwritten digits using Keras, Translation of languages from Spanish to English, Prescribing and writing antibiotics for infections.
TensorFlow APIs
TensorFlow APIs are created and arranged in a hierarchical order, with the high-level APIs build on the low-level APIs. Machine learning researchers use low-level APIs to create and explore new machine learning algorithms such as regression and classification. In the higher end, you will use a high-level API named tf. Keras to define and train machine learning models and to make predictions. tf.Keras is the TensorFlow variant of the open-source Keras.
It was initially released on November 9, 2015
Developed by GOOGLE
License: Apache license 2.0
Current stable release 2.3.1 on September 24, 2020
It was code using Python, C++, CUDA.
Install TensorFlow
Install TensorFlow using the PIP command
$ pip install TensorFlow
The above command allows you to install the current version on TensorFlow which is 2.3.1
A smaller CPU only package is available
$ pip install TensorFlow-CPU
To update the already existing TensorFlow package add an upgrade flag to the above syntax.
Modeling using TensorFlow
Steps involved in building a Neural Network model
1. Build a neural network to classify images.
2. Train neural networks.
3. Finally, evaluate the accuracy of the model.
Import TensorFlow
Load and prepare dataset, Convert sample from int to float.
In the above steps, we have successfully imported the MNIST dataset into MNIST and converted the values into a float by division.
The data is also split up to Train and Test components.
Now we build neural network layers, Remember to add more layers for better model training. Too many layers will drain CPU resources and may cause overfitting, so a perfect balance should be maintained no too many not too few.
We are using activation as ‘RELU’ as it doesn’t consume high CPU resources, We can also use TanH or Log functions.
The output return logits score one for each class. As shown below
Softmax function these logits into probabilities for each class
It is possible for the Softmax to be an activation function for the first layer of the network, this approach is discourage as it is possible to calculate loss function if softmax is use as activation in the first layer.
The output of probabilities is as follows.
Loss Function
The loss function takes vector logits as input and gives scalar loss as output.
Loss is zero if the model is sure of the correct class, Untrain model gives probability close to 1/10 for each class.
Loss_fun is the y_train model loss score.
Model. fit adjusts model parameters to minimize loss as low as possible.
Model. Evaluate checks model performance, usually on test set which was split initially.
The image classifier is now trained with 98% accuracy.
Advantage and disadvantages
Advantages:
- Tensorflow has better Graphics and visualization compared to other libraries.
- As a Google project, all the updates and bugs are fixed and maintained upto date.
- High performance matching industry standards.
- Allows monitoring training progress of the models.
Disadvantages:
- It has a unique structure had to find errors and debug them
- Requires advanced knowledge of linear algebra and machine learning.
- Steep learning curve.
- Lack of speed and usage compared to its competitors.
TensorFlow is an open-source and standard library which is a must learn to develop and understand neural networks.
Written By: Tarun Kumar
Reviewed By: Rushikesh Lavate
If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs