Ignore:
Timestamp:
05/29/18 16:24:39 (6 years ago)
Author:
Maciej Komosinski
Message:

Code formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/neuro/impl/neuroimpl-simple.cpp

    r726 r791  
    1212int NI_StdNeuron::lateinit()
    1313{
    14 istate=newstate+neuro->state; // neuro->state -> random initialization
    15 calcOutput();
    16 neuro->state=newstate;
    17 return 1;
     14        istate = newstate + neuro->state; // neuro->state -> random initialization
     15        calcOutput();
     16        neuro->state = newstate;
     17        return 1;
    1818}
    1919
    2020void NI_StdNeuron::calcInternalState()
    2121{
    22 double sum=getWeightedInputSum();
    23 velocity=force*(sum-istate)+inertia*velocity;
    24 istate+=velocity;
    25 if (istate>NEURO_MAX) istate=NEURO_MAX;
    26 else if (istate<-NEURO_MAX) istate=-NEURO_MAX;
     22        double sum = getWeightedInputSum();
     23        velocity = force*(sum - istate) + inertia*velocity;
     24        istate += velocity;
     25        if (istate > NEURO_MAX) istate = NEURO_MAX;
     26        else if (istate < -NEURO_MAX) istate = -NEURO_MAX;
    2727}
    2828
    2929void NI_StdNeuron::go()
    3030{
    31 calcInternalState();
    32 calcOutput();
     31        calcInternalState();
     32        calcOutput();
    3333}
    3434
    3535void NI_StdNeuron::calcOutput()
    3636{
    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
     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
    4040}
    4141
    4242void NI_StdUNeuron::calcOutput()
    4343{
    44 double s=istate * sigmo;
    45 if (s<-30.0) setState(0);
    46 else setState(1.0/(1.0+exp(-s))); // 0...1
     44        double s = istate * sigmo;
     45        if (s < -30.0) setState(0);
     46        else setState(1.0 / (1.0 + exp(-s))); // 0...1
    4747}
Note: See TracChangeset for help on using the changeset viewer.