LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::metric Class Referenceabstract

#include <metric.hpp>

Inheritance diagram for lbann::metric:
[legend]
Collaboration diagram for lbann::metric:
[legend]

Public Member Functions

 metric (lbann_comm *comm)
 
 metric (const metric &other)=default
 
metricoperator= (const metric &other)=default
 
virtual ~metric ()=default
 
virtual metriccopy () const =0
 
template<class Archive >
void serialize (Archive &ar)
 
virtual std::string name () const =0
 
virtual std::string get_unit () const
 
virtual void setup (model &m)
 
virtual EvalType evaluate (execution_mode mode, int mini_batch_size)=0
 
void reset_statistics ()
 
void reset_statistics (execution_mode mode)
 
EvalType get_mean_value (execution_mode mode) const
 
int get_statistics_num_samples (execution_mode mode) const
 
virtual std::vector< ViewingLayerPtrget_layer_pointers () const
 
virtual void set_layer_pointers (std::vector< ViewingLayerPtr > layers)
 
EvalType get_evaluate_time () const
 
EvalTypeget_evaluate_time ()
 
void reset_counters ()
 
virtual bool save_to_checkpoint_shared (persist &p)=0
 
virtual bool load_from_checkpoint_shared (persist &p)=0
 
virtual bool save_to_checkpoint_distributed (persist &p)=0
 
virtual bool load_from_checkpoint_distributed (persist &p)=0
 

Protected Member Functions

virtual EvalType evaluate_compute (const AbsDistMat &prediction, const AbsDistMat &ground_truth)=0
 
lbann_commget_comm ()
 
std::map< execution_mode, metric_statistics > & get_statistics ()
 

Private Attributes

lbann_commm_comm
 
std::map< execution_mode, metric_statisticsm_statistics
 
EvalType m_evaluate_time = 0.0
 

Detailed Description

Abstract base class for metric functions. A metric function can be used to evaluate the performance of a model without affecting the training process.

Definition at line 86 of file metric.hpp.

Constructor & Destructor Documentation

◆ metric() [1/2]

lbann::metric::metric ( lbann_comm comm)

Constructor.

◆ metric() [2/2]

lbann::metric::metric ( const metric other)
default

Copy constructor.

◆ ~metric()

virtual lbann::metric::~metric ( )
virtualdefault

Destructor.

Member Function Documentation

◆ copy()

virtual metric* lbann::metric::copy ( ) const
pure virtual

Copy function.

Implemented in lbann::layer_metric.

◆ evaluate()

virtual EvalType lbann::metric::evaluate ( execution_mode  mode,
int  mini_batch_size 
)
pure virtual

Evaluate the metric value. This function takes the model's current mini-batch size. If multiple models are being trained, the current mini-batch size may be different from the effective mini-batch size. The result is stored in history.

Implemented in lbann::layer_metric.

◆ evaluate_compute()

virtual EvalType lbann::metric::evaluate_compute ( const AbsDistMat prediction,
const AbsDistMat ground_truth 
)
protectedpure virtual

Computation to evaluate the metric function. This should return the sum of metric values across the mini-batch, not the mean value.

Implemented in lbann::layer_metric.

◆ get_comm()

lbann_comm& lbann::metric::get_comm ( )
inlineprotected

Get LBANN communicator.

Definition at line 173 of file metric.hpp.

◆ get_evaluate_time() [1/2]

EvalType lbann::metric::get_evaluate_time ( ) const
inline

Get the time spent in evaluation for this metric (const).

Definition at line 149 of file metric.hpp.

◆ get_evaluate_time() [2/2]

EvalType& lbann::metric::get_evaluate_time ( )
inline

Get the time spent in evaluation for this metric.

Definition at line 151 of file metric.hpp.

◆ get_layer_pointers()

virtual std::vector<ViewingLayerPtr> lbann::metric::get_layer_pointers ( ) const
virtual

Get list of pointers to layers.

Reimplemented in lbann::layer_metric.

◆ get_mean_value()

EvalType lbann::metric::get_mean_value ( execution_mode  mode) const

Get mean metric value. If mini-batch sizes are not identical, the mean is over the sample values rather than over the mini-batch mean values.

◆ get_statistics()

std::map<execution_mode, metric_statistics>& lbann::metric::get_statistics ( )
inlineprotected

Get metric statistics.

Definition at line 176 of file metric.hpp.

◆ get_statistics_num_samples()

int lbann::metric::get_statistics_num_samples ( execution_mode  mode) const

Get number of samples for statistics.

◆ get_unit()

virtual std::string lbann::metric::get_unit ( ) const
inlinevirtual

Return a display unit for this metric. Default is an empty string. This is overriden if the metric has units, e.g. "%" or "sec".

Reimplemented in lbann::layer_metric.

Definition at line 112 of file metric.hpp.

◆ load_from_checkpoint_distributed()

virtual bool lbann::metric::load_from_checkpoint_distributed ( persist p)
pure virtual

Implemented in lbann::layer_metric.

◆ load_from_checkpoint_shared()

virtual bool lbann::metric::load_from_checkpoint_shared ( persist p)
pure virtual

Load metric state from checkpoint.

Implemented in lbann::layer_metric.

◆ name()

virtual std::string lbann::metric::name ( ) const
pure virtual

Return a string name for this metric.

Implemented in lbann::layer_metric.

◆ operator=()

metric& lbann::metric::operator= ( const metric other)
default

Copy assignment operator.

◆ reset_counters()

void lbann::metric::reset_counters ( )
inline

Reset timing counters.

Definition at line 154 of file metric.hpp.

◆ reset_statistics() [1/2]

void lbann::metric::reset_statistics ( )
inline

Clear all statistics.

Definition at line 126 of file metric.hpp.

◆ reset_statistics() [2/2]

void lbann::metric::reset_statistics ( execution_mode  mode)
inline

Clear statistics for an execution mode.

Definition at line 133 of file metric.hpp.

◆ save_to_checkpoint_distributed()

virtual bool lbann::metric::save_to_checkpoint_distributed ( persist p)
pure virtual

Implemented in lbann::layer_metric.

◆ save_to_checkpoint_shared()

virtual bool lbann::metric::save_to_checkpoint_shared ( persist p)
pure virtual

Save metric state to checkpoint.

Implemented in lbann::layer_metric.

◆ serialize()

template<class Archive >
void lbann::metric::serialize ( Archive &  ar)

Archive for checkpoint and restart

◆ set_layer_pointers()

virtual void lbann::metric::set_layer_pointers ( std::vector< ViewingLayerPtr layers)
virtual

Set list of pointers to layers.

Reimplemented in lbann::layer_metric.

◆ setup()

virtual void lbann::metric::setup ( model m)
inlinevirtual

Setup metric.

Reimplemented in lbann::layer_metric.

Definition at line 115 of file metric.hpp.

Member Data Documentation

◆ m_comm

lbann_comm* lbann::metric::m_comm
private

LBANN communicator.

Definition at line 183 of file metric.hpp.

◆ m_evaluate_time

EvalType lbann::metric::m_evaluate_time = 0.0
private

Runtime for the metric evaluation.

Definition at line 189 of file metric.hpp.

◆ m_statistics

std::map<execution_mode, metric_statistics> lbann::metric::m_statistics
private

Metric statistics.

Definition at line 186 of file metric.hpp.


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