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 |
---|---|
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 |
---|---|
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 |
---|---|
Contribute
Feel free to fork and submit pull requests.