Multilayer artificial neural network that classifies patterns with shift-invariance and models context at each layer of the network