Elastic matching and pattern recognition in neural networks.