pub struct KSvd {
pub n_atoms: usize,
pub sparsity: usize,
pub n_iter: usize,
}Expand description
K-SVD dictionary learning algorithm.
Alternates between a sparse coding stage (OMP) and a dictionary update stage (rank-1 SVD update) to learn an overcomplete dictionary adapted to training data.
Reference: Aharon, Elad & Bruckstein (2006).
Fields§
§n_atoms: usizeNumber of dictionary atoms (columns).
sparsity: usizeTarget sparsity per signal.
n_iter: usizeNumber of training iterations.
Implementations§
Source§impl KSvd
impl KSvd
Sourcepub fn new(n_atoms: usize, sparsity: usize, n_iter: usize) -> Self
pub fn new(n_atoms: usize, sparsity: usize, n_iter: usize) -> Self
Create a new K-SVD learner.
n_atoms— number of dictionary atomssparsity— maximum number of atoms per signaln_iter— number of alternating optimisation iterations
Sourcepub fn fit(&self, signals: &[Vec<f64>]) -> Vec<Vec<f64>>
pub fn fit(&self, signals: &[Vec<f64>]) -> Vec<Vec<f64>>
Learn a dictionary from training signals.
signals— list of training signals (each of the same lengthd)
Returns a dictionary matrix D of shape d × n_atoms (columns are atoms,
stored as Vec<Vecf64> in row-major form, i.e. D[i][j] is row i, atom j).
Auto Trait Implementations§
impl Freeze for KSvd
impl RefUnwindSafe for KSvd
impl Send for KSvd
impl Sync for KSvd
impl Unpin for KSvd
impl UnsafeUnpin for KSvd
impl UnwindSafe for KSvd
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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.