rust-ml 0.1.5

A collection of machine learning algorithms implemented in pure Rust (personal project for practice).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::core::activations::activation::Activation;
use ndarray::{Array, Ix1};

pub struct LeakyReLU;

impl Activation<Ix1> for LeakyReLU {
    fn activate(z: &Array<f64, Ix1>) -> Array<f64, Ix1> {
        let alpha = 0.01;
        z.mapv(|x| if x > 0.0 { x } else { alpha * x })
    }

    fn derivative(z: &Array<f64, Ix1>) -> Array<f64, Ix1> {
        let alpha = 0.01;
        z.mapv(|x| if x > 0.0 { 1.0 } else { alpha })
    }
}