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

ADD: added a new function to retrieve the last calculated activation value of the neuron

parent 5a528459
No related branches found
No related tags found
No related merge requests found
......@@ -8,4 +8,8 @@ namespace lib4neuro {
}
double Neuron::get_last_activation_value() {
return this->activation_val;
}
}
......@@ -30,6 +30,12 @@ namespace lib4neuro {
*/
class Neuron {
protected:
/**
* holds the last value of the activation function, used by this->activate
*/
double activation_val;
public:
/**
......@@ -50,6 +56,12 @@ namespace lib4neuro {
*/
LIB4NEURO_API virtual double activate(double x, double b) = 0;
/**
* returns the last value of the actual activation function output for this neuron
* @return
*/
LIB4NEURO_API virtual double get_last_activation_value( );
}; /* end of Neuron class */
......
......@@ -15,10 +15,12 @@ namespace lib4neuro {
double NeuronBinary::activate(double x, double b) {
if (x >= b) {
return 1.0;
this->activation_val = 1.0;
} else {
return 0.0;
this->activation_val = 0.0;
}
return this->activation_val;
}
}
\ No newline at end of file
......@@ -21,7 +21,8 @@ namespace lib4neuro {
}
double NeuronConstant::activate(double x, double b) {
return this->p;
this->activation_val = this->p;
return this->activation_val;
}
double NeuronConstant::activation_function_eval_derivative_bias(double x, double b) {
......
......@@ -15,7 +15,8 @@ namespace lib4neuro {
NeuronLinear::NeuronLinear() {}
double NeuronLinear::activate(double x, double b) {
return x + b;
this->activation_val = x + b;
return this->activation_val;
}
double NeuronLinear::activation_function_eval_derivative_bias(double x, double b) {
......
......@@ -23,7 +23,8 @@ namespace lib4neuro {
double eb = std::pow(E, b);
double denom = (eb + ex);
return (eb * ex * (eb - ex)) / (denom * denom * denom);
this->activation_val = (eb * ex * (eb - ex)) / (denom * denom * denom);
return this->activation_val;
}
double NeuronLogistic_d2::activation_function_eval_derivative_bias(double x, double b) {
......@@ -58,7 +59,8 @@ namespace lib4neuro {
double d = (eb / ex);
double denom = (d + 1);
return d / (denom * denom);
this->activation_val = d / (denom * denom);
return this->activation_val;
}
double NeuronLogistic_d1::activation_function_eval_derivative_bias(double x, double b) {
......@@ -91,7 +93,9 @@ namespace lib4neuro {
//(1 + e^(-x + b))^(-1)
double ex = std::pow(E, b - x);
return 1.0 / (1.0 + ex);
this->activation_val = 1.0 / (1.0 + ex);
return this->activation_val;
}
double NeuronLogistic::activation_function_eval_derivative_bias(double x, double b) {
......
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