Last change
on this file since 100 was
66,
checked in by Maciej Komosinski, 14 years ago
|
set 'eol-style' to 'native'
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Rev | Line | |
---|
[64] | 1 | // This file is a part of the Framsticks GDK library. |
---|
| 2 | // Copyright (C) 2002-2011 Szymon Ulatowski. See LICENSE.txt for details. |
---|
| 3 | // Refer to http://www.framsticks.com/ for further information. |
---|
[5] | 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.