pub struct LinearChainCrf {
pub n_labels: usize,
pub n_features: usize,
pub emissions: Vec<f64>,
pub transitions: Vec<f64>,
}Expand description
Linear-chain CRF with linear emissions over real-valued features and a full dense transition matrix.
emissions[label*n_features + k]— emission weight w_k for labeltransitions[prev*n_labels + cur]— transition weight fromprevtocur
Fields§
§n_labels: usize§n_features: usize§emissions: Vec<f64>§transitions: Vec<f64>Implementations§
Source§impl LinearChainCrf
impl LinearChainCrf
Sourcepub fn zeros(n_labels: usize, n_features: usize) -> SeqResult<Self>
pub fn zeros(n_labels: usize, n_features: usize) -> SeqResult<Self>
Construct a zero-initialised CRF.
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Number of free parameters (emissions + transitions).
Sourcepub fn to_params(&self) -> Vec<f64>
pub fn to_params(&self) -> Vec<f64>
Pack (emissions, transitions) into a flat parameter vector.
Sourcepub fn from_params(&mut self, p: &[f64]) -> SeqResult<()>
pub fn from_params(&mut self, p: &[f64]) -> SeqResult<()>
Unpack a flat parameter vector into (emissions, transitions).
Sourcepub fn emit_score(&self, label: usize, x: &[f64]) -> SeqResult<f64>
pub fn emit_score(&self, label: usize, x: &[f64]) -> SeqResult<f64>
Compute the emission score for a single (label, feature_vec) pair.
Trait Implementations§
Source§impl Clone for LinearChainCrf
impl Clone for LinearChainCrf
Source§fn clone(&self) -> LinearChainCrf
fn clone(&self) -> LinearChainCrf
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 LinearChainCrf
impl RefUnwindSafe for LinearChainCrf
impl Send for LinearChainCrf
impl Sync for LinearChainCrf
impl Unpin for LinearChainCrf
impl UnsafeUnpin for LinearChainCrf
impl UnwindSafe for LinearChainCrf
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