Skip to content
Trains a Hopfield recurrent neural network to recognize colors and uses it to interpret images.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
input
output
.gitignore
LICENSE.md
README.md
main.js
network.js
package.json
tools.js

README.md

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.

You can’t perform that action at this time.