Direct Graphical Models
v.1.7.0
|
Abstract base class for message passing inference algorithmes. More...
#include <MessagePassing.h>
Public Member Functions | |
CMessagePassing (CGraphPairwise &graph) | |
Constructor. More... | |
virtual | ~CMessagePassing (void) |
virtual void | infer (unsigned int nIt=1) |
Inference. More... | |
Public Member Functions inherited from DirectGraphicalModels::CInfer | |
CInfer (CGraph &graph) | |
Constructor. More... | |
CInfer (const CInfer &)=delete | |
virtual | ~CInfer ()=default |
const CInfer & | operator= (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... | |
Protected Member Functions | |
CGraphPairwise & | getGraphPairwise (void) const |
Returns the graph. More... | |
virtual void | calculateMessages (unsigned int nIt)=0 |
Calculates messages, associated with the edges of corresponding graphical model. More... | |
void | calculateMessage (Edge *edge, float *temp, float *&dst, bool maxSum=false) |
Calculates one message for the specified edge edge. More... | |
void | createMessages (void) |
Allocates memory for Edge::msg and Edge::msg_temp containers for all edges in the graph. More... | |
void | deleteMessages (void) |
Deletes memory for Edge::msg and Edge::msg_temp containers for all edges in the graph. More... | |
void | swapMessages (void) |
Swaps Edge::msg and Edge::msg_temp for all edges in the graph. More... | |
Protected Member Functions inherited from DirectGraphicalModels::CInfer | |
CGraph & | getGraph (void) const |
Returns the reference to the graph. More... | |
Static Protected Member Functions | |
static float | MatMul (const Mat &M, const float *v, float *&dst, bool maxSum=false) |
Specific matrix multiplication. More... | |
Abstract base class for message passing inference algorithmes.
Definition at line 18 of file MessagePassing.h.
|
inline |
|
inlinevirtual |
Definition at line 26 of file MessagePassing.h.
|
protected |
Calculates one message for the specified edge edge.
PPL-safe function.
[in] | edge | Graph edge |
[in] | temp | Auxilary array of nStates values. Introduced for higher perfomance reasons. |
[out] | dst | Destination array for calculated message. Usually edge->msg or edge->msg_temp. If the pointer is NULL, destination container will be created as a new vector of length nStates. |
[in] | maxSum | Flag indicating weather the message must be calculated according to the sum-product (false) or max-product (true) algorithm. |
Definition at line 82 of file MessagePassing.cpp.
|
protectedpure virtual |
Calculates messages, associated with the edges of corresponding graphical model.
This function may modify Edge::msg and Edge::msg_temp containers of graph edges
nIt | Number of iterations |
Implemented in DirectGraphicalModels::CInferChain, DirectGraphicalModels::CInferTree, DirectGraphicalModels::CInferTRW, and DirectGraphicalModels::CInferLBP.
|
protected |
Allocates memory for Edge::msg and Edge::msg_temp containers for all edges in the graph.
Definition at line 113 of file MessagePassing.cpp.
|
protected |
Deletes memory for Edge::msg and Edge::msg_temp containers for all edges in the graph.
Definition at line 129 of file MessagePassing.cpp.
|
inlineprotected |
Returns the graph.
Definition at line 36 of file MessagePassing.h.
|
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
nIt | Number of iterations |
Implements DirectGraphicalModels::CInfer.
Reimplemented in DirectGraphicalModels::CInferTRW.
Definition at line 7 of file MessagePassing.cpp.
|
staticprotected |
Specific matrix multiplication.
This function calculates the result of multiplying square of matrix M by vector v as following: \(\vec{dst} = (M\cdot M)^\top\times\vec{v}\)
[in] | M | Matrix: Mat(size: M.height x M.width; type: CV_32FC1) |
[in] | v | Vector of length M.height |
[out] | dst | Resulting vector. If the pointer is NULL, destination container will be created as a new vector of length M.width. |
[in] | maxSum | Flag indicating weather the max-sum multiplication should be performed |
Definition at line 157 of file MessagePassing.cpp.
|
protected |
Swaps Edge::msg and Edge::msg_temp for all edges in the graph.
Definition at line 147 of file MessagePassing.cpp.