NNFS
Neural network library from scratch
Loading...
Searching...
No Matches
NNFS::SGD Class Reference

Stochastic Gradient Descent optimizer. More...

#include <SGD.hpp>

Inheritance diagram for NNFS::SGD:
[legend]

Public Member Functions

 SGD (double lr, double decay=0.0, double momentum=0.0)
 Construct a new SGD object.
 
void update_params (std::shared_ptr< Dense > &layer)
 Update the parameters of the layer.
 
- Public Member Functions inherited from NNFS::Optimizer
 Optimizer (double lr, double decay)
 Construct a new Optimizer object.
 
virtual ~Optimizer ()=default
 Basic destructor.
 
virtual void update_params (std::shared_ptr< Dense > &layer)=0
 Update the parameters of the layer.
 
void pre_update_params ()
 Pre-update parameters (e.g. learning rate decay)
 
void post_update_params ()
 Post-update parameters (e.g. increase iteration count)
 
double & current_lr ()
 Get the current learning rate.
 
int & iterations ()
 Get current iteration count.
 

Additional Inherited Members

- Protected Attributes inherited from NNFS::Optimizer
const double _lr
 
double _current_lr
 
int _iterations
 
double _decay
 

Detailed Description

Stochastic Gradient Descent optimizer.

This class implements the Stochastic Gradient Descent optimizer.

Constructor & Destructor Documentation

◆ SGD()

NNFS::SGD::SGD ( double  lr,
double  decay = 0.0,
double  momentum = 0.0 
)
inline

Construct a new SGD object.

Parameters
lrLearning rate
decayLearning rate decay (default: 0.0)
momentumMomentum (default: 0.0)

Member Function Documentation

◆ update_params()

void NNFS::SGD::update_params ( std::shared_ptr< Dense > &  layer)
inlinevirtual

Update the parameters of the layer.

Parameters
[in,out]layerLayer to update

Implements NNFS::Optimizer.


The documentation for this class was generated from the following file: