Home Up Mail an Joachim Pimiskern Impressum

TFeedForward3

An Object Pascal class for backpropagation with three neuron layers

Joachim Pimiskern. Freeware. Started 22.Dec.1995 with Turbo Pascal. Ported to Object Pascal (the language of Borland Delphi) at 7.Apr.1999.

Download

TFeedFwd3 is an implementation of a certain kind of neural nets, the feed-forward network. This implementation learns with backpropagation. There are three layers of neurons: the input layer, the hidden layer and the output layer. Hidden means, the user of the net is not interested in accessing this layer. The input neurons don't do any calculation, they only reflect the input data. The hidden and the output layer do calculate.

First of all, you create an object instance:
 uses feedfwd3;
  ...
  var NeuralNet: TFeedFwd3;
  ...
  NeuralNet := TFeedFwd3.Create(<NrInput>,
                                <NrHidden>,
                                <NrOutput>,
                                <Eta>);

NrInput is the number of neurons in the input layer. NrHidden is the number of neurons in the middle layer. NrOutput is the number of output neurons. Eta is a parameter that influences the speed of learning. One can experiment with it, the value is typically 0.2.

[1] Training: Give some data to the input layer of the net. Values can be any doubles between 0.0 and 1.0.
  var i: integer;
  ...
  for i := 0 to <NrInput> - 1 do
      NeuralNet.SetInput(i,<value>);

Now tell the net, what the ouput value for that input vector should be. Training means, you have many pairs (input vector, output vector).
  for i := 0 to <NrOuput> - 1 do
      NeuralNet.SetSollwert(i,<value>);

Now let the net map the input to the output:
  NeuralNet.FeedForward;

This would be the right point to compare the output of the net with the functions GetOutput(i) and GetSollwert(i) and sum up the abs() of the differences of these values.

There are differences between the values the net has now put out and the values the net should have put out. These differences are known to the net and can now be used to correct its weights and thresholds:
  NeuralNet.FeedBackward;
If you have more training examples or more time, repeat at [1].

Use the trained net: Set a sample vector into the input layer:
  var i: integer;
  ...
  for i := 0 to <NrInput> - 1 do
      NeuralNet.SetInput(i,<value>);

Map it to the output layer:
  NeuralNet.FeedForward;

Read out the results:
  for i := 0 to <NrOutput> - 1 do
      DoSomethingWith(NeuralNet.GetOutput(i));

Make the net permanent, eventually:
  NeuralNet.SaveToFile(<Filename>);
  NeuralNet.LoadFromFile(<Filename>);

Exiting the program - destroy the object instance:
NeuralNet.Free;

Home Up Mail an Joachim Pimiskern Impressum