Newer
Older
//
// Created by fluffymoo on 11.6.18.
//
7
8
9
10
11
12
13
14
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
53
54
55
56
57
58
59
60
NeuronLogistic::NeuronLogistic(double a, double b) {
this->activation_function_parameters = new double[2];
this->activation_function_parameters[0] = a;
this->activation_function_parameters[1] = b;
}
void NeuronLogistic::activate() {
double a = this->activation_function_parameters[0];
double b = this->activation_function_parameters[1];
double x = this->potential;
double ex = std::pow(E, b - x);
this->state = std::pow(1.0 + ex, -a);
}
double NeuronLogistic::activation_function_get_partial_derivative(int param_idx) {
double a = this->activation_function_parameters[0];
double b = this->activation_function_parameters[1];
double x = this->potential;
if(param_idx == 0){
double ex = std::pow(E, b - x);
double exa= -std::pow(ex + 1.0, -a);
return exa * std::log(ex + 1.0);
}
else{
double ex = std::pow(E, b - x);
double ex2 = std::pow(ex + 1.0, -a - 1.0);
return -a * ex * ex2;
}
}
double NeuronLogistic::activation_function_get_derivative() {
double a = this->activation_function_parameters[0];
double b = this->activation_function_parameters[1];
double x = this->potential;
double ex = std::pow(E, b - x);
double ex2 = std::pow(ex + 1.0, -a - 1.0);
return a * ex * ex2;
}