Hopfield network implementation