Last change
on this file since 467 was
286,
checked in by Maciej Komosinski, 10 years ago
|
Updated headers
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Rev | Line | |
---|
[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
| 3 | // See LICENSE.txt for details. |
---|
[109] | 4 | |
---|
| 5 | #include "neuroimpl-simple.h" |
---|
| 6 | |
---|
| 7 | #define NEURO_MAX 10.0 |
---|
| 8 | #define OVERLOAD 0.1 |
---|
| 9 | #define MUSCLESPEED 0.08 |
---|
| 10 | #define MUSCLEACC 0.01 |
---|
| 11 | |
---|
| 12 | int NI_StdNeuron::lateinit() |
---|
| 13 | { |
---|
| 14 | #ifdef MODEL_V1_COMPATIBLE |
---|
| 15 | if (inertia<0) inertia=neuro->inertia; |
---|
| 16 | if (force<0) force=neuro->force; |
---|
| 17 | if (sigmo>1e9) sigmo=neuro->sigmo; |
---|
| 18 | #endif |
---|
| 19 | istate=newstate+neuro->state; // neuro->state -> random initialization |
---|
| 20 | calcOutput(); |
---|
| 21 | neuro->state=newstate; |
---|
| 22 | return 1; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | void NI_StdNeuron::calcInternalState() |
---|
| 26 | { |
---|
| 27 | double sum=getWeightedInputSum(); |
---|
| 28 | velocity=force*(sum-istate)+inertia*velocity; |
---|
| 29 | istate+=velocity; |
---|
| 30 | if (istate>NEURO_MAX) istate=NEURO_MAX; |
---|
| 31 | else if (istate<-NEURO_MAX) istate=-NEURO_MAX; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | void NI_StdNeuron::go() |
---|
| 35 | { |
---|
| 36 | calcInternalState(); |
---|
| 37 | calcOutput(); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | void NI_StdNeuron::calcOutput() |
---|
| 41 | { |
---|
| 42 | double s=istate * sigmo; |
---|
| 43 | if (s<-30.0) setState(-1); |
---|
| 44 | else setState(2.0/(1.0+exp(-s))-1.0); // -1...1 |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | void NI_StdUNeuron::calcOutput() |
---|
| 48 | { |
---|
| 49 | double s=istate * sigmo; |
---|
| 50 | if (s<-30.0) setState(0); |
---|
| 51 | else setState(1.0/(1.0+exp(-s))); // 0...1 |
---|
| 52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.