Search code examples
javaneural-networkencog

training Hopefield network with encog in java


I started working with this network. And I wrote some code, but I am not sure whether I am doing it right or not. here is what I do:

  • First create the network HopefieldNetwork net = new HopefieldNetwork(50).
  • Than add all patterns, with net.addPattern(aPattern) where aPattern is of type BasicMLData and changes in a loop to add all patterns.
  • Now do net.runUntilStable(5000) for training with 5000 iterations max. Is this right?
  • Now we have the trained network. Get output like out = (BasicMLData) net.compute(input)

So is everything OK?


Solution

  • I found the solution.

    You have to call setCurrentState then runUntilStable then getCurrentState to get output.