GeneticAlgorithmPython icon indicating copy to clipboard operation
GeneticAlgorithmPython copied to clipboard

maximize the output of a built neural net( by pytorch) with continuous and discrete/integer variables

Open AmosJoseph opened this issue 2 years ago • 5 comments

Hi, can this library be used to maximize the output of a well-built neural net( by pytorch) with continuous and discrete/integer (1, 2, 3 ) variables?

Is there any example?

Best!

AmosJoseph avatar Jul 14 '23 14:07 AmosJoseph

It can train models built in Keras and PyTorch.

Here you can find examples for training PyTorch models: https://github.com/ahmedfgad/GeneticAlgorithmPython/tree/master/examples/TorchGA

ahmedfgad avatar Jul 14 '23 14:07 ahmedfgad

Thank you for your reply! The neural net has been trained and tested with good accuracy.

Then how to maximize the output of the neural net in the input domain?

发自我的iPhone

------------------ Original ------------------ From: Ahmed Gad @.> Date: Fri,Jul 14,2023 10:43 PM To: ahmedfgad/GeneticAlgorithmPython @.> Cc: AmosJoseph @.>, Author @.> Subject: Re: [ahmedfgad/GeneticAlgorithmPython] maximize the output of a builtneural net( by pytorch) with continuous and discrete/integer variables (Issue#220)

AmosJoseph avatar Jul 14 '23 14:07 AmosJoseph

Do you you mean change the inputs (not the neural network itself) so that their outputs are accurate? If this is the case, then yes it can be done. Although there is no example yet, it can be developed easily.

ahmedfgad avatar Jul 14 '23 14:07 ahmedfgad

Yes. Find the inputs (not the neural network itself) so that their outputs are maximum.

Then how to implement this?

Best!

发自我的iPhone

------------------ Original ------------------ From: Ahmed Gad @.> Date: Fri,Jul 14,2023 10:55 PM To: ahmedfgad/GeneticAlgorithmPython @.> Cc: AmosJoseph @.>, Author @.> Subject: Re: [ahmedfgad/GeneticAlgorithmPython] maximize the output of a built neural net( by pytorch) with continuous and discrete/integer variables (Issue #220)

Do you you mean change the inputs (not the neural network itself) so that their outputs are accurate? If this is the case, then yes it can be done. Although there is no example yet, it can be developed easily.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

AmosJoseph avatar Jul 14 '23 15:07 AmosJoseph

Sorry for the long time to follow up. Just decided to reply in case it would still be helpful even for someone else.

Then what evolves is the inputs. Here are the steps:

  1. Set the num_genes parameter to the length of a single input.
  2. Inside the fitness function, pass the input to the neural network to return the predicted output.
  3. Calculate the fitness by comparing the predicted and desired outputs.

ahmedfgad avatar Jan 28 '24 19:01 ahmedfgad