1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
impl Module for LeakyRelu { fn forward(&self, xs: &Tensor) -> Tensor { xs.max1(xs * self.slope) } } #[derive(Debug)] pub struct LeakyRelu { slope: f32, } impl LeakyRelu { pub fn new(slope: f32) -> LeakyRelu { LeakyRelu { slope } } }