Struct PoissonNllLossConfig
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: bool
If 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 * predictions
When log_input
is false
, the loss is computed as:
L(predictions, target) = predictions - target * log(predictions + eps)
full: bool
Whether 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: f64
A 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§
§
impl PoissonNllLossConfig
impl PoissonNllLossConfig
pub fn new() ->
PoissonNllLossConfig
pub fn new() -> PoissonNllLossConfig
Create a new instance of the config.
§
impl PoissonNllLossConfig
impl PoissonNllLossConfig
pub fn with_log_input(self, log_input: bool)
-> PoissonNllLossConfig
pub fn with_log_input(self, log_input: bool) -> PoissonNllLossConfig
If true
, the predictions are expected to be in log-space.
pub fn with_full(self, full: bool)
-> PoissonNllLossConfig
pub fn with_full(self, full: bool) -> PoissonNllLossConfig
Whether to compute the full loss, including the Stirling approximation term.
pub fn with_eps(self, eps: f64)
-> PoissonNllLossConfig
pub fn with_eps(self, eps: f64) -> PoissonNllLossConfig
A small value to avoid evaluation of log(0)
when
log_input
is false
.
§
impl PoissonNllLossConfig
impl PoissonNllLossConfig
pub fn init(&self) -> PoissonNllLoss
pub fn init(&self) -> PoissonNllLoss
Initializes a PoissonNllLoss instance with the current configuration.
§Panics
- Panics if
eps
is not a positive number.
Trait Implementations§
§
impl Clone for PoissonNllLossConfig
impl Clone for PoissonNllLossConfig
§
fn clone(&self) -> PoissonNllLossConfig
fn clone(&self) -> PoissonNllLossConfig
1.0.0 · Source§
fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read
more
§
impl Config for PoissonNllLossConfig
impl Config for PoissonNllLossConfig
§
fn load<P>(file: P) -> Result<Self, ConfigError>
fn load<P>(file: P) -> Result<Self, ConfigError>
§
fn load_binary(data: &[u8])
-> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
§
impl Debug for PoissonNllLossConfig
impl Debug for PoissonNllLossConfig
§
impl<'de> Deserialize<'de> for PoissonNllLossConfig
impl<'de> Deserialize<'de> for PoissonNllLossConfig
§
fn deserialize<D>(
deserializer: D,
) -> Result<PoissonNllLossConfig,
<D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PoissonNllLossConfig,
<D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§
impl Display for PoissonNllLossConfig
impl Display for PoissonNllLossConfig
§
impl Serialize for PoissonNllLossConfig
impl Serialize for PoissonNllLossConfig
§
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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,
§
impl<T> Instrument for T
impl<T> Instrument for T
§
fn instrument(self, span: Span) ->
Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§
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
more
Source§
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
§
impl<T> Pointable for T
impl<T> Pointable for T
§
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§
impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§
fn try_to_compact_string(&self)
-> Result<CompactString,
ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
] Read more
§
fn to_compact_string(&self) ->
CompactString
fn to_compact_string(&self) -> CompactString
CompactString
].
Read more
§
impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§
fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
,
but without panic on OOM.