hasinaxp / simple-neural-network

a simple neural network from scratch.
15 stars 5 forks source link

Mutation function? #2

Open Bobingstern opened 2 years ago

Bobingstern commented 2 years ago

This is great! I want to use this for neuro evolution but I can’t figure out how to mutate all the weights by a probability…

hasinaxp commented 2 years ago

To mutate the weights depending on the probability you first need to convert the probability into delta error. then the rest is the same. However this one is just a simple example, so it's not so efficient in terms of performance. For better performance in the case of neuroevolution, you need to use relu and sigmoid both in different layers as activation functions and introduce dropout.

this concept comes from local minima. Our goal is to make the error minimum. So we try to calculate the derivative of the error with respect to the weights. This gives us the direction, i.e. whether to increase a certain weight or to decrease. now we decrease or increase the given weight by a small amount. this is considered as the learning weight. you need to have a basic knowledge of calculus to understand how to calculate partial derivatives or the direction of minima. You can search for gradient descent for more clear information.

Bobingstern commented 2 years ago

Oh ok, I have never properly learned calculus before but I’ll look into it, thanks!