TrainHopfield does not calculate weight matrix correctly

Ron's picture

Good Day

I created a Hopfield neural network using org.encog.examples.neural.hopfield.Hopfield to get started. I used a BasicNeuralDataSet consisting of BiPolarNeuralData objects using the following patterns:


final boolean[][] trainingPatterns = {
{ true, true, false, false },
{ true, false, false, false }
};

After a training iteration, the weight matrix is only adjusted for the last pattern in the neural data set.

Stepping through the code I noticed that the method TrainHopfield.convertHopfieldMatrix(final Synapse target, final Matrix delta) does not add to the weight matrix.

I changed Line 86 from this...


target.getMatrix().set(row, col, delta.get(row, col));

To this...


target.getMatrix().set(
row,
col,
delta.get(row, col) + target.getMatrix().get(row, col)
);

...and the weight matrix appears to be correct. I used the Hopfield Applet as reference. Please let me know if I'm missing something or perhaps not using the training class correctly.

jeffheaton's picture

That is an issue with the hopfield train. I am adding it to the list to be fixed with the next Encog update. I will also fix it on the C# side as well, since they seem to share the problem.

Thanks for the report.


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.