SANN: Sushi Artificial Neural Network
This is a short library for a simple but efficient neural network
Func.hpp
1 /*******************************************************
2  * *
3  * sann: Neural Network library *
4  * *
5  * FUNC CLASS HEADER *
6  * *
7  * Giulio Auriemma *
8  * *
9  *******************************************************/
10 
11 #ifndef S_MATH_FUNC_S
12 #define S_MATH_FUNC_S
13 
14 // System libraries include.
15 #include <vector>
16 #include <math.h>
17 #include <functional>
18 
19 namespace sann{
20 
21 namespace math{
22 
24 class Func{
25 
26 private:
27 
28  // ATTRIBUTE
29 
30  std::function<double(const double)> func; // The function.
31  std::function<double(const double)> deriv; // The function's derivative.
32 
33 public:
34 
35  // Default constructor.
36  Func(const std::function<double(const double)> &func, const std::function<double(const double)> &derivative);
37  // Copy constructor.
38  Func(const Func &func);
39 
40  // METHODS
41 
42  double call(const double input) const;
43  double derivative(const double input) const;
44 
45  // STANDARD FUNCTION
46 
47  static Func linear;
48  static Func sigmoid;
49  static Func tanH;
50  static Func ReLU;
51 };
52 
53 }
54 
55 }
56 
57 #endif
static Func tanH
Returns the tanh function.
Definition: Func.hpp:49
This class represent a mathematical function used as activation function.
Definition: Func.hpp:24
static Func ReLU
Returns the relu function.
Definition: Func.hpp:50
double derivative(const double input) const
Computes the derivative of the function.
Definition: Func.cpp:42
static Func linear
Returns the linear function.
Definition: Func.hpp:47
Definition: constants.h:15
Func(const std::function< double(const double)> &func, const std::function< double(const double)> &derivative)
The default constructor.
Definition: Func.cpp:21
double call(const double input) const
Computes the function.
Definition: Func.cpp:32
static Func sigmoid
Returns the sigmoid function with a slope parameters.
Definition: Func.hpp:48