Fix the leaky relu. (#898)

This commit is contained in:
Laurent Mazare
2023-09-19 18:17:17 +01:00
committed by GitHub
parent 4f91c8e109
commit 34f2ecbc3b

View File

@ -45,7 +45,8 @@ pub fn sigmoid(xs: &Tensor) -> Result<Tensor> {
}
pub fn leaky_relu(xs: &Tensor, negative_slope: f64) -> Result<Tensor> {
xs.relu()?.minimum(&(xs * negative_slope)?)
let zeros = xs.zeros_like()?;
xs.maximum(&zeros)? + xs.minimum(&zeros)? * negative_slope
}
pub fn dropout(xs: &Tensor, drop_p: f32) -> Result<Tensor> {