EnergyBasedModel

Struct EnergyBasedModel 

Source
pub struct EnergyBasedModel { /* private fields */ }
Expand description

Energy-based model for semi-supervised learning

This implements an energy-based model that learns to assign low energy to data samples and high energy to unlikely samples. The model combines energy minimization with classification for semi-supervised learning.

Implementations§

Source§

impl EnergyBasedModel

Source

pub fn new() -> Self

Create a new energy-based model

Source

pub fn hidden_dims(self, dims: Vec<usize>) -> Self

Set the hidden layer dimensions

Source

pub fn n_classes(self, n_classes: usize) -> Self

Set the number of classes

Source

pub fn input_dim(self, input_dim: usize) -> Self

Set the input dimension

Source

pub fn learning_rate(self, lr: f64) -> Self

Set the learning rate

Source

pub fn epochs(self, epochs: usize) -> Self

Set the number of epochs

Source

pub fn regularization(self, reg: f64) -> Self

Set the regularization parameter

Source

pub fn n_negative_samples(self, n_samples: usize) -> Self

Set the number of negative samples

Source

pub fn temperature(self, temp: f64) -> Self

Set the temperature parameter

Source

pub fn classification_weight(self, weight: f64) -> Self

Set the classification weight

Source

pub fn margin(self, margin: f64) -> Self

Set the contrastive margin

Source

pub fn energy_to_probability(&self, energy: f64) -> f64

Compute Boltzmann probability from energy

Source

pub fn langevin_sample( &self, initial_sample: &ArrayView1<'_, f64>, n_steps: usize, step_size: f64, ) -> Result<Array1<f64>, SklearsError>

Sample from the model using Langevin dynamics

Source

pub fn log_partition_function( &self, n_samples: usize, ) -> Result<f64, SklearsError>

Compute the partition function approximation

Trait Implementations§

Source§

impl Clone for EnergyBasedModel

Source§

fn clone(&self) -> EnergyBasedModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EnergyBasedModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EnergyBasedModel

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>> for EnergyBasedModel

Source§

type Fitted = EnergyBasedModel

The fitted model type
Source§

fn fit( self, X: &ArrayView2<'_, f64>, y: &ArrayView1<'_, i32>, ) -> Result<Self::Fitted, SklearsError>

Fit the model to the provided data with validation
Source§

fn fit_with_validation( self, x: &X, y: &Y, _x_val: Option<&X>, _y_val: Option<&Y>, ) -> Result<(Self::Fitted, FitMetrics), SklearsError>
where Self: Sized,

Fit with custom validation and early stopping
Source§

impl Predict<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for EnergyBasedModel

Source§

fn predict(&self, X: &ArrayView2<'_, f64>) -> Result<Array1<i32>, SklearsError>

Make predictions on the provided data
Source§

fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>

Make predictions with confidence intervals
Source§

impl PredictProba<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>> for EnergyBasedModel

Source§

fn predict_proba( &self, X: &ArrayView2<'_, f64>, ) -> Result<Array2<f64>, SklearsError>

Predict class probabilities

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V