Skip to content

About the generated Python code #24

@Polarisamoon

Description

@Polarisamoon

After converting the network into formulas or Python code, I noticed that some hidden neurons are being referenced before they are computed, which is quite strange. For example:

h[0] = 0.171989*h[31] + 3.169343*i[0] - 0.266712

Here, h[31] has not been calculated yet, so it will use its initial value of 0. Is this normal?

Python Code:
h = np.zeros(35)
o = np.zeros(2)
h[0] = 0.171989*h[31] + 3.169343*i[0] - 0.266712
h[1] = -sin(0.112585*h[28] + 2.851631*i[0] - 2.619233*i[1] - 0.026671)
h[2] = -tanh(1.154439*i[0] + 1.897031*i[1] + 0.352859)
h[3] = nan
h[4] = 1.742897*h[0] - 0.302724*h[9] + 0.276833
h[5] = -0.297971*h[15] - 0.757493*h[24] + 2.0499*i[1] + 0.916681
h[6] = -tanh(2.076261*h[23]*i[1] - 1.89432)
h[7] = -2.081779*i[0] - 1.563756*i[1] + 0.980241
h[8] = 0.156715*h[17] - 1.694074*i[0] + 1.365514*i[1] + 1.311888
h[9] = tanh(0.619051*h[18] + 0.330781)
h[10] = 0.816805*h[11]
h[11] = -sin(0.300976*h[2] + 0.627619)
h[12] = 0.34393 - 0.560032*h[33]
h[13] = tanh(0.00587*h[17]*h[26]*i[1] + 0.874081)
h[14] = Max(0, 0.415834*i[0] + 0.395707*i[1] + 1.267994)
h[15] = Piecewise((-0.703819*i[1] - 0.186702, 0.703819*i[1] + 0.186702 < 0), (-0.003519*i[1] - 0.000934, True))
h[16] = -1.23256*i[0] + 0.079172*i[1] - 1.614457
h[17] = Max(0, 0.065526*h[18] + 0.09237*h[19] + 0.128332*i[1] + 0.361111)
h[18] = 0.432082*h[1] + 0.151905*h[26] + 0.444149*i[0] - 0.605303*i[1] + 0.5776
h[19] = Piecewise((0.913525*i[0] + 0.164543, 0.913525*i[0] + 0.164543 > 0), (0.004568*i[0] + 0.000823, True))
h[20] = -sin(0.129024*h[15] + 0.163934)
h[21] = 1.007134
h[22] = -tanh(-0.495377*h[15] + 0.06355*h[25] + 0.633176)
h[23] = Max(0, 0.715448*h[19] - 0.11983*h[27] - 0.359031)
h[24] = tanh(1.849501*i[0] + 0.141925)
h[25] = Max(0, 0.411862*h[26]*i[0] + 0.304906)
h[26] = 0.172775
h[27] = Max(0, 1.272269*h[24] + 0.399686)
h[28] = -0.110427
h[29] = -0.000292
h[30] = Piecewise((0.59178*h[10] - 0.154874*h[25] - 0.082747, -0.59178*h[10] + 0.154874*h[25] + 0.082747 < 0), (0.002959*h[10] - 0.000774*h[25] - 0.000414, True))
h[31] = Piecewise((0.856304*i[1] + 0.125001, 0.856304*i[1] + 0.125001 > 0), (0.004282*i[1] + 0.000625, True))
h[32] = Max(0, 0.781773*h[28] - 0.127448)
h[33] = tanh(1.0*h[2] + 0.008956)
h[34] = 0.891857*h[8]
o[0] = tanh(0.121949*h[1] + 0.020327*h[12] + 0.031256*h[13] + 0.070328*h[14] + 0.006741*h[17] + 0.030249*h[20] + 0.069293*h[4] - 0.083061*h[5] + 0.146785*h[6] - 0.09403*h[7] - 0.281119*h[8] + 0.310527)
o[1] = tanh(0.071067*h[0] + 0.093137*h[1] + 0.167901*h[13] + 0.038465*h[14] + 0.00907*h[17] + 0.064836*h[22] + 0.116218*h[32] - 0.0562*h[34] + 0.269817*h[5] - 0.012843*h[6] - 0.146425*h[7] - 0.115288)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions