fix sigmoid implementation stability in pim-simulator
All checks were successful
Validate Operations / validate-operations (push) Successful in 23m4s

This commit is contained in:
NiccoloN
2026-04-23 10:34:29 +02:00
parent 89b3501aa8
commit cff929a083

View File

@@ -55,15 +55,23 @@ pub trait HasSigm {
impl HasSigm for f32 {
fn sigm(self) -> Self {
let ex = self.exp();
ex / (1.0 + ex)
if self >= 0.0 {
1.0 / (1.0 + (-self).exp())
} else {
let ex = self.exp();
ex / (1.0 + ex)
}
}
}
impl HasSigm for f64 {
fn sigm(self) -> Self {
let ex = self.exp();
ex / (1.0 + ex)
if self >= 0.0 {
1.0 / (1.0 + (-self).exp())
} else {
let ex = self.exp();
ex / (1.0 + ex)
}
}
}