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

南笙酒味 提交于 2019-12-05 04:10:32

问题


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)

回答1:


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




回答2:


A common problem when using GAs to train ANNs is that the population becomes highly correlated as training progresses. You could try increasing mutation chance and/or effect as the error-change decreases. In English. The population becomes genetically similar due to crossover and fitness selection as a local minim is approached. You can introduce variation by increasing the chance of mutation.




回答3:


You can do a simple modification to the selection scheme: the population can be viewed as having a 1-dimensional spatial structure - a circle (consider the first and last locations to be adjacent).

The production of an individual for location i is permitted to involve only parents from i's local neighborhood, where the neighborhood is defined as all individuals within distance R of i. Aside from this restriction no changes are made to the genetic system.

It's only one or a few lines of code and it can help to avoid premature convergence.

References: TRIVIAL GEOGRAPHY IN GENETIC PROGRAMMING (2005) - Lee Spector, Jon Klein



来源:https://stackoverflow.com/questions/21210841/how-can-i-prevent-my-program-from-getting-stuck-at-a-local-maximum-feed-forward

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!