Skip to content
Snippets Groups Projects
NeuronBiased.h 1.79 KiB
/**
 * DESCRIPTION OF THE FILE
 *
 * @author Michal Kravčenko
 * @date 15.3.19 -
 */

#ifndef LIB4NEURO_NEURONBIASED_H
#define LIB4NEURO_NEURONBIASED_H

#include "Neuron.h"

namespace lib4neuro {
    class NeuronBiased : public NeuronDifferentiable {

    protected:

        double bias;

    public:

        /**
         * Struct used to access private properties from
         * the serialization function
         */
        struct access;

        /**
         * Constructs the object of the Linear neuron with activation function
         * f(x) = x + b
         * @param[in] b Bias
         */
        LIB4NEURO_API explicit NeuronBiased(double b = 0);

        /**
         * Evaluates 'x + this->bias' and stores the result into the 'state' property
         */
        LIB4NEURO_API double activate(double x,
                                      double b) override;

        /**
         * Calculates the partial derivative of the activation function
         * f(x) = x + this->bias at point x
         * @return Partial derivative of the activation function according to the
         * 'bias' parameter. Returns 0.0
         */
        LIB4NEURO_API double activation_function_eval_derivative_bias(double x,
                                                                      double b) override;

        /**
         * Calculates d/dx of (x + this->bias) at point x
         * @return 1.0
         */
        LIB4NEURO_API 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 Neuron* get_derivative() override;
    };

}//end of namespace lib4neuro

#endif //LIB4NEURO_NEURONBIASED_H