Newer
Older

Michal Kravcenko
committed
/**
* DESCRIPTION OF THE CLASS
*
* @author Martin Beseda
* @author Martin Mrovec
* @author Michal Kravčenko
* @date 2017 - 2018
*/
Martin Beseda
committed
#ifndef NEURON_H_
#define NEURON_H_
Martin Beseda
committed
#include "../settings.h"

Michal Kravcenko
committed
#include <vector>
Martin Beseda
committed
namespace lib4neuro {
Martin Beseda
committed
enum NEURON_TYPE {
BINARY,
CONSTANT,
LINEAR,
LOGISTIC
};
/**
* Abstract class representing a general neuron
*/
Martin Beseda
committed
class Neuron {

Michal Kravcenko
committed
protected:
/**
* holds the last value of the activation function, used by this->activate

Michal Kravcenko
committed
*/
double activation_val;
Martin Beseda
committed
public:
Martin Beseda
committed
/**
* Struct used to access private properties from
* the serialization function
*/
struct access;
Martin Beseda
committed
Martin Beseda
committed
/**
* Destructor of the Neuron object
* this level deallocates the array 'activation_function_parameters'
* also deallocates the OUTGOING connections
*/
LIB4NEURO_API virtual ~Neuron();
Martin Beseda
committed
/**
* Performs the activation function and returns the result
*/
LIB4NEURO_API virtual double activate(double x, double b) = 0;

Michal Kravcenko
committed
/**
* returns the last value of the actual activation function output for this neuron
* @return
*/
LIB4NEURO_API virtual double get_last_activation_value( );
Martin Beseda
committed
}; /* end of Neuron class */
/**
* Class serving as an interface providing 'activation_function_eval_partial_derivative',
* 'activation_function_eval_derivative', 'get_partial_derivative' and
* 'get_derivative' methods.
*/
class NeuronDifferentiable : public Neuron {
public:
/**
* Struct used to access private properties from
* the serialization function
*/
struct access;
Martin Beseda
committed
/**
* Calculates the derivative with respect to the argument, ie the 'potential'
* @return f'(x), where 'f(x)' is the activation function and 'x' = 'potential'
*/
virtual double activation_function_eval_derivative(double x, double b) = 0;
/**
* Calculates the derivative with respect to the bias
* @return d/db f'(x), where 'f(x)' is the activation function, 'x' is the 'potential'
* and 'b' is the bias
*/
virtual double activation_function_eval_derivative_bias(double x, double b) = 0;
/**
* Returns a Neuron pointer object with activation function being the partial derivative of
* the activation function of this Neuron object with respect to the argument, i.e. 'potential'
* @return
*/
virtual Neuron *get_derivative() = 0;
Martin Beseda
committed
}