NNFS
Neural network library from scratch
Loading...
Searching...
No Matches
NNFS::Optimizer Class Referenceabstract

Base class for all optimizers. More...

#include <Optimizer.hpp>

Inheritance diagram for NNFS::Optimizer:
[legend]

Public Member Functions

 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.
 

Protected Attributes

const double _lr
 
double _current_lr
 
int _iterations
 
double _decay
 

Detailed Description

Base class for all optimizers.

This class is the base class for all optimizers. It provides the interface for all optimizers.

Constructor & Destructor Documentation

◆ Optimizer()

NNFS::Optimizer::Optimizer ( double  lr,
double  decay 
)
inline

Construct a new Optimizer object.

Parameters
lrLearning rate
decayLearning rate decay (default: 0.0)

◆ ~Optimizer()

virtual NNFS::Optimizer::~Optimizer ( )
virtualdefault

Basic destructor.

Member Function Documentation

◆ current_lr()

double & NNFS::Optimizer::current_lr ( )
inline

Get the current learning rate.

Returns
double Current learning rate

◆ iterations()

int & NNFS::Optimizer::iterations ( )
inline

Get current iteration count.

Returns
int Current iteration count

◆ post_update_params()

void NNFS::Optimizer::post_update_params ( )
inline

Post-update parameters (e.g. increase iteration count)

◆ pre_update_params()

void NNFS::Optimizer::pre_update_params ( )
inline

Pre-update parameters (e.g. learning rate decay)

◆ update_params()

virtual void NNFS::Optimizer::update_params ( std::shared_ptr< Dense > &  layer)
pure virtual

Update the parameters of the layer.

Parameters
[in,out]layerLayer to update

Implemented in NNFS::Adagrad, NNFS::Adam, NNFS::RMSProp, and NNFS::SGD.

Member Data Documentation

◆ _current_lr

double NNFS::Optimizer::_current_lr
protected

◆ _decay

double NNFS::Optimizer::_decay
protected

◆ _iterations

int NNFS::Optimizer::_iterations
protected

◆ _lr

const double NNFS::Optimizer::_lr
protected

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