pub struct LoopyBp { /* private fields */ }Expand description
Loopy belief-propagation engine for a fixed grid topology.
The grid geometry (edge list and per-node incident-message bookkeeping) is
built once in LoopyBp::new and reused across LoopyBp::infer calls.
Implementations§
Source§impl LoopyBp
impl LoopyBp
Sourcepub fn new(
height: usize,
width: usize,
n_states: usize,
config: LoopyBpConfig,
) -> SeqResult<Self>
pub fn new( height: usize, width: usize, n_states: usize, config: LoopyBpConfig, ) -> SeqResult<Self>
Build an inference engine for a height × width grid with n_states
labels per node.
§Errors
SeqError::InvalidConfigurationif any dimension is0orconfig.max_iter == 0.SeqError::InvalidParameterifconfig.dampingis outside(0, 1].
Sourcepub fn infer(&self, unary: &[f64], pairwise: &[f64]) -> SeqResult<Vec<f64>>
pub fn infer(&self, unary: &[f64], pairwise: &[f64]) -> SeqResult<Vec<f64>>
Run sum-product BP and return the per-node marginals [H*W*n_states],
normalised so each node’s distribution sums to 1.
§Errors
SeqError::ShapeMismatch if unary or pairwise has the wrong length.
Sourcepub fn infer_detailed(
&self,
unary: &[f64],
pairwise: &[f64],
) -> SeqResult<LoopyBpResult>
pub fn infer_detailed( &self, unary: &[f64], pairwise: &[f64], ) -> SeqResult<LoopyBpResult>
Run sum-product BP, returning marginals together with the sweep count and
whether convergence was reached. See LoopyBp::infer for the error
conditions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoopyBp
impl RefUnwindSafe for LoopyBp
impl Send for LoopyBp
impl Sync for LoopyBp
impl Unpin for LoopyBp
impl UnsafeUnpin for LoopyBp
impl UnwindSafe for LoopyBp
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