Hardware supervised learning for cellular and Hopfield neural networks