{"id":15554934,"url":"https://github.com/cactuswhiskey/tensor-evolution","last_synced_at":"2025-04-23T19:48:29.669Z","repository":{"id":37851280,"uuid":"469993067","full_name":"cactusWhiskey/tensor-evolution","owner":"cactusWhiskey","description":"Evolutionary algorithm for neural network structure","archived":false,"fork":false,"pushed_at":"2023-03-08T19:05:15.000Z","size":237,"stargazers_count":3,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T04:05:38.514Z","etag":null,"topics":["deap","evolutionary-algorithm","machine-learning","neural-network","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cactusWhiskey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-15T03:35:56.000Z","updated_at":"2022-08-06T14:40:01.000Z","dependencies_parsed_at":"2024-10-02T15:05:05.886Z","dependency_job_id":null,"html_url":"https://github.com/cactusWhiskey/tensor-evolution","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cactusWhiskey%2Ftensor-evolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cactusWhiskey%2Ftensor-evolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cactusWhiskey%2Ftensor-evolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cactusWhiskey%2Ftensor-evolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cactusWhiskey","download_url":"https://codeload.github.com/cactusWhiskey/tensor-evolution/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250504085,"owners_count":21441527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deap","evolutionary-algorithm","machine-learning","neural-network","tensorflow"],"created_at":"2024-10-02T15:05:01.987Z","updated_at":"2025-04-23T19:48:29.619Z","avatar_url":"https://github.com/cactusWhiskey.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tensor Evolution\n\n\nTensor-Evolution is a library for evolving neural network topology using a genetic algorithm. This library currently \nuses [Deap](https://github.com/DEAP/deap) as its evolutionary backend, and [Tensorflow](https://github.com/tensorflow/tensorflow) \nfor the neural networks. Ray is used for parallel execution.\u003cbr\u003e\n\nNote that this library doesn't build networks a single neuron at a time, the basic building blocks are entire layers.\n\n\n## Philosophy\n\nPopulation members start as the input layer connected directly to the output layer. Mutation operators exist for \ninserting layers (from a list of supported types), deleting layers, and for mutating an existing layer's properties. A \ncrossover operator is also implemented.\n\nFitness is evaluated by building, compiling, and training a model from each population member's genome. \nTraining is done the standard way (i.e. via backpropagation, not through any evolutionary means).\n\nNote that most layer types can be added amost anywhere in the genome. If the input shape isn't right, it's corrected \n(attempts are made to correct it intelligently, but if required it's forced to fit). \n\n## Supported Layer Types\n\n\n\nThis list is currently expanding. So far:\n\n- Dense\n- ReLu\n- Conv2D, 3D\n- Maxpool2D, 3D\n- Addition\n- BatchNorm\n- Flatten\n- LSTM\n- GlobalAvgPooling 1D\n- Embedding\n- Concat\n\n## Installation\n\n\n```pip install tensor-evolution ```\n\n## Usage\n\n\n\n### Running an Evolution\nStart by importing the *tensor_evolution* module. This is the main driver for the evolution. \n\n```import tensorEvolution```\n\nNext, prepare your data as a tuple of four objects, like so:\n\n```data = x_train, y_train, x_test, y_test```\n\nThen create an evolution worker, and use that worker to drive the evolution:\n\n```worker = tensor_evolution.EvolutionWorker()```\n```worker.evolve(data=data)```\n\nPlease reference the end to end examples for full details.\n\n### Configuration\n\nEverything is configured via yaml file.\n\nFor example, to change population size to 30:\n\n```\n####\n# Evolution Controls\n####\n...\npop_size: 30 #population size\n\n```\n\nMutation rates, valid neural network layer types, **input and output shapes**, etc. are all controlled from the config file.\n\n## Project Status\n\n\nVery much still a work in progress, (as is this readme), but it is functional. The mnist, autompg, and text classification examples runs just fine.\n\n## Dependencies\n\n| Library                                                | License                                                                                        |\n|--------------------------------------------------------|------------------------------------------------------------------------------------------------|\n| [tensorflow](https://github.com/tensorflow/tensorflow) | [Apache License 2.0](https://github.com/tensorflow/tensorflow/blob/master/LICENSE)             |\n| [networkx](https://github.com/networkx/networkx)       | [BSD 3-Clause](https://github.com/networkx/networkx/blob/main/LICENSE.txt)                     |\n| [ray](https://github.com/ray-project/ray)              | [Apache License 2.0](https://github.com/ray-project/ray/blob/master/LICENSE)                   |\n| [numpy](https://github.com/numpy/numpy)                | [BSD 3-Clause](https://github.com/numpy/numpy/blob/main/LICENSE.txt)                           |\n| [deap](https://github.com/DEAP/deap)                   | [GNU Lesser General Public License v3.0](https://github.com/DEAP/deap/blob/master/LICENSE.txt) |\n| [matplotlib](https://github.com/matplotlib/matplotlib) | [License Details](https://matplotlib.org/3.5.0/users/project/license.html#license-agreement)   |\n| [sympy](https://github.com/sympy/sympy)                | [License Details](https://github.com/sympy/sympy/blob/master/LICENSE)                          |\n| [graphviz](https://github.com/graphp/graphviz)         | [MIT License](https://github.com/graphp/graphviz/blob/master/LICENSE)                          |\n\n\n## MNIST Results\n\nThe best individual after running MNIST with a population of 20 individuals for 10 generations:\n\n![MNIST Genome](/doc/images/MNIST.svg) \n\n```\n_________________________________________________________________\n Layer (type)                Output Shape              Param #   \n=================================================================\n input_4 (InputLayer)        [(None, 28, 28)]          0         \n                                                                 \n reshape (Reshape)           (None, 28, 28, 1)         0         \n                                                                 \n conv2d (Conv2D)             (None, 28, 28, 16)        272       \n                                                                 \n conv2d_1 (Conv2D)           (None, 28, 28, 8)         1160      \n                                                                 \n flatten (Flatten)           (None, 6272)              0         \n                                                                 \n dense (Dense)               (None, 10)                62730     \n                                                                 \n=================================================================\nTotal params: 64,162\nTrainable params: 64,162\nNon-trainable params: 0 \n```\n## Auto MPG Dataset Results\n\nThe best individual after running Auto MPG with a population of 100 individuals for 20 generations:\n\n![AutoMPG Genome](/doc/images/AutoMPG.svg) \n\n```\n__________________________________________________________________________________________________\n Layer (type)                   Output Shape         Param #     Connected to                     \n==================================================================================================\n input_1 (InputLayer)           [(None, 9)]          0           []                               \n                                                                                                  \n dropout (Dropout)              (None, 9)            0           ['input_1[0][0]']                \n                                                                                                  \n add (Add)                      (None, 9)            0           ['input_1[0][0]',                \n                                                                  'dropout[0][0]']                \n                                                                                                  \n dense (Dense)                  (None, 256)          2560        ['add[0][0]']                    \n                                                                                                  \n flatten (Flatten)              (None, 256)          0           ['dense[0][0]']                  \n                                                                                                  \n dense_1 (Dense)                (None, 1)            257         ['flatten[0][0]']                \n                                                                                                  \n==================================================================================================\nTotal params: 2,817\nTrainable params: 2,817\nNon-trainable params: 0\n__________________________________________________________________________________________________\n\nEvaluation Results\n3/3 [==============================] - 0s 0s/step - loss: 1.5367 - mean_absolute_error: 1.5367\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcactuswhiskey%2Ftensor-evolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcactuswhiskey%2Ftensor-evolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcactuswhiskey%2Ftensor-evolution/lists"}