Git Product home page Git Product logo

genetic-algo's Introduction

genetic algorithm package written in c and python

uses c for speed with python interface custom neural network architecture

todo

  • make c modules with each type of activation
  • test activations
  • droput
  • test dropout
  • make c activations hook up into one another
  • test layers
  • create nn
  • test nn
  • create init function
  • test
  • add and edit layers
  • test
  • feedforward
  • test
  • thread computation
  • test
  • model archetirure with string
  • test
  • create python wrapper
  • create nn objection
  • make everything interfaceable
  • save and load nn in python
  • test
  • allow user to add activation functions
  • rewrite ga from python into c
  • test all python code
  • code up some examples

documentation

C Structs and Functions

  • Reminder most C structs and functions are accessible from Python

Activation Functions

  • a_relu(double *inputs, double *weights, double bias, int length)

    • Returns the ReLU function of the given weights and biases as a double
  • a_sigmoid(double *inputs, double *weights, double bias, int length)

    • Returns the sigmoid function of the given weights and biases as a double
  • double a_tanh(double *inputs, double *weights, double bias, int length)

    • Returns the hyperbolic tangent function of the given weights and biases as a double

Layer Struct and Layer Functions

  • layer

    • Struct
    • int input length
    • int length of the layer
    • double array of biases
    • 2 dimensional double array of weights
    • char representing activation type
  • init_weights(struct layer *sheet)

    • Void
    • Generates a 2 dimensional empty array of doubles for the layer struct
  • init_biases(struct layer *sheet)

    • Void
    • Generates an empty array of doubles for the layer struct
  • output(struct layer *sheet, double *inputs)

    • Returns a double array
    • Uses activation from layer to calculate the output given an array of doubles

Neural Network Struct and Functions

  • nn

    • Struct
    • Array of layer structs
    • int length
  • network_init(struct nn *network, int randomized)

    • Initializes empty arrays of weights and biases from array of layers
  • struct nn create_nn(char *arc)

    • Generates an nn struct based on a given string architecture
    • String architecture looks like the following:
      • "xi|xa|" where x is any int and a is any valid activation function
      • "xa|" is repeated for each layer in nn struct
  • add_layer(struct nn *network, char *arc_part)

    • Adds a layer struct to nn's array of layers
    • *arc_part must be in the form of "xa|"
  • feedforward(struct nn *network, double *inputs)

    • Calculates output of network given a set of inputs in a double array

Python Classes and Methods

Wrapper

C Functions
  • a_relu(double *inputs, double *weights, double bias, int length)

    • Returns the ReLU function of the given weights and biases as a double
  • a_sigmoid(double *inputs, double *weights, double bias, int length)

    • Returns the sigmoid function of the given weights and biases as a double
  • double a_tanh(double *inputs, double *weights, double bias, int length)

    • Returns the hyperbolic tangent function of the given weights and biases as a double
  • layer

    • CTypes Struct
    • int input length
    • int length of the layer
    • double array of biases
    • 2 dimensional double array of weights
    • char representing activation type
  • init_weights(struct layer *sheet)

    • Void
    • Generates a 2 dimensional empty array of doubles for the layer struct
  • init_biases(struct layer *sheet)

    • Void
    • Generates an empty array of doubles for the layer struct
  • output(struct layer *sheet, double *inputs)

    • Returns a double array
    • Uses activation from layer to calculate the output given an array of doubles
  • nn

    • CTypes Struct
    • Array of layer structs
    • int length
  • network_init(struct nn *network, int randomized)

    • Initializes empty arrays of weights and biases from array of layers
  • struct nn create_nn(char *arc)

    • Generates an nn struct based on a given string architecture
    • String architecture looks like the following:
      • "xi|xa|" where x is any int and a is any valid activation function
      • "xa|" is repeated for each layer in nn struct
  • add_layer(struct nn *network, char *arc_part)

    • Adds a layer struct to nn's array of layers
    • *arc_part must be in the form of "xa|"
  • feedforward(struct nn *network, double *inputs)

    • Calculates output of network given a set of inputs in a double array

C Conversion Functions and Other C Functions in Python

  • init_c

    • Initializes shared object file with C functions
  • toCDouble(value)

    • Converts Python numeric to C double
  • toCInt(value)

    • Converts Python numeric to C int
  • toCChar(value)

    • Converts Python character to C char
  • CValtoPyValue(c_value)

    • Generic C value conversion to Python object
  • toCDoubleArray(arr)

    • Converts numeric Python array to array of C doubles
  • CDoubletoPyArray(arr, length)

    • Converts C double array to Python array given the length as an int
  • doubleToArrayToPointer(arr, shape)

    • Converts 2 dimensional numeric Python array to 2 dimensional C array of doubles
    • shape must be a tuple, (n, m) that specifies dimensions of array
  • writeToLayer(layer, arr, shape)

    • Writes double array to layer given shape
    • shape must be a tuple, (n, m) that specifies dimensions of array
    • layer must be CTypes layer struct

Neural Network Class

helpful links

genetic-algo's People

Contributors

nikhilmukraj avatar

Watchers

 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.