struct defs

typedefs

global vars

int initialize();
int input_hidden(float input_act[1221], float hidden_act[31]);
int hidden_output(float hidden_act[31], float output_act[35]);
int output_hidden(float teach[35], float output_act[35], float hidden_act[31]);
int hidden_input(float input_act[1221]);
int update_stats(float teach[35], float output_act[35], float *error);
int update_weights();
int main();

int initialize()
{
  local vars

  temp_141 = "in_pats.txt";
  temp_151 = "r";
  fp2 = fopen1(temp_141, temp_151);
  for ( pattern1 = 0 ; (pattern2 <= 29) ; pattern3 = (pattern2 + 1) )
  {
    for ( i2 = 0 ; (i3 <= 1220) ; i4 = (i3 + 1) )
    {
      /** fscanf(fp, "%f", (&next_input[pattern][i])) **/
      temp_163 = "%f";
      temp_173 = (&next_input[pattern2][i3]);
      fscanf(fp2, temp_163, temp_173);
    }
  }
  temp_181 = "out_pats.txt";
  temp_191 = "r";
  fp4 = fopen2(temp_181, temp_191);
  for ( pattern5 = 0 ; (pattern6 <= 29) ; pattern7 = (pattern6 + 1) )
  {
    for ( o2 = 0 ; (o3 <= 34) ; o4 = (o3 + 1) )
    {
      /** fscanf(fp, "%f", (&next_output[pattern][o])) **/
      temp_203 = "%f";
      temp_213 = (&next_output[pattern6][o3]);
      fscanf(fp4, temp_203, temp_213);
    }
  }
  temp_221 = "i_h_w.txt";
  temp_231 = "r";
  fp6 = fopen3(temp_221, temp_231);
  for ( h1 = 0 ; (h2 <= 29) ; h3 = (h2 + 1) )
  {
    for ( i8 = 0 ; (i9 <= 1220) ; i10 = (i9 + 1) )
    {
      /** fscanf(fp, "%f", (&i_h_weights[h][i])) **/
      temp_243 = "%f";
      temp_253 = (&i_h_weights[h2][i9]);
      fscanf(fp6, temp_243, temp_253);
    }
  }
  temp_261 = "h_o_w.txt";
  temp_271 = "r";
  fp8 = fopen4(temp_261, temp_271);
  for ( h5 = 0 ; (h6 <= 34) ; h7 = (h6 + 1) )
  {
    for ( i14 = 0 ; (i15 <= 30) ; i16 = (i15 + 1) )
    {
      /** fscanf(fp, "%f", (&h_o_weights[h][i])) **/
      temp_283 = "%f";
      temp_293 = (&h_o_weights[h6][i15]);
      fscanf(fp8, temp_283, temp_293);
    }
  }
  for ( i19 = 0 ; (i20 <= 29) ; i21 = (i20 + 1) )
  {
    for ( j2 = 0 ; (j3 <= 1220) ; j4 = (j3 + 1) )
    {
      i_h_w_ch_sum_array3[i20][j3] = 0.00000000000000e+00;
    }
  }
  for ( i23 = 0 ; (i24 <= 34) ; i25 = (i24 + 1) )
  {
    for ( j8 = 0 ; (j9 <= 30) ; j10 = (j9 + 1) )
    {
      h_o_w_ch_sum_array3[i24][j9] = 0.00000000000000e+00;
    }
  }
  i_h_lrc1 = 2.45901639344262e-04;
  h_o_lrc1 = 1.00000000000000e-02;
}

int input_hidden(
float input_act[1221], 
float hidden_act[31])
{
  local vars

  receiver1 = (&hidden_act1[0]);
  end_receiver1 = (&hidden_act1[29]);
  weight1 = (&i_h_weights[0][0]);
  for (  ; (receiver2 <= end_receiver1) ;  )
  {
    (*receiver2) = 0.00000000000000e+00;
    sender2 = (&input_act1[0]);
    end_sender2 = (&input_act1[1220]);
    for (  ; (sender3 <= end_sender2) ;  )
    {
      /** (*receiver) = ((*receiver) + ((*(sender++)) * (*(weight++)))) **/
      temp_303 = receiver2;
      temp_313 = (*temp_303);
      temp_343 = sender3;
      sender4 = (sender3 + 1);
      temp_333 = (*temp_343);
      temp_363 = weight3;
      weight4 = (weight3 + 1);
      temp_353 = (*temp_363);
      temp_323 = (temp_333 * temp_353);
      (*temp_303) = (temp_313 + temp_323);
    }
    temp_392 = (*receiver2);
    temp_402 = (-temp_392);
    temp_412 = (double ) temp_402;
    temp_383 = exp(temp_412);
    temp_372 = (1.00000000000000e+00 + temp_383);
    temp_422 = (1.00000000000000e+00 / temp_372);
    (*receiver2) = (float ) temp_422;
    temp_432 = receiver2;
    receiver3 = (receiver2 + 1);
    (*temp_43);
  }
  hidden_act1[30] = 1.00000000000000e+00;
}

int hidden_output(
float hidden_act[31], 
float output_act[35])
{
  local vars

  receiver1 = (&output_act1[0]);
  end_receiver1 = (&output_act1[34]);
  weight1 = (&h_o_weights[0][0]);
  for (  ; (receiver2 <= end_receiver1) ;  )
  {
    (*receiver2) = 0.00000000000000e+00;
    sender2 = (&hidden_act1[0]);
    end_sender2 = (&hidden_act1[30]);
    for (  ; (sender3 <= end_sender2) ;  )
    {
      /** (*receiver) = ((*receiver) + ((*(sender++)) * (*(weight++)))) **/
      temp_443 = receiver2;
      temp_453 = (*temp_443);
      temp_483 = sender3;
      sender4 = (sender3 + 1);
      temp_473 = (*temp_483);
      temp_503 = weight3;
      weight4 = (weight3 + 1);
      temp_493 = (*temp_503);
      temp_463 = (temp_473 * temp_493);
      (*temp_443) = (temp_453 + temp_463);
    }
    temp_532 = (*receiver2);
    temp_542 = (-temp_532);
    temp_552 = (double ) temp_542;
    temp_523 = exp(temp_552);
    temp_512 = (1.00000000000000e+00 + temp_523);
    temp_562 = (1.00000000000000e+00 / temp_512);
    (*receiver2) = (float ) temp_562;
    temp_572 = receiver2;
    receiver3 = (receiver2 + 1);
    (*temp_57);
  }
}

int output_hidden(
float teach[35], 
float output_act[35], 
float hidden_act[31])
{
  local vars

  for ( hu1 = 0 ; (hu2 <= 30) ; hu3 = (hu2 + 1) )
  {
    psum_array2[hu2] = 0.00000000000000e+00;
  }
  for ( ou1 = 0 ; (ou2 <= 34) ; ou3 = (ou2 + 1) )
  {
    temp_592 = teach1[ou2];
    temp_602 = output_act1[ou2];
    temp_582 = (temp_592 - temp_602);
    temp_612 = output_act1[ou2];
    temp_622 = (temp_582 * temp_612);
    temp_632 = (double ) temp_622;
    temp_652 = output_act1[ou2];
    temp_662 = (double ) temp_652;
    temp_642 = (1.00000000000000e+00 - temp_662);
    temp_672 = (temp_632 * temp_642);
    delta2[ou2] = (float ) temp_672;
    for ( hu6 = 0 ; (hu7 <= 30) ; hu8 = (hu7 + 1) )
    {
      temp_683 = hu7;
      temp_693 = psum_array5[temp_683];
      temp_713 = delta2[ou2];
      temp_723 = h_o_weights8[ou2][hu7];
      temp_703 = (temp_713 * temp_723);
      psum_array6[temp_683] = (temp_693 + temp_703);
      temp_733 = hu7;
      temp_743 = ou2;
      temp_753 = h_o_w_ch_sum_array7[temp_743][temp_733];
      temp_773 = delta2[ou2];
      temp_783 = hidden_act1[hu7];
      temp_763 = (temp_773 * temp_783);
      h_o_w_ch_sum_array8[temp_743][temp_733] = (temp_753 + temp_763);
    }
  }
  for ( hu11 = 0 ; (hu12 <= 30) ; hu13 = (hu12 + 1) )
  {
    /** hidden_delta[hu] = (float ) (((double ) hidden_act[hu] * (1.00000000000000e+00 - (double ) hidden_act[hu])) * (double ) psum_array[hu]) **/
    temp_802 = hidden_act1[hu12];
    temp_812 = (double ) temp_802;
    temp_832 = hidden_act1[hu12];
    temp_842 = (double ) temp_832;
    temp_822 = (1.00000000000000e+00 - temp_842);
    temp_792 = (temp_812 * temp_822);
    temp_852 = psum_array8[hu12];
    temp_862 = (double ) temp_852;
    temp_872 = (temp_792 * temp_862);
    hidden_delta2[hu12] = (float ) temp_872;
  }
}

int hidden_input(
float input_act[1221])
{
  local vars

  delta1 = (&hidden_delta[0]);
  end_delta1 = (&hidden_delta[29]);
  w_ch1 = (&i_h_w_ch_sum_array[0][0]);
  for (  ; (delta2 <= end_delta1) ;  )
  {
    sender2 = (&input_act1[0]);
    end_sender2 = (&input_act1[1220]);
    for (  ; (sender3 <= end_sender2) ;  )
    {
      /** (*(w_ch++)) = ((*(w_ch++)) + ((*delta) * (*(sender++)))) **/
      temp_893 = w_ch3;
      w_ch4 = (w_ch3 + 1);
      temp_883 = temp_893;
      temp_903 = (*temp_883);
      temp_923 = (*delta2);
      temp_943 = sender3;
      sender4 = (sender3 + 1);
      temp_933 = (*temp_943);
      temp_913 = (temp_923 * temp_933);
      (*temp_883) = (temp_903 + temp_913);
    }
    delta3 = (delta2 + 1);
  }
}

int update_stats(
float teach[35], 
float output_act[35], 
float *error)
{
  local vars

  for ( ou1 = 0 ; (ou2 <= 34) ; ou3 = (ou2 + 1) )
  {
    /** (*error) = ((*error) + ((teach[ou] - output_act[ou]) * (teach[ou] - output_act[ou]))) **/
    temp_952 = error1;
    temp_962 = (*temp_952);
    temp_992 = teach1[ou2];
    temp_1002 = output_act1[ou2];
    temp_982 = (temp_992 - temp_1002);
    temp_1022 = teach1[ou2];
    temp_1032 = output_act1[ou2];
    temp_1012 = (temp_1022 - temp_1032);
    temp_972 = (temp_982 * temp_1012);
    (*temp_952) = (temp_962 + temp_972);
  }
}

int update_weights()
{
  local vars

  for ( iu1 = 0 ; (iu2 <= 1220) ; iu3 = (iu2 + 1) )
  {
    for ( hu2 = 0 ; (hu3 <= 29) ; hu4 = (hu3 + 1) )
    {
      temp_1043 = iu2;
      temp_1053 = hu3;
      temp_1063 = i_h_weights7[temp_1053][temp_1043];
      temp_1083 = i_h_w_ch_sum_array12[hu3][iu2];
      temp_1073 = (temp_1083 * i_h_lrc7);
      i_h_weights8[temp_1053][temp_1043] = (temp_1063 + temp_1073);
      temp_1093 = iu2;
      temp_1103 = hu3;
      temp_1113 = i_h_w_ch_sum_array12[temp_1103][temp_1093];
      temp_1123 = (double ) temp_1113;
      temp_1133 = (temp_1123 * 9.00000000000000e-01);
      i_h_w_ch_sum_array13[temp_1103][temp_1093] = (float ) temp_1133;
    }
  }
  for ( hu7 = 0 ; (hu8 <= 30) ; hu9 = (hu8 + 1) )
  {
    for ( ou2 = 0 ; (ou3 <= 34) ; ou4 = (ou3 + 1) )
    {
      temp_1143 = hu8;
      temp_1153 = ou3;
      temp_1163 = h_o_weights7[temp_1153][temp_1143];
      temp_1183 = h_o_w_ch_sum_array12[ou3][hu8];
      temp_1173 = (temp_1183 * h_o_lrc7);
      h_o_weights8[temp_1153][temp_1143] = (temp_1163 + temp_1173);
      temp_1193 = hu8;
      temp_1203 = ou3;
      temp_1213 = h_o_w_ch_sum_array12[temp_1203][temp_1193];
      temp_1223 = (double ) temp_1213;
      temp_1233 = (temp_1223 * 9.00000000000000e-01);
      h_o_w_ch_sum_array13[temp_1203][temp_1193] = (float ) temp_1233;
    }
  }
}

int main()
{
  local vars

  temp_1241 = "initializing backprop parameters\n";
  printf(temp_1241);
  initialize1();
  temp_1251 = "starting training\n";
  printf(temp_1251);
  for ( epoch1 = 0 ; (epoch2 <= 199) ; epoch3 = (epoch2 + 1) )
  {
    error2 = 0.00000000000000e+00;
    for ( pattern2 = 0 ; (pattern3 <= 29) ; pattern4 = (pattern3 + 1) )
    {
      temp_1263 = (&next_input[pattern3]);
      temp_1273 = (float *) temp_1263;
      temp_1283 = hidden_act;
      input_hidden2(temp_1273, temp_1283);
      temp_1293 = hidden_act;
      temp_1303 = output_act;
      hidden_output3(temp_1293, temp_1303);
      temp_1313 = (&next_output[pattern3]);
      temp_1323 = (float *) temp_1313;
      temp_1333 = output_act;
      temp_1343 = (&error);
      update_stats4(temp_1323, temp_1333, temp_1343);
      temp_1353 = (&next_output[pattern3]);
      temp_1363 = (float *) temp_1353;
      temp_1373 = output_act;
      temp_1383 = hidden_act;
      output_hidden5(temp_1363, temp_1373, temp_1383);
      temp_1393 = (&next_input[pattern3]);
      temp_1403 = (float *) temp_1393;
      hidden_input6(temp_1403);
    }
    update_weights7();
    temp_1412 = "EPOCH NUMBER %d: ERROR = %.5f\n";
    temp_1422 = (epoch2 + 1);
    temp_1432 = (error5 / 1.05000000000000e+03);
    temp_1442 = (double ) temp_1432;
    printf(temp_1412, temp_1422, temp_1442);
  }
}