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
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;
Martin Beseda
committed
};
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;
Martin Beseda
committed
/**
* 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;
Martin Beseda
committed
/**
* 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;
Martin Beseda
committed
/**
* Returns a pointer to a Neuron with derivative as its activation function
* @return
*/
LIB4NEURO_API virtual NeuronLogistic *get_derivative() override;
Martin Beseda
committed
};
class NeuronLogistic_d2 : public NeuronLogistic_d1 {
Martin Beseda
committed
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;
Martin Beseda
committed
/**
* 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;
Martin Beseda
committed
/**
* 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;
Martin Beseda
committed
/**
*
* @return
*/
LIB4NEURO_API virtual NeuronLogistic *get_derivative() override;
Martin Beseda
committed
};
}
#endif //INC_4NEURO_NEURONLOGISTIC_H