Skip to content
Snippets Groups Projects
Commit 55416ed8 authored by Michal Kravcenko's avatar Michal Kravcenko
Browse files

ADD: added a new neuron to represent a never-changing shift of the input values

parent 66e62e12
No related branches found
No related tags found
No related merge requests found
/**
* 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
/**
* 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment