Learning patterns with neural networks