Skip to content

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

License

Notifications You must be signed in to change notification settings

shernshiou/hopfield-color-recognition

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Output
Input linear spectrum Output linear spectrum
Input Output
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 Output
Input linear spectrum Output linear spectrum
Input Output
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 Output
Input linear spectrum Output linear spectrum
Input Output
Input nature image Output nature image

Contribute

Feel free to fork and submit pull requests.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%