Search code examples
neural-networkartificial-intelligencegenetic-algorithm

How can I prevent my program from getting stuck at a local maximum (Feed forward artificial neural network and genetic algorithm)


I'm working on a feed forward artificial neural network (ffann) that will take input in form of a simple calculation and return the result (acting as a pocket calculator). The outcome wont be exact.
The artificial network is trained using genetic algorithm on the weights.

Currently my program gets stuck at a local maximum at:

  • 5-6% correct answers, with 1% error margin
  • 30 % correct answers, with 10% error margin
  • 40 % correct answers, with 20% error margin
  • 45 % correct answers, with 30% error margin
  • 60 % correct answers, with 40% error margin

I currently use two different genetic algorithms:
The first is a basic selection, picking two random from my population, naming the one with best fitness the winner, and the other the loser. The loser receives one of the weights from the winner.

The second is mutation, where the loser from the selection receives a slight modification based on the amount of resulting errors. (the fitness is decided by correct answers and incorrect answers). So if the network outputs a lot of errors, it will receive a big modification, where as if it has many correct answers, we are close to a acceptable goal and the modification will be smaller.

So to the question: What are ways I can prevent my ffann from getting stuck at local maxima?
Should I modify my current genetic algorithm to something more advanced with more variables?
Should I create additional mutation or crossover?
Or Should I maybe try and modify my mutation variables to something bigger/smaller?

This is a big topic so if I missed any information that could be needed, please leave a comment

Edit: Tweaking the numbers of the mutation to a more suited value has gotten be a better answer rate but far from approved:

  • 10% correct answers, with 1% error margin
  • 33 % correct answers, with 10% error margin
  • 43 % correct answers, with 20% error margin
  • 65 % correct answers, with 30% error margin
  • 73 % correct answers, with 40% error margin

The network is currently a very simple 3 layered structure with 3 inputs, 2 neurons in the only hidden layer, and a single neuron in the output layer.
The activation function used is Tanh, placing values in between -1 and 1.
The selection type crossover is very simple working like the following:

[a1, b1, c1, d1] // Selected as winner due to most correct answers
[a2, b2, c2, d2] // Loser

The loser will end up receiving one of the values from the winner, moving the value straight down since I believe the position in the array (of weights) matters to how it performs.

The mutation is very simple, adding a very small value (currently somewhere between about 0.01 and 0.001) to a random weight in the losers array of weights, with a 50/50 chance of being a negative value.

Here are a few examples of training data:

1, 8, -7 // the -7 represents + (1+8)
3, 7, -3 // -3 represents - (3-7)
7, 7, 3  // 3 represents * (7*7)
3, 8, 7  // 7 represents / (3/8)

Solution

  • Use a niching techniche in the GA. A useful alternative is niching. The score of every solution (some form of quadratic error, I think) is changed in taking account similarity of the entire population. This maintains diversity inside the population and avoid premature convergence an traps into local optimum.

    Take a look here:

    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.100.7342