Interface for wrapping around update policies (e.g., VanillaUpdate) and feeding a clipped gradient to them instead of the normal one. More...
Public Member Functions | |
| GradientClipping (const double minGradient, const double maxGradient, UpdatePolicyType &updatePolicy) | |
| Constructor for creating a GradientClipping instance. More... | |
| void | Initialize (const size_t rows, const size_t cols) |
| The Initialize method is called by SGD Optimizer method before the start of the iteration update process. More... | |
| double | MaxGradient () const |
| Get the maximum gradient value. More... | |
| double & | MaxGradient () |
| Modify the maximum gradient value. More... | |
| double | MinGradient () const |
| Get the minimum gradient value. More... | |
| double & | MinGradient () |
| Modify the minimum gradient value. More... | |
| void | Update (arma::mat &iterate, const double stepSize, const arma::mat &gradient) |
| Update step. More... | |
| UpdatePolicyType & | UpdatePolicy () const |
| Get the update policy. More... | |
| UpdatePolicyType & | UpdatePolicy () |
| Modify the update policy. More... | |
Interface for wrapping around update policies (e.g., VanillaUpdate) and feeding a clipped gradient to them instead of the normal one.
(Clipping here is implemented as
.)
| UpdatePolicy | A type of UpdatePolicy that sould be wrapped around. |
Definition at line 29 of file gradient_clipping.hpp.
|
inline |
Constructor for creating a GradientClipping instance.
| minGradient | Minimum possible value of gradient element. |
| maxGradient | Maximum possible value of gradient element. |
| updatePolicy | An instance of the UpdatePolicyType used for actual optimization. |
Definition at line 40 of file gradient_clipping.hpp.
|
inline |
The Initialize method is called by SGD Optimizer method before the start of the iteration update process.
Here we just do whatever initialization is needed for the actual update policy.
| rows | Number of rows in the gradient matrix. |
| cols | Number of columns in the gradient matrix. |
Definition at line 58 of file gradient_clipping.hpp.
|
inline |
Get the maximum gradient value.
Definition at line 92 of file gradient_clipping.hpp.
|
inline |
Modify the maximum gradient value.
Definition at line 94 of file gradient_clipping.hpp.
|
inline |
Get the minimum gradient value.
Definition at line 87 of file gradient_clipping.hpp.
|
inline |
Modify the minimum gradient value.
Definition at line 89 of file gradient_clipping.hpp.
|
inline |
Update step.
First, the gradient is clipped, and then the actual update policy does whatever update it needs to do.
| iterate | Parameters that minimize the function. |
| stepSize | Step size to be used for the given iteration. |
| gradient | The gradient matrix. |
Definition at line 71 of file gradient_clipping.hpp.
|
inline |
Get the update policy.
Definition at line 82 of file gradient_clipping.hpp.
|
inline |
Modify the update policy.
Definition at line 84 of file gradient_clipping.hpp.