diff options
author | jvech <jmvalenciae@unal.edu.co> | 2024-07-19 09:13:18 -0500 |
---|---|---|
committer | jvech <jmvalenciae@unal.edu.co> | 2024-07-19 09:13:18 -0500 |
commit | 13d2f9ee07a632ab09ed4eacabc57ce406a2dff0 (patch) | |
tree | 8265a1b98c651c50824a8b3887a321bd928d9962 /src/activations.c | |
parent | 4a5b6b12040a87dd8319a735cc48f31a2d140e3a (diff) |
add: tanh activation added
Diffstat (limited to 'src/activations.c')
-rw-r--r-- | src/activations.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/activations.c b/src/activations.c index 064482d..7a8ea24 100644 --- a/src/activations.c +++ b/src/activations.c @@ -30,6 +30,7 @@ double softplus(double x); double dsoftplus(double x); double linear(double x); double dlinear(double x); +double dtanh(double x); struct Activation NN_LEAKY_RELU = { .func = leaky_relu, @@ -56,6 +57,11 @@ struct Activation NN_LINEAR = { .dfunc = dlinear, }; +struct Activation NN_TANH = { + .func = tanh, + .dfunc = dtanh, +}; + double linear(double x) {return x;} double dlinear(double x) {return 1.0;} @@ -70,3 +76,5 @@ double dleaky_relu(double x) { return (x > 0) ? 1 : 0.01; } double softplus(double x) { return log1p(exp(x)); } double dsoftplus(double x) { return sigmoid(x); } + +double dtanh(double x) {return 1 - tanh(x) * tanh(x);}; |