Newer
Older
//
// Created by fluffymoo on 11.6.18.
//
#include "NeuronTanh.h"
NeuronTanh::NeuronTanh(double a) {
this->activation_function_parameters = new double[1];
this->activation_function_parameters[0] = a;

Michal Kravcenko
committed
this->edges_in = new std::vector<Connection*>(0);
this->edges_out = new std::vector<Connection*>(0);
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
}
void NeuronTanh::activate( ) {
double a = this->activation_function_parameters[0];
double x = this->potential;
double ex = std::pow(E, x - a);
double exi = 1.0 / ex;
this->state = (ex - exi) / (ex + exi);
}
double NeuronTanh::activation_function_get_partial_derivative(int param_idx) {
double a = this->activation_function_parameters[0];
double x = this->potential;
if(param_idx == 0){
double ex = -4.0 * std::pow(E, 2.0 * (x + a));
double exi = std::pow(E, 2.0 * a) + std::pow(E, 2.0 * x);
return ex / (exi * exi);
}
return 0.0;
}
double NeuronTanh::activation_function_get_derivative( ) {
double a = this->activation_function_parameters[0];
double x = this->potential;
double ex = -4.0 * std::pow(E, 2.0 * (x + a));
double exi = std::pow(E, 2.0 * a) + std::pow(E, 2.0 * x);
return ex / (exi * exi);
}