Obtaining intermediate layers from a model