Crates.io | activation_functions |
lib.rs | activation_functions |
version | 0.1.1 |
source | src |
created_at | 2021-07-10 07:13:40.111877 |
updated_at | 2021-07-10 12:06:00.26034 |
description | This is a collection of activation functions |
homepage | |
repository | https://github.com/SnefDenGames/activation_functions |
max_upload_size | |
id | 421017 |
size | 17,514 |
This is the quellcode of an rust crate called: activation_functions
Contents |
---|
Informations |
Documentation (GitHub) (docs.rs) |
Name | Value |
---|---|
Language | Rust |
Programer | SnefDen |
version | 0.1.0 |
last update | 10.07.2021 |
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 |
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn sigmoid(x:f32) -> f32 {
1 as f32 / (1 as f32 + std::f32::consts::E.powf(-x))
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn bstep(x:f32) -> f32 {
if x<0 as f32 {
0 as f32
} else {
1 as f32
}
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
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))
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn relu(x:f32) -> f32 {
if x<=0 as f32 {
0 as f32
} else {
1 as f32
}
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn silu(x:f32) -> f32 {
x / (1 as f32 + std::f32::consts::E.powf(-x))
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn gaussian(x:f32) -> f32 {
std::f32::consts::E.powf(-(x*x))
}
// variable stands for parameter
let x:f64; // float64
// variables
let x:f64; // parameter
let result:f64; // return variable
// functions
std::f64::consts::E.powf();
// variable stands for return
let result:f64; // float64
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
pub fn sigmoid(x:f64) -> f64 {
1 as f64 / (1 as f64 + std::f64::consts::E.powf(-x))
}
// variable stands for parameter
let x:f64; // float64
// variables
let x:f64; // parameter
let result:f64; // return variable
// functions
std::f64::consts::E.powf();
// variable stands for return
let result:f64; // float64
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
pub fn bstep(x:f64) -> f64 {
if x<0 as f64 {
0 as f64
} else {
1 as f64
}
}
// variable stands for parameter
let x:f64; // float64
// variables
let x:f64; // parameter
let result:f64; // return variable
// functions
std::f64::consts::E.powf();
// variable stands for return
let result:f64; // float64
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
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))
}
// variable stands for parameter
let x:f32; // float32
// variables
let x:f32; // parameter
let result:f32; // return variable
// functions
std::f32::consts::E.powf();
// variable stands for return
let result:f32; // float32
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
pub fn relu(x:f32) -> f32 {
if x<=0 as f32 {
0 as f32
} else {
1 as f32
}
}
// variable stands for parameter
let x:f64; // float64
// variables
let x:f64; // parameter
let result:f64; // return variable
// functions
std::f64::consts::E.powf();
// variable stands for return
let result:f64; // float64
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
pub fn silu(x:f64) -> f64 {
x / (1 as f64 + std::f64::consts::E.powf(-x))
}
// variable stands for parameter
let x:f64; // float64
// variables
let x:f64; // parameter
let result:f64; // return variable
// functions
std::f64::consts::E.powf();
// variable stands for return
let result:f64; // float64
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
pub fn gaussian(x:f64) -> f64 {
std::f64::consts::E.powf(-(x*x))
}