Package: keras-genetic
Keras GeneticKeras Genetic allows you to easily train Keras models using genetic algorithms.Quick Links:CartpoleMNIST Image ClassificationOverviewQuickstartBackgroundKerasGenetic allows you to leverage the elegent modeling API Keras while performing
training with genetic algorithms.  Typically, Keras neural network weights are optimized
by minimizing a loss function through the process of gradient descent.Keras Genetic takes a different approach to weight optimization by leveraging
genetic algorithms.  Genetic algorithms allow you to optimize a neural network
without in scenarios where there is no information about the loss landscape.Genetic algorithms can be used to train neural networks in niche cases where you need to
train a specialized controller with <1000 parameters.Some areas where genetic algorithms are applied today:Reinforcement learning (WorldModels)FinanceOverviewThe Keras genetic API is quick to get started with, but flexible enough to fit
any use case you may come up with.There are three core components of the API that must be used to get started:theIndividualtheEvaluatortheBreedersearch()IndividualTheIndividualclass represents an individual in the population.The most important method on theIndividualclass isload_model().load_model()yields a Keras model with the weights stored on theindividualclass loaded:model=individual.load_model()model.predict(some_data)EvaluatorNext, lets go over theEvaluator.  TheEvaluatoris responsible for
determining the strength of anIndividual.  Perhaps the simplest
evaluator is an accuracy evaluator for a classification task:defevaluate_accuracy(individual:keras_genetic.Individual):model=individual.load_model()result=model.evaluate(x_train[:100],y_train[:100],return_dict=True,verbose=0)returnresult["accuracy"]Theevaluate_accuracy()function defined above maps from anIndividualto an
accuracy score.  This score can be used to select the individuals that will be
used in the next generation.BreederTheBreederis responsible with producing new individuals from a set of parent
individuals.  The details as to how eachBreederproduces new individuals are
unique to the  breeder, but as a general rule some attributes of the parent are
preserved while some new attributes are randomly sampled.For most users, theTwoParentMutationBreederis sufficiently effective.search()search()is akin tomodel.fit()in the core Keras framework.  Thesearch()API
supports a wide variety of parameters.  For an in depth view, browse the API docs.Here is a sample usage of thesearch()function:results=keras_genetic.search(model=model,# computational cost is evaluate*generations*population_sizeevaluator=evaluate_accuracy,generations=10,population_size=50,n_parents_from_population=5,breeder=keras_genetic.breeder.MutationBreeder(),return_best=1,)Further ReadingCheck out theexamplesand guides (Coming Soon!).QuickstartFor now, theCartpole Exampleserves as the Quickstart guide.RoadmapI'd like to accomplish the following tasks:✅ stabilize the base API✅ support a callbacks API✅ end to end MNIST example✅ end to end CartPole example✅ implement a ProgBarLogger✅ implement EarlyStopping callback (can be used in CartPole example)have at least 3 distinct breedersautogenerate documentationthoroughly document each componentoffer implementations of  the most effective genetic algorithmsimplement unit tests for each componentsupport random seedingthoroughly review the API per Keras core API design guidelinessupport custom initial populations (i.e. to model after a human imitation model)support keep_probability schedulesFeel free to contribute any of these.Citation@misc{wood2022kerasgenetic,title={Keras Genetic},author={Luke Wood},year=2022,howpublished={\url{https://github.com/lukewood/keras-genetic}}}