Newer
Older

Michal Kravcenko
committed
/**
* DESCRIPTION OF THE CLASS
*
* @author Martin Beseda
* @author Martin Mrovec
* @author Michal Kravčenko
* @date 2017 - 2018
*/
#ifndef INC_4NEURO_NEURONLOGISTIC_H
#define INC_4NEURO_NEURONLOGISTIC_H
Martin Beseda
committed
#include "../settings.h"
Martin Beseda
committed
#include "Neuron.h"
Martin Beseda
committed
namespace lib4neuro {
class NeuronLogistic : public NeuronDifferentiable {
Martin Beseda
committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
public:
/**
* Struct used to access private properties from
* the serialization function
*/
struct access;
/**
* Constructs the object of the Logistic neuron with activation function
* f(x) = (1 + e^(-x + b))^(-1)
*/
LIB4NEURO_API explicit NeuronLogistic();
/**
* Evaluates '(1 + e^(-x + b))^(-1)' and stores the result into the 'state' property
*/
LIB4NEURO_API virtual double activate(double x, double b) override;
/**
* Calculates the partial derivative of the activation function
* f(x) = (1 + e^(-x + b))^(-1)
* @return Partial derivative of the activation function according to the
* bias, returns: -e^(b - x)/(e^(b - x) + 1)^2
*/
LIB4NEURO_API virtual double activation_function_eval_derivative_bias(double x, double b) override;
/**
* Calculates d/dx of (1 + e^(-x + b))^(-1)
* @return e^(b - x)/(e^(b - x) + 1)^2
*/
LIB4NEURO_API virtual double activation_function_eval_derivative(double x, double b) override;
/**
* Returns a pointer to a Neuron with derivative as its activation function
* @return
*/
LIB4NEURO_API virtual NeuronLogistic *get_derivative() override;
};
class NeuronLogistic_d1 : public NeuronLogistic {
public:
/**
* Struct used to access private properties from
* the serialization function
*/
struct access;
/**
* Constructs the object of the Logistic neuron with activation function
* f(x) = e^(b - x)/(e^(b - x) + 1)^2
* @param[in] b Bias
*/
LIB4NEURO_API explicit NeuronLogistic_d1();
/**
* Evaluates 'e^(b - x)/(e^(b - x) + 1)^2' and returns the result
*/
LIB4NEURO_API virtual double activate(double x, double b) override;
/**
* Calculates the partial derivative of the activation function
* f(x) = e^(b - x)/(e^(b - x) + 1)^2
* @return Partial derivative of the activation function according to the
* bias, returns: (e^(b + x) (e^x - e^b))/(e^b + e^x)^3
*/
LIB4NEURO_API virtual double activation_function_eval_derivative_bias(double x, double b) override;
/**
* Calculates d/dx of e^(b - x)*(1 + e^(b - x))^(-2)
* @return (e^(b + x) (e^b - e^x))/(e^b + e^x)^3
*/
LIB4NEURO_API virtual double activation_function_eval_derivative(double x, double b) override;
/**
* Returns a pointer to a Neuron with derivative as its activation function
* @return
*/
LIB4NEURO_API virtual NeuronLogistic *get_derivative() override;
};
class NeuronLogistic_d2 : public NeuronLogistic_d1 {
public:
/**
* Struct used to access private properties from
* the serialization function
*/
struct access;
/**
* Constructs the object of the Logistic neuron with activation function
* f(x) = (e^(b + x) (e^b - e^x))/(e^b + e^x)^3
*/
LIB4NEURO_API explicit NeuronLogistic_d2();
/**
* Evaluates '(e^(b + x) (e^b - e^x))/(e^b + e^x)^3' and returns the result
*/
LIB4NEURO_API virtual double activate(double x, double b) override;
/**
* Calculates the partial derivative of the activation function
* f(x) = (e^(b + x) (e^b - e^x))/(e^b + e^x)^3
* @return Partial derivative of the activation function according to the
* bias, returns: -(e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4
*/
LIB4NEURO_API virtual double activation_function_eval_derivative_bias(double x, double b) override;
/**
* Calculates d/dx of (e^(b + x) (e^b - e^x))/(e^b + e^x)^3
* @return (e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4
*/
LIB4NEURO_API virtual double activation_function_eval_derivative(double x, double b) override;
/**
*
* @return
*/
LIB4NEURO_API virtual NeuronLogistic *get_derivative() override;
};
}
#endif //INC_4NEURO_NEURONLOGISTIC_H