Last change
on this file since 1263 was
907,
checked in by Maciej Komosinski, 5 years ago
|
Code formatting
|
-
Property svn:eol-style set to
native
|
File size:
1.0 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 | { |
---|
[791] | 14 | istate = newstate + neuro->state; // neuro->state -> random initialization |
---|
| 15 | calcOutput(); |
---|
| 16 | neuro->state = newstate; |
---|
| 17 | return 1; |
---|
[109] | 18 | } |
---|
| 19 | |
---|
| 20 | void NI_StdNeuron::calcInternalState() |
---|
| 21 | { |
---|
[791] | 22 | double sum = getWeightedInputSum(); |
---|
[907] | 23 | velocity = force * (sum - istate) + inertia * velocity; |
---|
[791] | 24 | istate += velocity; |
---|
| 25 | if (istate > NEURO_MAX) istate = NEURO_MAX; |
---|
| 26 | else if (istate < -NEURO_MAX) istate = -NEURO_MAX; |
---|
[109] | 27 | } |
---|
| 28 | |
---|
| 29 | void NI_StdNeuron::go() |
---|
| 30 | { |
---|
[791] | 31 | calcInternalState(); |
---|
| 32 | calcOutput(); |
---|
[109] | 33 | } |
---|
| 34 | |
---|
| 35 | void NI_StdNeuron::calcOutput() |
---|
| 36 | { |
---|
[791] | 37 | double s = istate * sigmo; |
---|
| 38 | if (s < -30.0) setState(-1); |
---|
| 39 | else setState(2.0 / (1.0 + exp(-s)) - 1.0); // -1...1 |
---|
[109] | 40 | } |
---|
| 41 | |
---|
| 42 | void NI_StdUNeuron::calcOutput() |
---|
| 43 | { |
---|
[791] | 44 | double s = istate * sigmo; |
---|
| 45 | if (s < -30.0) setState(0); |
---|
| 46 | else setState(1.0 / (1.0 + exp(-s))); // 0...1 |
---|
[109] | 47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.