Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CInfer Class Referenceabstract

Base abstract class for random model inference. More...

#include <Infer.h>

Inheritance diagram for DirectGraphicalModels::CInfer:
Collaboration diagram for DirectGraphicalModels::CInfer:

Public Member Functions

 CInfer (CGraph &graph)
 Constructor. More...
 
 CInfer (const CInfer &)=delete
 
virtual ~CInfer ()=default
 
const CInferoperator= (const CInfer &)=delete
 
virtual void infer (unsigned int nIt=1)=0
 Inference. More...
 
vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=EmptyMat)
 Approximate decoding. More...
 
vec_float_t getConfidence (void) const
 Returns the confidence of the perdiction. More...
 
vec_float_t getPotentials (byte state) const
 Returns the potnetials for the selected state (class) More...
 

Protected Member Functions

CGraphgetGraph (void) const
 Returns the reference to the graph. More...
 

Private Attributes

CGraphm_graph
 

Detailed Description

Base abstract class for random model inference.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 19 of file Infer.h.

Constructor & Destructor Documentation

◆ CInfer() [1/2]

DirectGraphicalModels::CInfer::CInfer ( CGraph graph)
inline

Constructor.

Parameters
graphThe graph

Definition at line 26 of file Infer.h.

◆ CInfer() [2/2]

DirectGraphicalModels::CInfer::CInfer ( const CInfer )
delete

◆ ~CInfer()

virtual DirectGraphicalModels::CInfer::~CInfer ( )
virtualdefault

Member Function Documentation

◆ decode()

vec_byte_t DirectGraphicalModels::CInfer::decode ( unsigned int  nIt = 0,
Mat &  lossMatrix = EmptyMat 
)

Approximate decoding.

This function calls first inference infer() and then, using resulting marginal probabilities, estimates the most probable configuration of states (classes) in the graph via CDecode::decode().

This function modifies Node::Pot containers of graph nodes

Parameters
nItNumber of iterations
lossMatrix(optional) The loss matrix \(L\) (size: nStates x nStates; type: CV_32FC1). It must be a quadratic zero-diagonal matrix, whith all non-diagonal elements \(L_{i,j} > 0, \forall i\neq j\). The elemets \(L_{i,j}\) represent a loss if state \(j\) is classified as a state \(i\).
Returns
The most probable configuration
Note
This function estimates the most likely configuration, based on the marginal probabilities (potentials) in graph nodes, which in general is NOT the same as the set of most likely states, which corresponds to the configuration with the highest joint probability. In other words:
using namespace DirectGraphicalModels;
CGraphPairwise * graph = new CGraphPairwise(nStates);
CInfer * inferer = new CInferExact(graph);
CDecode * decoder = new CDecodeExact(graph);
inferer->decode() == decoder->decode(); // This statement is not always true!

Definition at line 7 of file Infer.cpp.

Here is the call graph for this function:

◆ getConfidence()

vec_float_t DirectGraphicalModels::CInfer::getConfidence ( void  ) const

Returns the confidence of the perdiction.

This function calculates the confidence values for the predicted states (classes) in the graph via CInfer::decode(). The confidence values lie in range [0; 1].

Returns
The confidence values for each node of graph.

Definition at line 13 of file Infer.cpp.

Here is the call graph for this function:

◆ getGraph()

CGraph& DirectGraphicalModels::CInfer::getGraph ( void  ) const
inlineprotected

Returns the reference to the graph.

Returns
The reference to the graph

Definition at line 82 of file Infer.h.

Here is the caller graph for this function:

◆ getPotentials()

vec_float_t DirectGraphicalModels::CInfer::getPotentials ( byte  state) const

Returns the potnetials for the selected state (class)

Parameters
stateThe state (class) of interest
Returns
The potential values for each node of the graph.

Definition at line 33 of file Infer.cpp.

Here is the call graph for this function:

◆ infer()

virtual void DirectGraphicalModels::CInfer::infer ( unsigned int  nIt = 1)
pure virtual

Inference.

This function estimates the marginal potentials for each graph node, and stores them as node potentials

This function modifies Node::Pot containers of graph nodes

Parameters
nItNumber of iterations
Note
This function must not to be linear, i.e. \( infer(\alpha\times N)\not\equiv\alpha\times infer(N) \)
This function substitutes the graph nodes' potentials with estimated marginal potentials

Implemented in DirectGraphicalModels::CInferExact, DirectGraphicalModels::CInferTRW, DirectGraphicalModels::CInferDense, and DirectGraphicalModels::CMessagePassing.

Here is the caller graph for this function:

◆ operator=()

const CInfer& DirectGraphicalModels::CInfer::operator= ( const CInfer )
delete

Member Data Documentation

◆ m_graph

CGraph& DirectGraphicalModels::CInfer::m_graph
private

Definition at line 86 of file Infer.h.


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