Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CInferExact Class Reference

Exact inference class. More...

#include <InferExact.h>

Inheritance diagram for DirectGraphicalModels::CInferExact:
Collaboration diagram for DirectGraphicalModels::CInferExact:

Public Member Functions

 CInferExact (IGraphPairwise &graph)
 Constructor. More...
 
virtual ~CInferExact (void)=default
 
virtual void infer (unsigned int nIt=0)
 Exact inference. More...
 
vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=EmptyMat)
 Approximate decoding. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CInfer
 CInfer (CGraph &graph)
 Constructor. More...
 
 CInfer (const CInfer &)=delete
 
virtual ~CInfer ()=default
 
const CInferoperator= (const CInfer &)=delete
 
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...
 

Additional Inherited Members

- Protected Member Functions inherited from DirectGraphicalModels::CInfer
CGraphgetGraph (void) const
 Returns the reference to the graph. More...
 
- Private Member Functions inherited from DirectGraphicalModels::CDecodeExact
 CDecodeExact (IGraphPairwise &graph)
 Constructor. More...
 
virtual ~CDecodeExact (void)
 
virtual vec_byte_t decode (Mat &lossMatrix=EmptyMat) const
 Exact decoding. More...
 
IGraphPairwisegetGraphPairwise (void) const
 Returns the graph. More...
 
void setState (vec_byte_t &state, qword configuration) const
 Sets the state according to the configuration index configuration. More...
 
void incState (vec_byte_t &state) const
 Increases the state by one, i.e. switches the state array to the consequent configuration. More...
 
vec_float_t calculatePotentials (void) const
 Calculates potentials for all possible configurations. More...
 
- Private Member Functions inherited from DirectGraphicalModels::CDecode
virtual ~CDecode (void)
 
 CDecode (CGraph &graph)
 Constructor. More...
 
CGraphgetGraph (void) const
 Returns the reference to the graph. More...
 
- Static Private Member Functions inherited from DirectGraphicalModels::CDecode
static vec_byte_t decode (const CGraph &graph, Mat &lossMatrix=EmptyMat)
 Approximate decoding. More...
 
static Mat getDefaultLossMatrix (byte nStates)
 Returns a default loss matrix \(L\). More...
 

Detailed Description

Exact inference class.

Note
Use this class only if \( nStates^{nNodes} < 2^{32}\)
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 17 of file InferExact.h.

Constructor & Destructor Documentation

◆ CInferExact()

DirectGraphicalModels::CInferExact::CInferExact ( IGraphPairwise graph)
inline

Constructor.

Parameters
graphThe graph

Definition at line 24 of file InferExact.h.

◆ ~CInferExact()

virtual DirectGraphicalModels::CInferExact::~CInferExact ( void  )
virtualdefault

Member Function Documentation

◆ decode()

vec_byte_t DirectGraphicalModels::CInfer::decode

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.

◆ infer()

void DirectGraphicalModels::CInferExact::infer ( unsigned int  nIt = 0)
virtual

Exact inference.

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. It means the following:

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!
Parameters
nItis not used
Note
This function changes the graph nodes' potentials

Implements DirectGraphicalModels::CInfer.

Definition at line 7 of file InferExact.cpp.

Here is the call graph for this function:

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