Path: blob/master/site/en-snapshot/addons/tutorials/optimizers_conditionalgradient.ipynb
25118 views
Copyright 2020 The TensorFlow Authors.
TensorFlow Addons Optimizers: ConditionalGradient
Overview
This notebook will demonstrate how to use the Conditional Graident Optimizer from the Addons package.
ConditionalGradient
Constraining the parameters of a neural network has been shown to be beneficial in training because of the underlying regularization effects. Often, parameters are constrained via a soft penalty (which never guarantees the constraint satisfaction) or via a projection operation (which is computationally expensive). Conditional gradient (CG) optimizer, on the other hand, enforces the constraints strictly without the need for an expensive projection step. It works by minimizing a linear approximation of the objective within the constraint set. In this notebook, you demonstrate the appliction of Frobenius norm constraint via the CG optimizer on the MNIST dataset. CG is now available as a tensorflow API. More details of the optimizer are available at https://arxiv.org/pdf/1803.06453.pdf
Setup
Build the Model
Prep the Data
Define a Custom Callback Function
Train and Evaluate: Using CG as Optimizer
Simply replace typical keras optimizers with the new tfa optimizer
Train and Evaluate: Using SGD as Optimizer
Frobenius Norm of Weights: CG vs SGD
The current implementation of CG optimizer is based on Frobenius Norm, with considering Frobenius Norm as regularizer in the target function. Therefore, you compare CG’s regularized effect with SGD optimizer, which has not imposed Frobenius Norm regularizer.