Layerwise inference