Giter Club home page Giter Club logo

nas_via_geneticalgorithms's Introduction

Genetic Algorithms for Neural Architecture Search

Introduction

This project performs neural architecture search via various evolution strategies (crossover, mutation and selection). It performs an NAS on a shallow CNN to be trained on the CIFAR-10 dataset.

This code can be used to find the perfect NN for your specific dataset.

Requirements

python3
keras
tensorflow

I also recommend using a GPU.

How to run

python ga_nas.py

or run

ga_nas.ipynb

Programming Strategies

This project uses some strategies with respect to how the DNA is translated to its phenotype.

Translation scheme

The genotype of an individual consists of 1 + 3 * N values, where N is the network depth. Since the problem is an image recogntion problem, it reqires a feature extraction stage, then a flattening layer and then a fully connected stage to perform the classifcation.

The first entry in the DNA determines the layer number before which the flattening occurs. In the current implementation this is the ultimate or penultimate layer and the first entry is either a 1 or a 0. Each subsequent triplet determines a layer and its parameters. The following table indicates the phenotype translation of a triplet.

First value of the triplet: determines layer type depending on the stage it is in (feature extraction or classification):

Value Feature extraction Classifiaction
0 Conv Dense
1 Dropout Dropout
2 Pooling Gaussian Noise

The second value of the triplet determines a parameter of the layer depending on the layer. It's a number from 0 to 9:

Layer type Parameter (p)
Conv 2 * p = number of filters
Dense 10 * p = number of neurons
Dropout 0.1 * p = dropout rate
Pooling 2 + p = stride
Gaussian Noise 0.1 * p = standard deviation

The third value of the triplet determines another parameter of the layer. It is a number from 0 to 3:

Layer type Parameter (q)
Conv 2 * q + 1 = kernel size
Pooling pooling type (max if less than 2, average otherwise)

The other layers dont require a second parameter.

The at the beginning of ga_nas.py there are some hyperparameters predefined. These can be adjusted according to the user's needs.

Future improvements

  1. a more stable genotype encoding strategy. A single mutation has the possibility to change an entire layer. This is not condusive to successful evolution.
  2. incorporate various other factors into the fitness evaluation. Often it's not only accuracy that determines the quality of a network, but also speed (i.e. real time image recognition).
  3. encode more hyperparameters of the network into DNA. The learning rate, batch size etc. are good candidated for optimization via genetic algorithms as well
  4. variable network depth. Randomly select number of layers of an individual in the population.

nas_via_geneticalgorithms's People

Stargazers

jitendra chautharia avatar  avatar

Watchers

James Cloos avatar Justin MacPherson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.