The Complete SPRLIB & ANNLIB

print_c_code

- write the code necessary to evaluate a network to a C file (LOCAL)

SYNOPSIS

int print_c_code (stream, net)

ARGUMENTS

FILE *stream A valid filepointer.
NET *net A pointer to a NET structure.

RETURNS

FALSE if successful, TRUE if not.

FUNCTION

This function is used by make_source_ffnet to write the code necessary to evaluate the network net to a C file. The code written is:
void eval_c_ffnet (input, output)
double *input, *output;
{
  int i,j;

  for (i = 0; i < NR_HUNITS; i++)
  {
    HidActivation[i] = 0.0;
  
    for (j = 0; j < NR_INPUTS; j++)
      HidActivation[i] += InWeights[i][j] * input[j+1];
 
    HidActivation[i] += InWeights[i][NR_INPUTS];

    HidActivation[i] = 1.0 / (1.0 + exp (-1.0 * HidActivation[i]));
  }
 
  for (i = 0; i < NR_OUTPUTS; i++)
  {
    output[i+1] = 0.0;
  
    for (j = 0; j < NR_HUNITS; j++)
      output[i+1] += OutWeights[i][j] * HidActivation[j];

    output[i+1] += OutWeights[i][NR_HUNITS];

    output[i+1] = 1.0 / (1.0 + exp (-1.0 * output[i+1]));
  }
}

The written function, eval_c_ffnet, expects a vector of input values and returns a vector of output values.

SEE ALSO

make_source_ffnet, printfile, print_c_header, print_inweights, print_outweights

This document was generated using api2html on Thu Mar 5 09:00:00 MET DST 1998