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
use crate::core::activations::activation::Activation;
use crate::core::types::Vector;
use ndarray::Ix1;

pub struct ReLU;

impl Activation<Ix1> for ReLU {
    fn activate(z: &Vector) -> Vector {
        z.mapv(|x| x.max(0.0))
    }

    fn derivative(z: &Vector) -> Vector {
        z.map(|&x| if x > 0.0 { 1.0 } else { 0.0 })
    }
}