diff --git a/src/Neuron/NeuronBiased.cpp b/src/Neuron/NeuronBiased.cpp new file mode 100644 index 0000000000000000000000000000000000000000..278c90e64ce6059a1d4fa1b52348144e033270c6 --- /dev/null +++ b/src/Neuron/NeuronBiased.cpp @@ -0,0 +1,34 @@ +/** + * DESCRIPTION OF THE FILE + * + * @author Michal KravĨenko + * @date 15.3.19 - + */ + +#include "NeuronBiased.h" +#include "NeuronConstant.h" + +namespace lib4neuro{ + + NeuronBiased::NeuronBiased(double b) { + this->bias = b; + } + + double NeuronBiased::activate(double x, double b) { + return x + this->bias; + } + + double NeuronBiased::activation_function_eval_derivative(double x, double b) { + return 1.0; + } + + double NeuronBiased::activation_function_eval_derivative_bias(double x, double b) { + return 0.0; + } + + Neuron* NeuronBiased::get_derivative() { + NeuronConstant *output = new NeuronConstant(1.0); + return output; + } + +}//end of namespace lib4neuro \ No newline at end of file diff --git a/src/Neuron/NeuronBiased.h b/src/Neuron/NeuronBiased.h new file mode 100644 index 0000000000000000000000000000000000000000..b8ca40ecf21c005271800ac06835c37651d60615 --- /dev/null +++ b/src/Neuron/NeuronBiased.h @@ -0,0 +1,63 @@ +/** + * 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 { + + private: + + 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 ); + + /** + * 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