n2p2 - A neural network potential package
nnp::Updater Class Referenceabstract

Base class for different weight update methods. More...

#include <Updater.h>

Inheritance diagram for nnp::Updater:
Collaboration diagram for nnp::Updater:

Public Member Functions

virtual void setState (double *state)=0
 Set pointer to current state. More...
 
virtual void setError (double const *const error, std::size_t const size=1)=0
 Set pointer to current error vector. More...
 
virtual void setJacobian (double const *const jacobian, std::size_t const columns=1)=0
 Set pointer to current Jacobi matrix. More...
 
virtual void update ()=0
 Perform single update of state vector. More...
 
virtual std::string status (std::size_t epoch) const =0
 Status report. More...
 
virtual std::vector< std::string > statusHeader () const =0
 Header for status report file. More...
 
virtual std::vector< std::string > info () const =0
 Information about this updater. More...
 
virtual void setupTiming (std::string const &prefix="upd")
 Activate detailed timing. More...
 
virtual void resetTimingLoop ()
 Start a new timing loop (e.g. More...
 
virtual std::map< std::string, StopwatchgetTiming () const
 Return timings gathered in stopwatch map. More...
 

Protected Member Functions

 Updater (std::size_t const sizeState)
 Constructor. More...
 

Protected Attributes

bool timing
 Whether detailed timing is enabled. More...
 
bool timingReset
 Internal loop timer reset switch. More...
 
std::size_t sizeState
 Number of neural network connections (weights + biases). More...
 
std::string prefix
 Prefix for timing stopwatches. More...
 
std::map< std::string, Stopwatchsw
 Stopwatch map for timing. More...
 

Detailed Description

Base class for different weight update methods.

Definition at line 31 of file Updater.h.

Constructor & Destructor Documentation

◆ Updater()

Updater::Updater ( std::size_t const  sizeState)
protected

Constructor.

Parameters
[in]sizeStateSize of the state vector (number of parameters to optimize).

Definition at line 22 of file Updater.cpp.

22 : timing (false ),
23 timingReset(true ),
25 prefix ("" )
26{
27}
std::string prefix
Prefix for timing stopwatches.
Definition: Updater.h:112
std::size_t sizeState
Number of neural network connections (weights + biases).
Definition: Updater.h:110
bool timingReset
Internal loop timer reset switch.
Definition: Updater.h:108
bool timing
Whether detailed timing is enabled.
Definition: Updater.h:106

Member Function Documentation

◆ setState()

virtual void nnp::Updater::setState ( double *  state)
pure virtual

Set pointer to current state.

Parameters
[in,out]statePointer to state vector (weights vector), will be changed in-place upon calling update().

Implemented in nnp::GradientDescent, and nnp::KalmanFilter.

◆ setError()

virtual void nnp::Updater::setError ( double const *const  error,
std::size_t const  size = 1 
)
pure virtual

Set pointer to current error vector.

Parameters
[in]errorPointer to error (difference between reference and neural network potential output).
[in]sizeNumber of error vector entries.

Implemented in nnp::KalmanFilter, and nnp::GradientDescent.

◆ setJacobian()

virtual void nnp::Updater::setJacobian ( double const *const  jacobian,
std::size_t const  columns = 1 
)
pure virtual

Set pointer to current Jacobi matrix.

Parameters
[in]jacobianDerivatives of error with respect to weights.
[in]columnsNumber of gradients provided.
Note
If there are \(m\) errors and \(n\) weights, the Jacobi matrix is a \(n \times m\) matrix stored in column-major order.

Implemented in nnp::KalmanFilter, and nnp::GradientDescent.

◆ update()

virtual void nnp::Updater::update ( )
pure virtual

Perform single update of state vector.

Implemented in nnp::GradientDescent, and nnp::KalmanFilter.

◆ status()

virtual std::string nnp::Updater::status ( std::size_t  epoch) const
pure virtual

Status report.

Parameters
[in]epochCurrent epoch.
Returns
Line with current status information.

Implemented in nnp::GradientDescent, and nnp::KalmanFilter.

◆ statusHeader()

virtual std::vector< std::string > nnp::Updater::statusHeader ( ) const
pure virtual

Header for status report file.

Returns
Vector with header lines.

Implemented in nnp::GradientDescent, and nnp::KalmanFilter.

◆ info()

virtual std::vector< std::string > nnp::Updater::info ( ) const
pure virtual

Information about this updater.

Returns
Vector of information lines.

Implemented in nnp::GradientDescent, and nnp::KalmanFilter.

◆ setupTiming()

void Updater::setupTiming ( std::string const &  prefix = "upd")
virtual

Activate detailed timing.

Parameters
[in]prefixPrefix used for stopwatch map entries.

Definition at line 29 of file Updater.cpp.

30{
31 this->prefix = prefix;
32 timing = true;
33
34 return;
35}

References prefix, and timing.

◆ resetTimingLoop()

void Updater::resetTimingLoop ( )
virtual

Start a new timing loop (e.g.

epoch).

Definition at line 42 of file Updater.cpp.

43{
44 timingReset = false;
45 return;
46}

References timingReset.

◆ getTiming()

std::map< std::string, Stopwatch > Updater::getTiming ( ) const
virtual

Return timings gathered in stopwatch map.

Returns
Stopwatch map.

Definition at line 37 of file Updater.cpp.

38{
39 return sw;
40}
std::map< std::string, Stopwatch > sw
Stopwatch map for timing.
Definition: Updater.h:114

References sw.

Member Data Documentation

◆ timing

bool nnp::Updater::timing
protected

Whether detailed timing is enabled.

Definition at line 106 of file Updater.h.

Referenced by setupTiming().

◆ timingReset

bool nnp::Updater::timingReset
protected

Internal loop timer reset switch.

Definition at line 108 of file Updater.h.

Referenced by resetTimingLoop().

◆ sizeState

◆ prefix

std::string nnp::Updater::prefix
protected

Prefix for timing stopwatches.

Definition at line 112 of file Updater.h.

Referenced by setupTiming().

◆ sw

std::map<std::string, Stopwatch> nnp::Updater::sw
protected

Stopwatch map for timing.

Definition at line 114 of file Updater.h.

Referenced by getTiming().


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