activation_functions

Crates.ioactivation_functions
lib.rsactivation_functions
version0.1.1
sourcesrc
created_at2021-07-10 07:13:40.111877
updated_at2021-07-10 12:06:00.26034
descriptionThis is a collection of activation functions
homepage
repositoryhttps://github.com/SnefDenGames/activation_functions
max_upload_size
id421017
size17,514
(SnefDenGames)

documentation

README

Activation Functions

Description:

This is the quellcode of an rust crate called: activation_functions

Table of Contents

Contents
Informations
Documentation (GitHub) (docs.rs)

Some informations:

Name Value
Language Rust
Programer SnefDen
version 0.1.0
last update 10.07.2021

Documentation

Table of Contents

sigmoid binary step tanh rectified linear unit sigmoid linear unit gaussian
f32 f32::sigmoid f32::bstep f32::tanh f32::relu f32::silu f32::gaussian
f64 f64::sigmoid f64::bstep f64::tanh f64::relu f64::silu f64::gaussian

f32

sigmoid(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = sigmoid(x);

println!("sigmoid({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

sigmoid(0.5) => 0.62245935

Implementation:

pub fn sigmoid(x:f32) -> f32 {
    1 as f32 / (1 as f32 + std::f32::consts::E.powf(-x))
}

bstep(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = bstep(x);

println!("bstep({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

bstep(0.5) => 1.0

Implementation:

pub fn bstep(x:f32) -> f32 {
    if x<0 as f32 {
        0 as f32
    } else {
        1 as f32
    }
}

tanh(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = tanh(x);

println!("tanh({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

tanh(0.5) => 0.46211714

Implementation:

pub fn tanh(x:f32) -> f32 {
    (std::f32::consts::E.powf(x) - std::f32::consts::E.powf(-x)) / (std::f32::consts::E.powf(x) + std::f32::consts::E.powf(-x))
}

relu(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = relu(x);

println!("relu({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

relu(0.5) => 1.0

Implementation:

pub fn relu(x:f32) -> f32 {
    if x<=0 as f32 {
        0 as f32
    } else {
        1 as f32
    }
}

silu(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = silu(x);

println!("silu({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

silu(0.5) => 0.31122968

Implementation:

pub fn silu(x:f32) -> f32 {
    x / (1 as f32 + std::f32::consts::E.powf(-x))
}

gaussian(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = gaussian(x);

println!("gaussian({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

gaussian(0.5) => 0.7788008

Implementation:

pub fn gaussian(x:f32) -> f32 {
    std::f32::consts::E.powf(-(x*x))
}

f64

sigmoid(x):

Informations:

Parameter:

// variable stands for parameter

let x:f64;          // float64

Used inside:

//      variables
let x:f64;          // parameter
let result:f64;     // return variable

//      functions
std::f64::consts::E.powf();

Return:

// variable stands for return

let result:f64;     // float64

Example:

let x:f64   = 0.5;
let answer  = sigmoid(x);

println!("sigmoid({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

sigmoid(0.5) => 0.62245935

Implementation:

pub fn sigmoid(x:f64) -> f64 {
    1 as f64 / (1 as f64 + std::f64::consts::E.powf(-x))
}

bstep(x):

Informations:

Parameter:

// variable stands for parameter

let x:f64;          // float64

Used inside:

//      variables
let x:f64;          // parameter
let result:f64;     // return variable

//      functions
std::f64::consts::E.powf();

Return:

// variable stands for return

let result:f64;     // float64

Example:

let x:f64   = 0.5;
let answer  = bstep(x);

println!("bstep({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

bstep(0.5) => 1.0

Implementation:

pub fn bstep(x:f64) -> f64 {
    if x<0 as f64 {
        0 as f64
    } else {
        1 as f64
    }
}

tanh(x):

Informations:

Parameter:

// variable stands for parameter

let x:f64;          // float64

Used inside:

//      variables
let x:f64;          // parameter
let result:f64;     // return variable

//      functions
std::f64::consts::E.powf();

Return:

// variable stands for return

let result:f64;     // float64

Example:

let x:f64   = 0.5;
let answer  = tanh(x);

println!("tanh({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

tanh(0.5) => 0.46211714

Implementation:

pub fn tanh(x:f64) -> f64 {
    (std::f64::consts::E.powf(x) - std::f64::consts::E.powf(-x)) / (std::f64::consts::E.powf(x) + std::f64::consts::E.powf(-x))
}

relu(x):

Informations:

Parameter:

// variable stands for parameter

let x:f32;          // float32

Used inside:

//      variables
let x:f32;          // parameter
let result:f32;     // return variable

//      functions
std::f32::consts::E.powf();

Return:

// variable stands for return

let result:f32;     // float32

Example:

let x:f32   = 0.5;
let answer  = relu(x);

println!("relu({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

relu(0.5) => 1.0

Implementation:

pub fn relu(x:f32) -> f32 {
    if x<=0 as f32 {
        0 as f32
    } else {
        1 as f32
    }
}

silu(x):

Informations:

Parameter:

// variable stands for parameter

let x:f64;          // float64

Used inside:

//      variables
let x:f64;          // parameter
let result:f64;     // return variable

//      functions
std::f64::consts::E.powf();

Return:

// variable stands for return

let result:f64;     // float64

Example:

let x:f64   = 0.5;
let answer  = silu(x);

println!("silu({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

silu(0.5) => 0.31122968

Implementation:

pub fn silu(x:f64) -> f64 {
    x / (1 as f64 + std::f64::consts::E.powf(-x))
}

gaussian(x):

Informations:

Parameter:

// variable stands for parameter

let x:f64;          // float64

Used inside:

//      variables
let x:f64;          // parameter
let result:f64;     // return variable

//      functions
std::f64::consts::E.powf();

Return:

// variable stands for return

let result:f64;     // float64

Example:

let x:f64   = 0.5;
let answer  = gaussian(x);

println!("gaussian({}) => {}",x,answer);

that would print out the answer and the given x-value in this format

gaussian(0.5) => 0.7788008

Implementation:

pub fn gaussian(x:f64) -> f64 {
    std::f64::consts::E.powf(-(x*x))
}

Commit count: 5

cargo fmt