diff options
Diffstat (limited to '')
-rw-r--r-- | src/slopestd.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/slopestd.h b/src/slopestd.h new file mode 100644 index 0000000..40ceef2 --- /dev/null +++ b/src/slopestd.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef NEURAL_SLOPE_STD_H | ||
2 | #define NEURAL_SLOPE_STD_H | ||
3 | |||
4 | #include <math.h> | ||
5 | |||
6 | #include "neural/slope.h" | ||
7 | |||
8 | namespace Neural | ||
9 | { | ||
10 | template<typename sigtype> | ||
11 | sigtype tpltanh( sigtype sInput ); | ||
12 | |||
13 | template<> | ||
14 | float tpltanh<float>( float sInput ) | ||
15 | { | ||
16 | return tanhf( sInput ); | ||
17 | } | ||
18 | |||
19 | template<> | ||
20 | double tpltanh<double>( double sInput ) | ||
21 | { | ||
22 | return tanh( sInput ); | ||
23 | } | ||
24 | |||
25 | template<> | ||
26 | long double tpltanh<long double>( long double sInput ) | ||
27 | { | ||
28 | return tanhl( sInput ); | ||
29 | } | ||
30 | |||
31 | template<typename sigtype> | ||
32 | class SlopeStd : public Slope<sigtype> | ||
33 | { | ||
34 | public: | ||
35 | SlopeStd( sigtype sSlope=1.0 ) : | ||
36 | sSlope( sSlope ) | ||
37 | { | ||
38 | } | ||
39 | |||
40 | virtual ~SlopeStd() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | virtual sigtype operator()( sigtype sInput ) | ||
45 | { | ||
46 | return (tpltanh<sigtype>(2.0*sSlope*sInput) + 1.0)/2.0; | ||
47 | } | ||
48 | |||
49 | private: | ||
50 | sigtype sSlope; | ||
51 | }; | ||
52 | }; | ||
53 | |||
54 | #endif | ||
55 | |||