Newer
Older
1
2
3
4
5
6
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
61
62
63
64
#include <boost/serialization/export.hpp>
#include <iostream>
#include "NeuronLinearSaturated.h"
#include "NeuronBinary.h"
#include "NeuronSerialization.h"
#include "NeuronLinearSaturatedSerialization.h"
#include "exceptions.h"
BOOST_CLASS_EXPORT_IMPLEMENT(lib4neuro::NeuronLinearSaturated);
namespace lib4neuro {
NeuronLinearSaturated::NeuronLinearSaturated(double saturation_point) {
this->saturation_point = saturation_point;
}
double NeuronLinearSaturated::activate(double x,
double b) {
if (x + b < 0) {
this->activation_val = 0.0;
}
else if (x + b > this->saturation_point) {
this->activation_val = this->saturation_point;
}
else {
this->activation_val = x + b;
}
return this->activation_val;
}
double NeuronLinearSaturated::activation_function_eval_derivative_bias(double x,
double b) {
// f'(0) = 0 for the purposes of training
if (x + b < 0) {
return 0.0;
}
else if (x + b > this->saturation_point) {
return 0.0;
}
else {
return 1.0;
}
}
double NeuronLinearSaturated::activation_function_eval_derivative(double x,
double b) {
// f'(0) = 0 for the purposes of training
if (x + b < 0) {
return 0.0;
}
else if (x + b > this->saturation_point) {
return 0.0;
}
else {
return 1.0;
}
}
Neuron* NeuronLinearSaturated::get_derivative() {
THROW_NOT_IMPLEMENTED_ERROR("");
}
}