Added more helper methods to math.

This commit is contained in:
Relintai 2022-03-10 12:38:30 +01:00
parent 67b9aa6d0a
commit 11e474ae3b

View File

@ -323,6 +323,26 @@ public:
return hf;
}
static _ALWAYS_INLINE_ double sigmoid(const double x) {
return 1 / (1 + exp(-x));
}
static _ALWAYS_INLINE_ double sigmoid_derived(const double x) {
return sigmoid(x) * (1 - sigmoid(x));
}
static _ALWAYS_INLINE_ double tanh_derived(const double x) {
return 1 - pow(tanh(x), 2);
}
static _ALWAYS_INLINE_ double linear(const double x) {
return x;
}
static _ALWAYS_INLINE_ double linear_derived(const double x) {
return 1;
}
};
#ifndef ABS