pub struct GeneralGraphCrf {
pub node_potentials: Vec<f64>,
pub edge_potentials: Vec<f64>,
pub edges: Vec<Edge>,
/* private fields */
}Expand description
General-graph pairwise CRF with loopy belief propagation inference.
Fields§
§node_potentials: Vec<f64>Node unary log-potentials [n_nodes × n_labels].
edge_potentials: Vec<f64>Edge pairwise log-potentials [n_edges × n_labels × n_labels].
edges: Vec<Edge>Edge list.
Implementations§
Source§impl GeneralGraphCrf
impl GeneralGraphCrf
Sourcepub fn new(config: GraphCrfConfig, edges: Vec<Edge>) -> SeqResult<Self>
pub fn new(config: GraphCrfConfig, edges: Vec<Edge>) -> SeqResult<Self>
Create a new CRF with zero potentials and the given edges.
Validates that node indices in edges are within [0, n_nodes).
Sourcepub fn set_node_potential(
&mut self,
node: usize,
lbl: usize,
val: f64,
) -> SeqResult<()>
pub fn set_node_potential( &mut self, node: usize, lbl: usize, val: f64, ) -> SeqResult<()>
Set the unary log-potential for node node, label lbl.
Sourcepub fn set_edge_potential(
&mut self,
e_idx: usize,
li: usize,
lj: usize,
val: f64,
) -> SeqResult<()>
pub fn set_edge_potential( &mut self, e_idx: usize, li: usize, lj: usize, val: f64, ) -> SeqResult<()>
Set the pairwise log-potential for edge e_idx, labels (li, lj).
Sourcepub fn sum_product_marginals(&self) -> SeqResult<Vec<f64>>
pub fn sum_product_marginals(&self) -> SeqResult<Vec<f64>>
Run sum-product loopy belief propagation.
Returns marginal log-beliefs [n_nodes × n_labels] (normalised so that
Σ_label exp(beliefs[node * n_labels + label]) = 1).
Sourcepub fn map_decode(&self) -> SeqResult<Vec<usize>>
pub fn map_decode(&self) -> SeqResult<Vec<usize>>
Run max-product loopy BP to compute approximate MAP assignments.
Returns [n_nodes] with the argmax label for each node.
Trait Implementations§
Source§impl Clone for GeneralGraphCrf
impl Clone for GeneralGraphCrf
Source§fn clone(&self) -> GeneralGraphCrf
fn clone(&self) -> GeneralGraphCrf
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GeneralGraphCrf
impl RefUnwindSafe for GeneralGraphCrf
impl Send for GeneralGraphCrf
impl Sync for GeneralGraphCrf
impl Unpin for GeneralGraphCrf
impl UnsafeUnpin for GeneralGraphCrf
impl UnwindSafe for GeneralGraphCrf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more