SANN: Sushi Artificial Neural Network
This is a short library for a simple but efficient neural network
Public Member Functions | Static Public Attributes | List of all members
sann::math::Func Class Reference

This class represent a mathematical function used as activation function. More...

#include <Func.hpp>

Collaboration diagram for sann::math::Func:
Collaboration graph
[legend]

Public Member Functions

 Func (const std::function< double(const double)> &func, const std::function< double(const double)> &derivative)
 The default constructor. More...
 
 Func (const Func &func)
 
double call (const double input) const
 Computes the function. More...
 
double derivative (const double input) const
 Computes the derivative of the function. More...
 

Static Public Attributes

static Func linear
 Returns the linear function. More...
 
static Func sigmoid
 Returns the sigmoid function with a slope parameters. More...
 
static Func tanH
 Returns the tanh function. More...
 
static Func ReLU
 Returns the relu function. More...
 

Detailed Description

This class represent a mathematical function used as activation function.

Constructor & Destructor Documentation

◆ Func()

sann::math::Func::Func ( const std::function< double(const double)> &  func,
const std::function< double(const double)> &  derivative 
)

The default constructor.

Parameters
func- The function.
derivative- The derivative of the function.

Member Function Documentation

◆ call()

double sann::math::Func::call ( const double  input) const

Computes the function.

Parameters
input- The input of the function.
Returns
double - The computed value.

◆ derivative()

double sann::math::Func::derivative ( const double  input) const

Computes the derivative of the function.

Parameters
input- The input of the derivative.
Returns
double - The computed derivative.

Member Data Documentation

◆ linear

Func sann::math::Func::linear
static
Initial value:
= Func(
[](const double x) -> double{
return x;
},
[](const double x) -> double{
return 1;
}
)

Returns the linear function.

Returns
Func - The linear function.

◆ ReLU

Func sann::math::Func::ReLU
static
Initial value:
= Func(
[](const double x) -> double{
return x > 0 ? x : 0;
},
[](const double x) -> double{
return x > 0 ? 1 : 0;
}
)

Returns the relu function.

Returns
Func - The relu function.

◆ sigmoid

Func sann::math::Func::sigmoid
static
Initial value:
= Func(
[](const double x) -> double{
return 1.0 / ( 1.0 + exp( -x ) );
},
[](const double x) -> double{
double ex = exp(x);
return ex / pow(ex + 1, 2);
}
)

Returns the sigmoid function with a slope parameters.

Parameters
slope- The slope parameters (1 by dafault).
Returns
Func - The sigmoid function.

◆ tanH

Func sann::math::Func::tanH
static
Initial value:
= Func(
[](const double x) -> double{
return (2 / (1 + exp(-x * 2))) - 1;
},
[](const double x) -> double{
return 1 - pow((2 / (1 + exp(-x * 2))) - 1, 2);
}
)

Returns the tanh function.

Returns
Func - The tanh function.

The documentation for this class was generated from the following files: