Appendix C
Examples of Generated Models

This appendix includes neural network models that were automatically generated by the behavioural model generators, in order to illustrate how the networks can be mapped onto several different representations for further use. The example concerns a simple network with one hidden layer, three network inputs, three network outputs, and two neurons in the hidden layer. The total number of neurons is therefore five: two in the hidden layer and three in the output layer. These five neurons together involve 50 network parameters. The neuron nonlinearity is in all cases the F2 as defined in Eq. (2.16).

C.1 Pstar Example

/*****************************************************  
 * Non-quasistatic Pstar models for 1 networks, as   *  
 * written by automatic behavioural model generator. *  
 *****************************************************/  
 
MODEL: NeuronType1(IN,OUT,REF) delta, tau1, tau2;  
   delta2 = delta * delta;  
   EC1(AUX,REF) ln( (exp(delta2*(V(IN,REF)+1)/2) + exp(-delta2*(V(IN,REF)+1)/2))  
                  / (exp(delta2*(V(IN,REF)-1)/2) + exp(-delta2*(V(IN,REF)-1)/2))  
                  ) / delta2;  
   L1(AUX,OUT) tau1;  C2(OUT,REF) tau2 / tau1   ;  
   R2(OUT,REF) 1.0 ;  
END;  
 
MODEL: Thesis0(T0,T1,T2,REF);  
 
   /* Thesis0 topology: 3 - 2 - 3 */  
 
   c:Rlarge = 1.0e+15;  
   c: Neuron instance NET[0].L[1].N[0];  
   L4 (DDX4,REF) 1.0;  
   JC4(DDX4,REF)  
      +1.790512e-09*V(T0,REF)-1.258335e-10*V(T1,REF)+2.022312e-09*V(T2,REF);  
   EC4(IN4,REF)  
      -6.708517e-02*V(T0,REF)-4.271246e-01*V(T1,REF)-7.549380e-01*V(T2,REF)  
      +4.958681e-01-V(L4);  
   NeuronType1_4(IN4,OUT4,REF)  
       1.369986e+00, 6.357759e-10, 6.905401e-21;  
   c:R4(OUT4,REF) Rlarge;  
 
   c: Neuron instance NET[0].L[1].N[1];  
   L5 (DDX5,REF) 1.0;  
   JC5(DDX5,REF)  
      +1.933749e-09*V(T0,REF)+1.884210e-10*V(T1,REF)+2.656819e-09*V(T2,REF);  
   EC5(IN5,REF)  
      +1.895829e-01*V(T0,REF)+3.461638e-01*V(T1,REF)+1.246243e+00*V(T2,REF)  
      -2.266006e-01-V(L5);  
   NeuronType1_5(IN5,OUT5,REF)  
       1.458502e+00, 9.067704e-10, 5.114471e-20;  
   c:R5(OUT5,REF) Rlarge;  
 
   c: Neuron instance NET[0].L[2].N[0];  
   L6 (DDX6,REF) 1.0;  
   JC6(DDX6,REF)  
      +2.202777e-10*V(OUT4,REF)+2.865773e-10*V(OUT5,REF);  
   EC6(IN6,REF)  
      +1.425344e+00*V(OUT4,REF)-1.075981e+00*V(OUT5,REF)  
      +3.051705e-02-V(L6);  
   NeuronType1_6(IN6,OUT6,REF)  
       1.849287e+00, 7.253345e-10, 3.326457e-20;  
   c:R6(OUT6,REF) Rlarge;  
   JC9(T0,REF) -1.249222e-01-2.684799e-01*V(OUT6,REF);  
 
   c: Neuron instance NET[0].L[2].N[1];  
   L7 (DDX7,REF) 1.0;  
   JC7(DDX7,REF)  
      +9.147703e-10*V(OUT4,REF)+5.598127e-10*V(OUT5,REF);  
   EC7(IN7,REF)  
      +6.116778e-01*V(OUT4,REF)-2.250382e-02*V(OUT5,REF)  
      -1.391824e-02-V(L7);  
   NeuronType1_7(IN7,OUT7,REF)  
       1.732572e+00, 2.478904e-10, 1.471256e-21;  
   c:R7(OUT7,REF) Rlarge;  
   JC10(T1,REF) -8.017604e-02+5.439718e+00*V(OUT7,REF);  
 
   c: Neuron instance NET[0].L[2].N[2];  
   L8 (DDX8,REF) 1.0;  
   JC8(DDX8,REF)  
      -5.037256e-11*V(OUT4,REF)-2.056628e-10*V(OUT5,REF);  
   EC8(IN8,REF)  
      +1.891435e+00*V(OUT4,REF)-8.019724e-01*V(OUT5,REF)  
      +2.601973e-01-V(L8);  
   NeuronType1_8(IN8,OUT8,REF)  
       1.894981e+00, 1.096576e-09, 5.602905e-20;  
   c:R8(OUT8,REF) Rlarge;  
   JC11(T2,REF)  2.267318e-01-2.024442e-01*V(OUT8,REF);  
 
END; /* End of Pstar Thesis0 model */

C.2 Standard SPICE Input Deck Example

*****************************************************  
* Non-quasistatic SPICE subcircuits for 1 networks, *  
* written by automatic behavioural model generator. *  
*****************************************************  
 
* This file defines 1 neural networks:  
*   .SUBCKT NET0 1 2 3 999 with 3 independent terminal currents  
*  
* TEMP   =  2.7000000000000000E+01  CtoK =  2.7314999999999997E+02  
* BOLTZ  =  1.3806225999999997E-23  (Boltzmann constant k)  
* CHARGE =  1.6021917999999999E-19  (Elementary charge q)  
*   => T =  3.0014999999999997E+02  Vt   =  2.5864186384551461E-02  
 
* N must equal q/(kT) == 1/Vt at YOUR simulation temperature TEMP!!!  
.MODEL DNEURON D (IS= 1.0E-03 IBV= 0.0 CJO= 0.0 N= 3.8663501149113841E+01)  
* Re-generate SUBCKTs for any different temperatures.  
* Also, ideal diode behaviour is assumed at all current levels! =>  
* Make some adaptations for your simulator, if needed. The IS value  
* can be arbitrarily selected for numerical robustness: it drops  
* out of the mathematical relations, but it affects error control.  
* Cadence Spectre has an IMAX parameter that should be made large.  
 
.SUBCKT NET0L1N0 1 2 999  
* Neuron instance NET[0].L[1].N[0]  
R1   1 999  1.0  
E1   4 999  1 999 1.0  
V1   4   5  0.0  
E10 10 999  5 999  9.3843029994013438E-01  
D10 10  15 DNEURON  
V10 15 999 0.0  
E20 20 999  5 999 -9.3843029994013438E-01  
D20 20  25 DNEURON  
V20 25 999 0.0  
F30 999 30 V10  8.6725011215163601E-01  
F35 999 30 V20  1.3274988784836392E-01  
D30 30 999 DNEURON  
F40 999 40 V10  1.3274988784836392E-01  
F45 999 40 V20  8.6725011215163601E-01  
D40 40 999 DNEURON  
G5   5 999 30 40  5.3280462068615719E-01  
H50 50 999 V1 1.0  
L50 50   2  6.3577589506364056E-10  
R50  2 999  1.0  
C50  2 999  1.0861375379500291E-11  
.ENDS  
 
.SUBCKT NET0L1N1 1 2 999  
* Neuron instance NET[0].L[1].N[1]  
R1   1 999  1.0  
E1   4 999  1 999 1.0  
V1   4   5  0.0  
E10 10 999  5 999  1.0636136179961743E+00  
D10 10  15 DNEURON  
V10 15 999 0.0  
E20 20 999  5 999 -1.0636136179961743E+00  
D20 20  25 DNEURON  
V20 25 999 0.0  
F30 999 30 V10  8.9352149294460403E-01  
F35 999 30 V20  1.0647850705539598E-01  
D30 30 999 DNEURON  
F40 999 40 V10  1.0647850705539598E-01  
F45 999 40 V20  8.9352149294460403E-01  
D40 40 999 DNEURON  
G5   5 999 30 40  4.7009552297947205E-01  
H50 50 999 V1 1.0  
L50 50   2  9.0677037473784523E-10  
R50  2 999  1.0  
C50  2 999  5.6403157684469542E-11  
.ENDS  
 
.SUBCKT NET0L2N0 1 2 999  
* Neuron instance NET[0].L[2].N[0]  
R1   1 999  1.0  
E1   4 999  1 999 1.0  
V1   4   5  0.0  
E10 10 999  5 999  1.7099305663270813E+00  
D10 10  15 DNEURON  
V10 15 999 0.0  
E20 20 999  5 999 -1.7099305663270813E+00  
D20 20  25 DNEURON  
V20 25 999 0.0  
F30 999 30 V10  9.6831951188735381E-01  
F35 999 30 V20  3.1680488112646179E-02  
D30 30 999 DNEURON  
F40 999 40 V10  3.1680488112646179E-02  
F45 999 40 V20  9.6831951188735381E-01  
D40 40 999 DNEURON  
G5   5 999 30 40  2.9240953395785913E-01  
H50 50 999 V1 1.0  
L50 50   2  7.2533448996746825E-10  
R50  2 999  1.0  
C50  2 999  4.5861006433956426E-11  
.ENDS  
 
.SUBCKT NET0L2N1 1 2 999  
* Neuron instance NET[0].L[2].N[1]  
R1   1 999  1.0  
E1   4 999  1 999 1.0  
V1   4   5  0.0  
E10 10 999  5 999  1.5009030008888708E+00  
D10 10  15 DNEURON  
V10 15 999 0.0  
E20 20 999  5 999 -1.5009030008888708E+00  
D20 20  25 DNEURON  
V20 25 999 0.0  
F30 999 30 V10  9.5265564929569439E-01  
F35 999 30 V20  4.7344350704305657E-02  
D30 30 999 DNEURON  
F40 999 40 V10  4.7344350704305657E-02  
F45 999 40 V20  9.5265564929569439E-01  
D40 40 999 DNEURON  
G5   5 999 30 40  3.3313278719803212E-01  
H50 50 999 V1 1.0  
L50 50   2  2.4789035420970444E-10  
R50  2 999  1.0  
C50  2 999  5.9351066440511015E-12  
.ENDS  
 
.SUBCKT NET0L2N2 1 2 999  
* Neuron instance NET[0].L[2].N[2]  
R1   1 999  1.0  
E1   4 999  1 999 1.0  
V1   4   5  0.0  
E10 10 999  5 999  1.7954759016151536E+00  
D10 10  15 DNEURON  
V10 15 999 0.0  
E20 20 999  5 999 -1.7954759016151536E+00  
D20 20  25 DNEURON  
V20 25 999 0.0  
F30 999 30 V10  9.7316774616780659E-01  
F35 999 30 V20  2.6832253832193342E-02  
D30 30 999 DNEURON  
F40 999 40 V10  2.6832253832193342E-02  
F45 999 40 V20  9.7316774616780659E-01  
D40 40 999 DNEURON  
G5   5 999 30 40  2.7847770028559875E-01  
H50 50 999 V1 1.0  
L50 50   2  1.0965763466052844E-09  
R50  2 999  1.0  
C50  2 999  5.1094529090918392E-11  
.ENDS  
 
.SUBCKT NET0 1 2 3 999  
* Network 0 topology: 3 - 2 - 3  
G2 999 11 1 999 -6.7085165083464222E-02  
G1 999 10 1 999  1.7905117030211314E-09  
G4 999 11 2 999 -4.2712455761636123E-01  
G3 999 10 2 999 -1.2583350345102781E-10  
G6 999 11 3 999 -7.5493795848363305E-01  
G5 999 10 3 999  2.0223116907395013E-09  
I11 999 11  4.9586810996633499E-01  
L10 10 999  1.0000000000000000E+00  
G7 999 11 10 999  1.0000000000000000E+00  
X11 11 12 999 NET0L1N0  
G10 999 14 1 999  1.8958285166932167E-01  
G9 999 13 1 999  1.9337487686116938E-09  
G12 999 14 2 999  3.4616377160567428E-01  
G11 999 13 2 999  1.8842096327712685E-10  
G14 999 14 3 999  1.2462426190134208E+00  
G13 999 13 3 999  2.6568190323453482E-09  
I14 999 14 -2.2660061612223554E-01  
L13 13 999  1.0000000000000000E+00  
G15 999 14 13 999  1.0000000000000000E+00  
X14 14 15 999 NET0L1N1  
G18 999 17 12 999  1.4253444817664417E+00  
G17 999 16 12 999  2.2027769755558099E-10  
G20 999 17 15 999 -1.0759814652523116E+00  
G19 999 16 15 999  2.8657725035783068E-10  
I17 999 17  3.0517054260507383E-02  
L16 16 999  1.0000000000000000E+00  
G21 999 17 16 999  1.0000000000000000E+00  
X17 17 18 999 NET0L2N0  
G24 1 999 18 999 -2.6847994620332258E-01  
I18 1 999 -1.2492219829255186E-01  
G26 999 20 12 999  6.1167782976390769E-01  
G25 999 19 12 999  9.1477032544690288E-10  
G28 999 20 15 999 -2.2503817077250656E-02  
G27 999 19 15 999  5.5981269686469561E-10  
I20 999 20 -1.3918243186941530E-02  
L19 19 999  1.0000000000000000E+00  
G29 999 20 19 999  1.0000000000000000E+00  
X20 20 21 999 NET0L2N1  
G32 2 999 21 999  5.4397177239052902E+00  
I21 2 999 -8.0176040232393930E-02  
G34 999 23 12 999  1.8914346798991264E+00  
G33 999 22 12 999 -5.0372564367972412E-11  
G36 999 23 15 999 -8.0197243940349203E-01  
G35 999 22 15 999 -2.0566284076395966E-10  
I23 999 23  2.6019731842095845E-01  
L22 22 999  1.0000000000000000E+00  
G37 999 23 22 999  1.0000000000000000E+00  
X23 23 24 999 NET0L2N2  
G40 3 999 24 999 -2.0244416743534960E-01  
I24 3 999  2.2673179954870881E-01  
.ENDS

C.3 C Code Example

/*****************************************************  
 * Static (DC) C-source functions for 1 networks, as *  
 * written by automatic behavioural model generator. *  
 *****************************************************/  
 
double f(double s, double d)  
{  
   return(log(cosh(0.5*d*d*(s+1.0))/cosh(0.5*d*d*(s-1.0)))/(d*d));  
}  
 
/* Network 0 topology: 3 - 2 - 3 */  
void net0( double   in0, double   in1, double   in2  
         , double *out0, double *out1, double *out2)  
{  
   double net0l1n0;  
   double net0l1n1;  
   double net0l2n0;  
   double net0l2n1;  
   double net0l2n2;  
 
   /* Neuron instance NET[0].L[1].N[0] */  
   net0l1n0 =  
    f(-6.7085165083464222e-02 * in0  
      -4.2712455761636123e-01 * in1  
      -7.5493795848363305e-01 * in2  
      +4.9586810996633499e-01, 1.3699856203187932e+00);  
 
   /* Neuron instance NET[0].L[1].N[1] */  
   net0l1n1 =  
    f(+1.8958285166932167e-01 * in0  
      +3.4616377160567428e-01 * in1  
      +1.2462426190134208e+00 * in2  
      -2.2660061612223554e-01, 1.4585017092867422e+00);  
 
   /* Neuron instance NET[0].L[2].N[0] */  
   net0l2n0 =  
    f(+1.4253444817664417e+00 * net0l1n0  
      -1.0759814652523116e+00 * net0l1n1  
      +3.0517054260507383e-02, 1.8492866550792397e+00);  
 
  *out0 = -1.2492219829255186e-01 -2.6847994620332258e-01 * net0l2n0;  
 
   /* Neuron instance NET[0].L[2].N[1] */  
   net0l2n1 =  
    f(+6.1167782976390769e-01 * net0l1n0  
      -2.2503817077250656e-02 * net0l1n1  
      -1.3918243186941530e-02, 1.7325720769358317e+00);  
 
  *out1 = -8.0176040232393930e-02 +5.4397177239052902e+00 * net0l2n1;  
 
   /* Neuron instance NET[0].L[2].N[2] */  
   net0l2n2 =  
    f(+1.8914346798991264e+00 * net0l1n0  
      -8.0197243940349203e-01 * net0l1n1  
      +2.6019731842095845e-01, 1.8949806867697379e+00);  
 
  *out2 =  2.2673179954870881e-01 -2.0244416743534960e-01 * net0l2n2;  
}

C.4 FORTRAN Code Example

C      *****************************************************  
C      * Static (DC) FORTRAN source code for 1 networks,   *  
C      * written by automatic behavioural model generator. *  
C      *****************************************************  
 
      DOUBLE PRECISION FUNCTION DF(DS, DD)  
         IMPLICIT DOUBLE PRECISION (D)  
         DD2 = DD * DD  
         DF  = LOG( (EXP( DD2*(DS+1D0)/2D0)  
     +             + EXP(-DD2*(DS+1D0)/2D0))  
     +            / (EXP( DD2*(DS-1D0)/2D0)  
     +             + EXP(-DD2*(DS-1D0)/2D0))  
     +            ) / DD2  
      END  
 
 
C     Network 0 topology: 3 - 2 - 3  
      SUBROUTINE NET0( DIN0  
     +               , DIN1  
     +               , DIN2  
     +               , DOUT0  
     +               , DOUT1  
     +               , DOUT2)  
 
         IMPLICIT DOUBLE PRECISION (D)  
 
C        Neuron instance NET[0].L[1].N[0]  
         D1N0 =  
     +      DF(-6.7085165083464222E-02 * DIN0  
     +         -4.2712455761636123E-01 * DIN1  
     +         -7.5493795848363305E-01 * DIN2  
     +         +4.9586810996633499E-01, 1.3699856203187932E+00)  
 
C        Neuron instance NET[0].L[1].N[1]  
         D1N1 =  
     +      DF(+1.8958285166932167E-01 * DIN0  
     +         +3.4616377160567428E-01 * DIN1  
     +         +1.2462426190134208E+00 * DIN2  
     +         -2.2660061612223554E-01, 1.4585017092867422E+00)  
 
C        Neuron instance NET[0].L[2].N[0]  
         D2N0 =  
     +      DF(+1.4253444817664417E+00 * D1N0  
     +         -1.0759814652523116E+00 * D1N1  
     +         +3.0517054260507383E-02, 1.8492866550792397E+00)  
 
         DOUT0 = -1.2492219829255186E-01-2.6847994620332258E-01 * D2N0  
 
C        Neuron instance NET[0].L[2].N[1]  
         D2N1 =  
     +      DF(+6.1167782976390769E-01 * D1N0  
     +         -2.2503817077250656E-02 * D1N1  
     +         -1.3918243186941530E-02, 1.7325720769358317E+00)  
 
         DOUT1 = -8.0176040232393930E-02+5.4397177239052902E+00 * D2N1  
 
C        Neuron instance NET[0].L[2].N[2]  
         D2N2 =  
     +      DF(+1.8914346798991264E+00 * D1N0  
     +         -8.0197243940349203E-01 * D1N1  
     +         +2.6019731842095845E-01, 1.8949806867697379E+00)  
 
         DOUT2 =  2.2673179954870881E-01-2.0244416743534960E-01 * D2N2  
      END

C.5 Mathematica Code Example

(*****************************************************  \  
 * Static (DC) Mathematica models for 1 networks, as *  \  
 * written by automatic behavioural model generator. *  \  
 *****************************************************)  
 
Clear[f]  
f[s_,d_] := 1/d^2 Log [Cosh[d^2 (s+1)/2] / Cosh[d^2 (s-1)/2]]  
Clear[x0,x1,x2]  
 
(* Network 0 topology: 3 - 2 - 3 *)  
 
Clear[net0l1n0]  (* Neuron instance NET[0].L[1].N[0] *)  
net0l1n0[x0_,x1_,x2_] :=  \  
 f[-0.6708516508346424 10^-1 x0  \  
   -0.4271245576163612 10^+0 x1  \  
   -0.7549379584836331 10^+0 x2  \  
   +0.4958681099663350 10^+0,+1.3699856203187932 10^+0]  
 
Clear[net0l1n1]  (* Neuron instance NET[0].L[1].N[1] *)  
net0l1n1[x0_,x1_,x2_] :=  \  
 f[+0.1895828516693217 10^+0 x0  \  
   +0.3461637716056743 10^+0 x1  \  
   +1.2462426190134208 10^+0 x2  \  
   -0.2266006161222355 10^+0,+1.4585017092867422 10^+0]  
 
Clear[net0l2n0]  (* Neuron instance NET[0].L[2].N[0] *)  
net0l2n0[x0_,x1_,x2_] :=  \  
 f[+1.4253444817664417 10^+0 net0l1n0[x0,x1,x2]  \  
   -1.0759814652523116 10^+0 net0l1n1[x0,x1,x2]  \  
   +0.3051705426050739 10^-1,+1.8492866550792397 10^+0]  
 
net0output0[x0_,x1_,x2_] := -0.1249221982925519 10^+0  \  
   -0.2684799462033226 10^+0 net0l2n0[x0,x1,x2]  
 
Clear[net0l2n1]  (* Neuron instance NET[0].L[2].N[1] *)  
net0l2n1[x0_,x1_,x2_] :=  \  
 f[+0.6116778297639077 10^+0 net0l1n0[x0,x1,x2]  \  
   -0.2250381707725066 10^-1 net0l1n1[x0,x1,x2]  \  
   -0.1391824318694153 10^-1,+1.7325720769358317 10^+0]  
 
net0output1[x0_,x1_,x2_] := -0.8017604023239395 10^-1  \  
   +5.4397177239052902 10^+0 net0l2n1[x0,x1,x2]  
 
Clear[net0l2n2]  (* Neuron instance NET[0].L[2].N[2] *)  
net0l2n2[x0_,x1_,x2_] :=  \  
 f[+1.8914346798991264 10^+0 net0l1n0[x0,x1,x2]  \  
   -0.8019724394034920 10^+0 net0l1n1[x0,x1,x2]  \  
   +0.2601973184209585 10^+0,+1.8949806867697379 10^+0]  
 
net0output2[x0_,x1_,x2_] := +0.2267317995487088 10^+0  \  
   -0.2024441674353496 10^+0 net0l2n2[x0,x1,x2]