How to use SGD optimizer using TF learn

This recipe helps you use SGD optimizer using TF learn

Recipe Objective

This recipe explains what is Stochastic Gradient Descent in TFLayer.

Stochastic Gradient Descent

Its syntax is tflearn.optimizers.SGD (learning_rate=0.001, lr_decay=0.0, decay_step=100, staircase=False, use_locking=False, name='SGD')
Stochastic Gradient Descent Optimizer works on learning rate decay. While training a model it is advisable to decrease the learning rate as the training occurs It returns the decayed learning rate. decayed learning rate = learning rate * decay rate ^ (global_ tep / decay steps)

class SGD(optimizer):
    def __init__(self, lr=0.001, lr_d=0., ds=100, s=False, ul=False, N="SGD"):
       super(SGD, self).__init__(lr, ul, N)
       self.lr_d = lr_d
       if self.lr_d > 0.:
          self.hd = True
       self.ds = ds
       self.s = s

    def build(self, st=None):
       self.Built = True
       if self.hd:
          if not st:
             raise Exception("Learning rate decay but no step_tensor " "provided.")
          self.lr = tf.train.ed(self.lr, st, self.ds, self.ds, s=self.s)
          tf.add_to_collection(tf.GraphKeys.LR_VARIABLES, self.lr)
       self.tensor = tf.train.GradientDescentOptimizer(lr=self.lr, ul=self.ul, N=self.N)

sgd = SGD

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

End-to-End Snowflake Healthcare Analytics Project on AWS-2
In this AWS Snowflake project, you will build an end to end retraining pipeline by checking Data and Model Drift and learn how to redeploy the model if needed

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.

Build a Graph Based Recommendation System in Python -Part 1
Python Recommender Systems Project - Learn to build a graph based recommendation system in eCommerce to recommend products.

Isolation Forest Model and LOF for Anomaly Detection in Python
Credit Card Fraud Detection Project - Build an Isolation Forest Model and Local Outlier Factor (LOF) in Python to identify fraudulent credit card transactions.

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

Build a Multi Touch Attribution Machine Learning Model in Python
Identifying the ROI on marketing campaigns is an essential KPI for any business. In this ML project, you will learn to build a Multi Touch Attribution Model in Python to identify the ROI of various marketing efforts and their impact on conversions or sales..

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Forecasting Business KPI's with Tensorflow and Python
In this machine learning project, you will use the video clip of an IPL match played between CSK and RCB to forecast key performance indicators like the number of appearances of a brand logo, the frames, and the shortest and longest area percentage in the video.