diff options
| author | mike <mike@d8baa203-390c-0410-a584-dba4c0749223> | 2011-07-16 18:53:45 +0000 |
|---|---|---|
| committer | mike <mike@d8baa203-390c-0410-a584-dba4c0749223> | 2011-07-16 18:53:45 +0000 |
| commit | 3005ed13f0fde6d61ab8a229c1490f9389cd75b5 (patch) | |
| tree | 737c067dc4ceb0e4cee26e3e5f60ef91f8e71cdb /src/slopestd.h | |
| parent | 6bf9a32cf42b3f1a6dad7018d1b1925cc909b585 (diff) | |
| download | libneural-3005ed13f0fde6d61ab8a229c1490f9389cd75b5.tar.gz libneural-3005ed13f0fde6d61ab8a229c1490f9389cd75b5.tar.bz2 libneural-3005ed13f0fde6d61ab8a229c1490f9389cd75b5.tar.xz libneural-3005ed13f0fde6d61ab8a229c1490f9389cd75b5.zip | |
Everything is in place except for columns, networks, and a cute language for
describing the networks. ...and tests, don't forget about tests.
git-svn-id: http://svn.xagasoft.com/misc/libneural/trunk@470 d8baa203-390c-0410-a584-dba4c0749223
Diffstat (limited to 'src/slopestd.h')
| -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 | |||
