// Hopfield.cpp
// (Discrete (Binary)) Hopfield Artificial Neural Network (ANN)
// For more info see:
// http://en.wikipedia.org/wiki/Hopfield_net
// http://www.scholarpedia.org/article/Hopfield_network
// Compiler used: Dev-C++ 4.9.9.2
// FB - 201011136
#include
#include // getch()
using namespace std;
int main (int argc, char *argv[])
{
cout<<"Hopfield Artificial Neural Network (ANN):"<(0.138f*n); // number of patterns (rows)
int* pattern=new int[m*n];
for(j=0;j w=0)
int* w=new int[n*n];
for(j=0;j=0)
neuron[j]=1;
else
neuron[j]=0;
}
/*
// Second Choice for updating the network:
// Parallel updating:
// Update all neurons simultaneously
int* neuron_temp=new int[n];
// calculate the new values of each neuron
// but do not update immediately!
for(j=0;j=0)
neuron_temp[j]=1;
else
neuron_temp[j]=0;
}
// update the neurons with the new values
neuron=neuron_temp; // update the array pointer
delete []neuron; // delete the old values
*/
// if state of the network unchanged
// then increase the unchanged counter
// else reset it
bool changed=false;
for(k=0;k=100)
{
cout<<"Converged network state:"<