Realm

oa::ml::nn::AdaptiveLogSoftmaxWithLoss

Two-level output layer: a head linear scores the most frequent classes plus one logit per tail cluster, while each tail cluster owns a projection and output linear that rescore its classes conditioned on the head cluster probability. Matches the nn.AdaptiveLogSoftmaxWithLoss contract: cutoffs partition 0..n_classes into a head range 0..cutoffs[0] and one tail cluster per cutoff, with tail i projecting in_features down to round(in_features / div_value^(i+1)) before its output linear.

StRust public API

Declaration

pub struct AdaptiveLogSoftmaxWithLoss { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn log_prob(&self, input: &Matrix) -> Result<Matrix>
pub fn forward( &self, input: &Matrix, target: &Matrix, ) -> Result<AdaptiveLogSoftmaxResult>
pub const fn in_features(&self) -> usize
pub const fn n_classes(&self) -> usize
fn forward(&self, input: &Matrix) -> Result<Matrix>
fn registry(&self) -> &ModuleRegistry
fn parameters(&self) -> Vec<Parameter>
fn named_parameters(&self) -> Vec<NamedParameter>
fn buffers(&self) -> Vec<Matrix>
fn named_buffers(&self) -> Vec<NamedBuffer>
fn all_parameters(&self) -> Result<Vec<Parameter>>
fn all_named_parameters(&self) -> Result<Vec<NamedParameter>>
fn all_named_buffers(&self) -> Result<Vec<NamedBuffer>>
fn all_named_state_u32(&self) -> Result<Vec<NamedStateU32>>
fn num_parameters(&self) -> Result<usize>
fn train(&self, training: bool)
fn eval(&self)
fn is_training(&self) -> bool
fn scoped_eval(&self) -> ScopedEval<'_>

Associated Functions

pub fn new( in_features: usize, n_classes: usize, cutoffs: &[usize], ) -> Result<Self>
pub fn new_with_seed( in_features: usize, n_classes: usize, cutoffs: &[usize], seed: u64, ) -> Result<Self>
pub fn new_with_seed_on( runtime: &Runtime, in_features: usize, n_classes: usize, cutoffs: &[usize], div_value: f64, head_bias: bool, _tail_bias: bool, seed: u64, ) -> Result<Self>
pub fn from_parts( in_features: usize, n_classes: usize, cutoffs: &[usize], head: Rc<Linear>, tails: Vec<(Rc<Linear>, Rc<Linear>)>, ) -> Result<Self>

Public Method Documentation

pub fn log_prob( &self, input: &Matrix ) -> Result<Matrix>
No public source comment is attached to this declaration.
pub fn forward( &self, input: &Matrix, target: &Matrix ) -> Result<AdaptiveLogSoftmaxResult>
No public source comment is attached to this declaration.
pub const fn in_features( &self ) -> usize
No public source comment is attached to this declaration.
pub const fn n_classes( &self ) -> usize
No public source comment is attached to this declaration.
fn forward( &self, input: &Matrix ) -> Result<Matrix>
No public source comment is attached to this declaration.
fn registry( &self ) -> &ModuleRegistry
No public source comment is attached to this declaration.
fn parameters( &self ) -> Vec<Parameter>
No public source comment is attached to this declaration.
fn named_parameters( &self ) -> Vec<NamedParameter>
No public source comment is attached to this declaration.
fn buffers( &self ) -> Vec<Matrix>
No public source comment is attached to this declaration.
fn named_buffers( &self ) -> Vec<NamedBuffer>
No public source comment is attached to this declaration.
fn all_parameters( &self ) -> Result<Vec<Parameter>>
No public source comment is attached to this declaration.
fn all_named_parameters( &self ) -> Result<Vec<NamedParameter>>
No public source comment is attached to this declaration.
fn all_named_buffers( &self ) -> Result<Vec<NamedBuffer>>
No public source comment is attached to this declaration.
fn all_named_state_u32( &self ) -> Result<Vec<NamedStateU32>>
No public source comment is attached to this declaration.
fn num_parameters( &self ) -> Result<usize>
No public source comment is attached to this declaration.
fn train( &self, training: bool )
No public source comment is attached to this declaration.
fn eval( &self )
No public source comment is attached to this declaration.
fn is_training( &self ) -> bool
No public source comment is attached to this declaration.
fn scoped_eval( &self ) -> ScopedEval<'_>
No public source comment is attached to this declaration.
pub fn new( in_features: usize, n_classes: usize, cutoffs: &[usize] ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn new_with_seed( in_features: usize, n_classes: usize, cutoffs: &[usize], seed: u64 ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn new_with_seed_on( runtime: &Runtime, in_features: usize, n_classes: usize, cutoffs: &[usize], div_value: f64, head_bias: bool, _tail_bias: bool, seed: u64 ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn from_parts( in_features: usize, n_classes: usize, cutoffs: &[usize], head: Rc<Linear>, tails: Vec<(Rc<Linear>, Rc<Linear>)> ) -> Result<Self>
No public source comment is attached to this declaration.