Skip to main content

PACBayesGeneralization

Struct PACBayesGeneralization 

Source
pub struct PACBayesGeneralization {
    pub kl_qp: f64,
    pub n: usize,
    pub delta: f64,
}
Expand description

PAC-Bayes generalization bound computation.

McAllester’s bound: L_D(Q) ≤ L_S(Q) + √((KL(Q‖P) + ln(n/δ)) / (2n)).

Fields§

§kl_qp: f64

KL divergence KL(Q‖P) in nats.

§n: usize

Number of training samples n.

§delta: f64

Confidence parameter δ.

Implementations§

Source§

impl PACBayesGeneralization

Source

pub fn new(kl_qp: f64, n: usize, delta: f64) -> Self

Create a new PAC-Bayes bound instance.

Source

pub fn mcallester_bound(&self, empirical_loss: f64) -> f64

McAllester bound: empirical_loss + √((KL + ln(n/δ)) / (2n)).

Source

pub fn catoni_bound(&self, empirical_loss: f64, lambda: f64) -> f64

Catoni’s tighter bound (using solve for λ-parameterized form). Approximation: L_D(Q) ≤ (1/(1-λ/2)) * (L_S(Q) + KL/(2λn)).

Source

pub fn optimal_lambda(&self, empirical_loss: f64) -> f64

Optimal λ for Catoni bound (minimizing RHS).

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> 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, 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.