Linear and nonlinear neural networks for image compression