pub struct PoissonNllLossConfig {
pub log_input: bool,
pub full: bool,
pub eps: f64,
}Expand description
Configuration for creating a PoissonNllLoss instance.
This configuration allows customization of the Poisson Negative Log Likelihood (NLL) loss behavior, such as whether the input is in log-space, whether to include the Stirling approximation term, and a small epsilon value to avoid numerical instability.
Fields§
§log_input: boolIf true, the predictions are expected to be in log-space.
When log_input is true, the loss is computed as:
L(predictions, target) = exp(predictions) - target * predictionsWhen log_input is false, the loss is computed as:
L(predictions, target) = predictions - target * log(predictions + eps)full: boolWhether to compute the full loss, including the Stirling approximation term.
When full is true, the Stirling approximation term is added to the loss:
target * log(target) - target + 0.5 * log(2 * PI * target)eps: f64A small value to avoid evaluation of log(0) when log_input is false.
This epsilon value is added to the predictions to ensure numerical stability when computing the logarithm.
Implementations§
Source§impl PoissonNllLossConfig
impl PoissonNllLossConfig
Source§impl PoissonNllLossConfig
impl PoissonNllLossConfig
Sourcepub fn init(&self) -> PoissonNllLoss
pub fn init(&self) -> PoissonNllLoss
Initializes a PoissonNllLoss instance with the current configuration.
§Panics
- Panics if
epsis not a positive number.
Trait Implementations§
Source§impl Clone for PoissonNllLossConfig
impl Clone for PoissonNllLossConfig
Source§impl Config for PoissonNllLossConfig
impl Config for PoissonNllLossConfig
Source§fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
std only.Source§fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
std only.Source§fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
Source§impl Debug for PoissonNllLossConfig
impl Debug for PoissonNllLossConfig
Source§impl<'de> Deserialize<'de> for PoissonNllLossConfig
impl<'de> Deserialize<'de> for PoissonNllLossConfig
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for PoissonNllLossConfig
impl Display for PoissonNllLossConfig
Auto Trait Implementations§
impl Freeze for PoissonNllLossConfig
impl RefUnwindSafe for PoissonNllLossConfig
impl Send for PoissonNllLossConfig
impl Sync for PoissonNllLossConfig
impl Unpin for PoissonNllLossConfig
impl UnwindSafe for PoissonNllLossConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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