title: Training neural network for function approximation
body: <p>I've got absolutely no experience with neural networks and for now I'm just playing with FANN library to learn them. So the objective is to train the network to approximate the sine function. For that I'm using 3 layer NN  1 input, 3 hidden and 1 output neuron. the code is </p>
  
  <pre><code>const unsigned int num_input = 1;
  const unsigned int num_output = 1;
  const unsigned int num_layers = 3;
  const unsigned int num_neurons_hidden = 3;
  
  struct fann *ann;
  
  ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);
  
  fann_set_activation_steepness_hidden(ann, 1);
  fann_set_activation_steepness_output(ann, 1);
  
  fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
  fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
  
  fann_set_train_stop_function(ann, FANN_STOPFUNC_BIT);
  fann_set_bit_fail_limit(ann, 0.01f);
  
  fann_set_training_algorithm(ann, FANN_TRAIN_RPROP);
  
  fann_randomize_weights(ann, 0, 1);
  
  for(int i=0; i&lt;2; ++i) {
      for(float angle=0; angle&lt;10; angle+=0.1) {
          float sin_anle = sinf(angle);
          fann_train(ann, &amp;angle, &amp;sin_anle);
      }
  }
  
  int k = 0;
  for(float angle=0; angle&lt;10; angle+=0.1) {
      float sin_anle = sinf(angle);
      float *o = fann_run(ann, &amp;angle);
      printf("%d\t%f\t%f\t\n", k++, *o, sin_anle);
  }
  
  fann_destroy(ann);
  </code></pre>
  
  <p>However I've got results that has nothing to do with the real sine function. I suppose that there is some fundamental error in my network design.</p>