Sensory cortical representations can be highly dynamic, raising the question of how representational stability impacts learning. We train mice to discriminate the number of photostimulation pulses delivered to opsin-expressing pyramidal neurons in layer 2/3 of primary vibrissal somatosensory cortex. We simultaneously track evoked neural activity across learning using volumetric two-photon calcium imaging. In well-trained animals, trial-to-trial fluctuations in the amount of photostimulus-evoked activity predicted animal choice. Population activity levels declined rapidly across training, with the most active neurons showing the largest declines in responsiveness. Mice learned at varied rates, with some failing to learn the task in the time provided. The photoresponsive population showed greater instability both within and across behavioral sessions among animals that failed to learn. Animals that failed to learn also exhibited a faster deterioration in stimulus decoding. Thus, greater stability in the stimulus response is associated with learning in a sensory cortical microstimulation task.