Neural representations of the external world are built from patterns of sensory input. In the cortex, these representations can be surprisingly dynamic, shifting over time and across learning. We investigated this reorganization using volumetric two-photon imaging of primary somatosensory cortex in mice learning to discriminate simple shapes with their whiskers. I will present how the representations of shape are distributed across cortical layers, how they are assembled from sensory input features, and how training increases the importance of task-relevant sensory features, specifically enhancing discrimination of trained examples. These results suggest mechanisms by which cortical reorganization allows flexible improvement in task performance while maintaining perceptual stability.