Skip to content

utilitarianexe/brains

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

Neural network simulation software.

Biased towards being more like a squishy brain and less like a traditional AI.

General concept

Running the program runs a "world". A world consists of a brain/model and an environment.

A brain consists of a network, a set of parameters, and choice of a model of a neuron to simulate.

An environment provides inputs to the brain and receives outputs.

Install

Install python 3 and on a unix terminal or anaconda terminal on windows

git clone https://github.com/utilitarianexe/brains.git

cd brains/

pip install virtualenv

virtualenv venv

on unix source venv/bin/activate on windows C:\Users\'Username'\'path to repository'\venv\Scripts\activate

pip install -r requirements.txt

Optionally use rust acceleration if you have cargo installed

chmod a+x build_and_run.sh

./build_and_run.sh

Note this is a python 3 app with rust acceleration. You will need at least python 3. You can run the program without rust but it will be slower.

Run

Runs in two display modes or with no display

Basic learning using STDP

python brains/main.py --epochs=5000 --world=easy --export_name=easy_network --display=""

Runs a simple brain for 2000000 steps(400 per epoch). Input from three neurons. One that fires randomly and a pair where at least one fires but which one is random. There are two output cells. If the same output cell fires as the input cell in the same row the network is rewarded and a win is recorded. The network starts out unbiased but will learn to fire the right output for the input.

pygame

Watch network run in real time by importing the brain you just trained.

python brains/main.py --environment=easy --import_name=easy_network --display=pygame

Or watch a more complex network and environment.

python brains/main.py --display pygame --world handwriting

Current input data for this mode is a small subset of https://www.kaggle.com/sachinpatel21/az-handwritten-alphabets-in-csv-format

Pressing space will cycle the modes (cells, weights, and none).

Clicking a cell will select it to

None will allow the program to run much faster.

I needed MESA_LOADER_DRIVER_OVERRIDE=i965 to make pygame work on Ubuntu

pyplot

Display potential graphs for each cell using pyplot

python brains/main.py --display pyplot --world stdp --epochs 5

Options

You can export models to preserve changes to the network during a run using the export_name option. You can then import the model using the import_name option. You will also need the environment option, as this is not stored as part of the model. world is a combination of environment and model.

Rust commands

Using rust will massivly speed up the code.

cd iron_brains cargo build --release cp target/release/libiron_brains.so ../brains/iron_brains.so

Future

The code is much more flexible than these options suggest.

Much more to come :-)

Development

Run tests from root directory with

pytest

About

Experiments with artificial neurons

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published