• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Trains a Hopfield recurrent neural network to recognize colors and uses it to interpret images.

Hopfield color recognition

Trains a Hopfield recurrent neural network to recognize colors after which it interprets all PNG images in the input folder and saves the results to the output folder.

Usage

Clone this repository and make sure the output folder exists before running

$ npm install
$ node main.js

Edit the beginning of main.js if you want to use different colors.

The transparency of each pixel is based on the uncertainty of the neural network's response to its color.

Observations

  • When trained to recognize red, green, blue and black (#ff0000, #00ff00, #0000ff and #000000 respectively), the inverses cyan, yellow and magenta (#00ffff, #ff00ff and #ffff00 respectively) emerge as solid states as noted in the 'Spurious patterns' section of the Wikipedia article.
  • Applying a network trained to recognize black and white (#000000 and #ffffff respectively) on a circular color spectrum produces fractal-like patterns.

Examples

Below are a few examples of Hopfield networks trained to remember different combinations of colors. Think of the output as a reflection of what the network "sees" when interpreting the input.

Black and white

The following images are inputs and outputs of a network which recognizes black and white (#000000 and #ffffff respectively) colors.

Input Output
Input circular spectrum Output circular spectrum
Input linear spectrum Output linear spectrum
Input canonical spectrum Output canonical spectrum
Input nature image Output nature image

Green and black

The following images are inputs and outputs of a network which recognizes green and black (#ff0000 and #000000 respectively) colors.

Input Output
Input circular spectrum Output circular spectrum
Input linear spectrum Output linear spectrum
Input canonical spectrum Output canonical spectrum
Input nature image Output nature image

Red, green, blue and black

The following images are inputs and outputs of a network which recognizes red, green, blue and black (#ff0000, #00ff00, #0000ff and #000000 respectively) colors.

Input Output
Input circular spectrum Output circular spectrum
Input linear spectrum Output linear spectrum
Input canonical spectrum Output canonical spectrum
Input nature image Output nature image

Contribute

Feel free to fork and submit pull requests.