Training Neural Networks as Recognizers of Formal Languages