GithubHelp home page GithubHelp logo

generic-github-user / caesium Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 1.0 3.63 MB

General-purpose AI library with NEAT-style genetic algorithm.

Home Page: https://generic-github-user.github.io/Caesium/src/versions/javascript/projects/network-visualization/

License: MIT License

HTML 0.73% JavaScript 98.86% CSS 0.41%
ai artificial-intelligence neural-networks neuroevolution artificial-neural-networks artificial-general-intelligence neat evolutionary-algorithm

caesium's Introduction

Caesium

An evolutionary neural network implementation, inspired by Neuroevolution of Augmenting Topologies. The Caesium library is currently available for JavaScript. Python and Node.js implementations are planned.

Design

Architecture

The neural network architecture used for Caesium deviates substantially from that of a traditional neural network.

For one, there are no "weights" used in the synapses. This is perhaps the most integral part of a neural network, and the one that most closely mimics a biological neural network. Caesium's goal is not to imitate biological neural networks, but to take advantage of the unique abilities of computational processing to create a new kind of data model.

Caesium aims to create as basic as possible a framework for the evolutionary optimization strategy to build a model with. At the highest level, this is reflected by Caesium's NEAT architecture, which uses individual nodes and connections to represent the flow of data, instead of linear stacks of "layers".

Operations

Caesium uses basic operations performed on data to represent its computations, instead of a traditional model with weights, biases, activation functions, and other properties of traditional neural networks. Operations are completed in nodes, and there are currently two types: addition and multiplication. Both nodes can have an infinite number of inputs and an infinite number of outputs. The addition node takes several scalar values as input and returns the sum of all these values as its output. The multiplication node returns the product of all of its inputs.

A more basic representation of operations performed on data allows for more flexible, versatile models.

Data

Delays

The flow of data through neural networks in Caesium is regulated by delays, stored in the connections between nodes.

Evaluation

The value of each node is evaluated simultaneously based on a buffer of the stored values of each node. Similarly to a biological neural network, the entire network is constantly being updated and re-evaluated, as opposed to a traditional model, in which each layer would be evaluated sequentially, until the output layer is calculated. This would not be feasible for the organic style of Caesium's networks, in which input and output nodes are spread throughout the network. Constant evaluation also allows for the network to constantly "think" about problems that may require more than one computational iteration to solve, and allows the network to recursively apply dynamic mathematical operations and functions on data to iteratively transform it.

For example, instead of stacking several multiplication nodes together to approximate an exponent function, the network could develop a "multiplication loop" that multiplies the result of a computation by another number, then repeats this operation on the output of the function until another signal tells the network to end the loop and send the output to the global output node, theoretically allowing for more efficiency and smaller networks.

Evolutionary Development of Models

Training

Limits

A hard limit can be placed on the number of nodes and/or connections that the neuroevolution algorithm can add to the network. This prevents the network growing indefinitely in size and reduces memory usage. It also encourages the evolution-based optimization algorithm to find better solutions to problems with fewer nodes, therefore reducing overfitting and improving generalization.

Implementations

This is a technical guide to specific aspects of the Caesium library implementation in different programming languages for development reference purposes. Full documentation will be created soon.

Python

A Python implementation of Caesium is planned.

Node.js

A Node.js implementation of Caesium is planned.

Credits

This project wouldn't have been possible without lots of great open-source technology that people have been kind enough to share with the world. All sources listed here are also credited in code comments.

Libraries

Material Design Lite

getmdl.io

Material Design Icons

material.io/tools/icons

Code Snippets

Smaller functions and pieces of code.

UUID Generation Function

stackoverflow.com/a/105074

var uuids = [];
const UUID = function () {
      // Generate a random string of four hexadecimal digits
      function s4() {
            return Math.floor((1 + Math.random()) * 0x10000)
            .toString(16)
            .substring(1);
      }
      // Generate UUID from substrings
      var id;
      do {
            id = s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
      }
      while (uuids.indexOf(id) !== -1)

      uuids.push(id);
      return id;
}

Range Mapping Function

stackoverflow.com/a/23202637

const map = function (num, in_min, in_max, out_min, out_max) {
      return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Hexadecimal Brightness Function

stackoverflow.com/a/13542669

const shade_color = function (color, percent) {
    var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF;
    return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);
}

Finding maximum value in array by property

stackoverflow.com/a/4020842

var min = Math.min.apply(Math, this.nodes.map(function(x) { return x.value; }));
var max = Math.max.apply(Math, this.nodes.map(function(x) { return x.value; }));

Demos

A series of demos to show just how cool Caesium is and what it is capable of. Feel free to clone any demo and create a new project out of it.

Literally just an HTML page with the Caesium library loaded. Have fun.

image

Visualize all the nodes and connections in a Caesium network.

Approximate a polynomial function using neuroevolution.

image

image

image

Evolve a randomly generated population of neural networks.

image

Learn to classify 2D points based on their X and Y coordinates. WARNING: Flashing colors

Resources

Media and images used in Caesium.

Transparent Textures

transparenttextures.com

Used for backgrounds in the JavaScript/web version of Caesium.

Brushed alum

transparenttextures.com/patterns/brushed-alum.png

By Tim Ward

Used for the network visualization background.

Az Subtle

transparenttextures.com/patterns/az-subtle.png

By Anli.

Used for the control panel/sidebar background.

Logos

GitHub Logo

github.com/logos

Other

Eric Meyer’s “Reset CSS” 2.0

cssreset.com/scripts/eric-meyer-reset-css

Used to reset the default CSS rules to make development a lot easier.

ASCII Text Art Creator

www.network-science.de/ascii

Used to create the ASCII logo art displayed in the console. See issue #20.

caesium's People

Contributors

generic-github-user avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

caesium's Issues

Circles overflow edges of SVG element

The radii of the circles are limited to the inner bounds of the SVG element, but the circles themselves can overflow. Some padding should be added (equivalent to the radius of the circles, or a little bit more).

Define coordinates in percentages

Thankfully (unlike many other things), the SVG specifications allow this, so these do not need to be automatically updated whenever the window is resized.

Add node transitions

Update node display properties when changed

  • Size
  • Color

It doesn't seem that these can be done with plain CSS . . .

Number of update steps between inputs?

Example

Output: "What is your name?"
n update steps
Input: "My name is Phillip."
n update steps
Output: "Hello, Phillip."

More steps allow for more complex internal operations, but increase computation time and may become hard to manage when training.

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.