fix sigmoid implementation stability in pim-simulator
All checks were successful
Validate Operations / validate-operations (push) Successful in 23m4s
All checks were successful
Validate Operations / validate-operations (push) Successful in 23m4s
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user