mrkwjc / ffnet

Feed-forward neural network for python
GNU Lesser General Public License v3.0
12 stars 7 forks source link

Genetic algorithm training #6

Open Nitrooo opened 5 years ago

Nitrooo commented 5 years ago

Can anybody provide an example of how to train a network with a genetic algorithm using ffnet? Pseudocode for the GA part would suffice. I'd like to use DEAP (https://deap.readthedocs.io/en/master/) to train a NN using a simulation as fitness function. I just want to make sure I'm using ffnet the right (and best) way. Thanks.

mrkwjc commented 5 years ago

Fot GA training in ffnet you do something like that (see examples):

net.train_genetic(input, target, individuals=20, generations=500)

The 'individual' here is a vector of network weights. This method is higly inefficient for larger networks. It can be useful however for searching a good starting point for other algorithms.

BTW: you cannot use custom fitness functions in ffnet (in an easy way at least), ffnet always minimizes sum of squared errors at network output.