Newer
Older
//
// Created by fluffymoo on 11.6.18.
//
NeuronLogistic_d2::NeuronLogistic_d2( double * b ) {
this->bias = b;

Michal Kravcenko
committed
}
double NeuronLogistic_d2::activate( double x ) {
//(e^(b + x) (e^b - e^x))/(e^b + e^x)^3

Michal Kravcenko
committed
double b = 0.0;
if( this->bias ){
b = *this->bias;

Michal Kravcenko
committed
}
double ex = std::pow(E, x);
double eb = std::pow(E, b);

Michal Kravcenko
committed
return (eb*ex*(eb - ex))/((eb + ex)*(eb + ex)*(eb + ex));

Michal Kravcenko
committed
}
double NeuronLogistic_d2::activation_function_eval_derivative_bias( double x ) {
//-(e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4

Michal Kravcenko
committed
double b = 0.0;
if( this->bias ){
b = *this->bias;
}

Michal Kravcenko
committed
double eb = std::pow(E, b);
double ex = std::pow(E, x);
return -(eb*ex*(-4*eb*ex + eb*eb +ex*ex))/((eb + ex)*(eb + ex)*(eb + ex)*(eb + ex));

Michal Kravcenko
committed
}
double NeuronLogistic_d2::activation_function_eval_derivative( double x ) {
//(e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4
return -this->activation_function_eval_derivative_bias( x );

Michal Kravcenko
committed
}
NeuronLogistic* NeuronLogistic_d2::get_derivative() {
//TODO maybe not the best way
return nullptr;

Michal Kravcenko
committed
}
NeuronLogistic_d1::NeuronLogistic_d1( double * b ) {
this->bias = b;

Michal Kravcenko
committed
}
double NeuronLogistic_d1::activate( double x ) {
//e^(b - x)/(e^(b - x) + 1)^2
double b = 0.0;
if( this->bias ){
b = *this->bias;

Michal Kravcenko
committed
}
double ex = std::pow(E, x);
double eb = std::pow(E, b);
double d = (eb/ex);

Michal Kravcenko
committed

Michal Kravcenko
committed
}
double NeuronLogistic_d1::activation_function_eval_derivative_bias( double x ) {
//(e^(b + x) (e^x - e^b))/(e^b + e^x)^3
double b = 0.0;
if( this->bias ){
b = *this->bias;
}

Michal Kravcenko
committed
double ex = std::pow(E, x);
double eb = std::pow(E, b);

Michal Kravcenko
committed
return (eb*ex* (ex - eb))/((eb + ex)*(eb + ex)*(eb + ex));

Michal Kravcenko
committed
}
double NeuronLogistic_d1::activation_function_eval_derivative( double x ) {
//(e^(b + x) (e^b - e^x))/(e^b + e^x)^3
return -this->activation_function_eval_derivative_bias( x );
}

Michal Kravcenko
committed
NeuronLogistic* NeuronLogistic_d1::get_derivative( ) {
//(e^(b + x) (e^b - e^x))/(e^b + e^x)^3

Michal Kravcenko
committed
NeuronLogistic_d2* output = nullptr;

Michal Kravcenko
committed
return output;
}
NeuronLogistic::NeuronLogistic( double * b ) {
this->bias = b;
double NeuronLogistic::activate( double x ) {
//(1 + e^(-x + b))^(-1)
double b = 0.0;
if( this->bias ){
b = *this->bias;
}
double NeuronLogistic::activation_function_eval_derivative_bias( double x ) {
//-e^(b - x)/(e^(b - x) + 1)^2
double b = 0.0;
if( this->bias ){
b = *this->bias;

Michal Kravcenko
committed
double NeuronLogistic::activation_function_eval_derivative( double x ) {
//e^(b - x)/(e^(b - x) + 1)^2
return -this->activation_function_eval_derivative_bias( x );

Michal Kravcenko
committed
}
NeuronLogistic* NeuronLogistic::get_derivative( ) {

Michal Kravcenko
committed

Michal Kravcenko
committed
NeuronLogistic_d1 *output = nullptr;

Michal Kravcenko
committed
return output;

Michal Kravcenko
committed