NeuronConstant.h 1.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/**
 * DESCRIPTION OF THE FILE
 *
 * @author Michal Kravčenko
 * @date 8.8.18 -
 */

#ifndef INC_4NEURO_NEURONCONSTANT_H
#define INC_4NEURO_NEURONCONSTANT_H


Michal Kravcenko's avatar
Michal Kravcenko committed
12
#include "Neuron.h"
13

Michal Kravcenko's avatar
Michal Kravcenko committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
class NeuronConstant: public Neuron, public IDifferentiable {
    friend class boost::serialization::access;

protected:
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version){
        //TODO separate implementation to NeuronLinear.cpp!
        ar & boost::serialization::base_object<Neuron>(*this);
    };

public:

    /**
     * Constructs the object of the Linear neuron with activation function
     * f(x) = c
     * @param[in] c Constant value
     */
    explicit NeuronConstant( double c = 0.0 );
32

Michal Kravcenko's avatar
Michal Kravcenko committed
33 34 35 36
    /**
     * Evaluates and returns 'c'
     */
    double activate( double x ) override;
37

Michal Kravcenko's avatar
Michal Kravcenko committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    /**
     * Calculates the partial derivative of the activation function
     * f(x) = c at point x
     * @return Partial derivative of the activation function according to the
     * 'bias' parameter. Returns 0.0
     */
    double activation_function_eval_derivative_bias( double x ) override;

    /**
     * Calculates d/dx of (c) at point x
     * @return 0.0
     */
    double activation_function_eval_derivative( double x ) override;

    /**
     * Returns a pointer to a Neuron with derivative as its activation function
     * @return
     */
    Neuron* get_derivative( ) override;
private:
    double p = 0.0;
};
60
#endif //INC_4NEURO_NEURONCONSTANT_H