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,16 +55,24 @@ pub trait HasSigm {
|
|||||||
|
|
||||||
impl HasSigm for f32 {
|
impl HasSigm for f32 {
|
||||||
fn sigm(self) -> Self {
|
fn sigm(self) -> Self {
|
||||||
|
if self >= 0.0 {
|
||||||
|
1.0 / (1.0 + (-self).exp())
|
||||||
|
} else {
|
||||||
let ex = self.exp();
|
let ex = self.exp();
|
||||||
ex / (1.0 + ex)
|
ex / (1.0 + ex)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasSigm for f64 {
|
impl HasSigm for f64 {
|
||||||
fn sigm(self) -> Self {
|
fn sigm(self) -> Self {
|
||||||
|
if self >= 0.0 {
|
||||||
|
1.0 / (1.0 + (-self).exp())
|
||||||
|
} else {
|
||||||
let ex = self.exp();
|
let ex = self.exp();
|
||||||
ex / (1.0 + ex)
|
ex / (1.0 + ex)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasExp {
|
pub trait HasExp {
|
||||||
|
|||||||
Reference in New Issue
Block a user