/  Deep Learning Interview questions and answers   /  How to implement Linear Classification model in TensorFlow?
Tensor Datatype and Ranks 1(i2tutorials)

How to implement Linear Classification model in TensorFlow?

The two most common supervised learning tasks are linear regression and linear classifier. Linear regression predicts a value while the linear classifier predicts a class. This tutorial is focused on Linear Classifier.

Technically, in a linear model we will use the simplest function to predict the label $\mathbf{y_i}$ of the image $\mathbf{x_i}$. We’ll do so by using a linear mapping like $f(\mathbf{x_i}, \mathbf{W}, \mathbf{b})=\mathbf{W}\mathbf{x_i}+\mathbf{b}$ where $\mathbf{W}$ and $\mathbf{b}$ are called weight matrix and bias vector respectively.

Steps to implement Linear Classification in TensorFlow:

  • Import required Libraries
  • Load the Data
  • Specifying the Data Dimensions
  • Randomize the Data
  • Load the Data and Display the sizes
  • Hyper Parameter Tuning
  • TensorFlow Variables of proper size and initialization for generating the weight and bias variables of the desired shape.
  • Place Holders for input and corresponding labels
  • Create the model structure
  • Defining the Loss Function, Optimizer, accuracy and Predicted Class
  • Initialize the all variables
  • Train the Data
  • Test the Data
  • Evaluate the model
  • Visualize the results

Leave a comment