offState = -1.0;
threshold = 0;
nInputs = 100;
inputWidth = sqrt(nInputs);
noiseLevel = 0.1;

%%% initialize the weights so that each unit is connected to its 4 
%%% nearest neighbors.
weights = init2Dweights(inputWidth);

%%% variables for plotting the input vector 
%%% as an inputWidth * inputWidth grid
colormap(cool)
%% need to pad with an extra row and col of zeros 
%% because pcolor doesn't plot the last row and col
activationGrid = zeros(inputWidth+1);


%% initialize activations vector. We actually want to view this vector
%% as a 2D image, and think of the network as de-noising the image.
activations = ones(nInputs,1) * (-1);
for col = 3:(inputWidth-2),
  for row = 3:(inputWidth-2),
     activations((col - 1)*inputWidth + row) = 1;
  end;
end
for i = 1:nInputs,
  if rand(1,1) < noiseLevel
     activations(i,1) = activations(i,1) * (-1);
  end
end

plotHopActivations;

fprintf(1,'To run this demo, repeatedly type the following from the command line:\n');
fprintf(1, '   forwardHopfield\n');
