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 Tanh;

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

    fn derivative(z: &Vector) -> Vector {
        z.mapv(|x| 1.0 - x.tanh().powi(2))
    }
}