SummaryLearning to avoid dangerous signals while preserving normal behavioral responses to safe stimuli is essential for everyday behavior and survival. Like other forms of learning, fear learning has a high level of inter-subject variability. Following an identical fear conditioning protocol, different subjects exhibit a range of fear specificity. Under high specificity, subjects specialize fear to only the paired (dangerous) stimulus, whereas under low specificity, subjects generalize fear to other (safe) sensory stimuli. Pathological fear generalization underlies emotional disorders, such as post-traumatic stress disorder. Despite decades of work, the neuronal basis that determines fear specificity level remains unknown. We identified the neuronal code that underlies variability in fear specificity. We performed longitudinal imaging of activity of neuronal ensembles in the auditory cortex of mice prior to and after the mice were subjected to differential fear conditioning. The neuronal code in the auditory cortex prior to learning predicted the level of specificity following fear learning across subjects. After fear learning, population neuronal responses were reorganized: the responses to the safe stimulus decreased, whereas the responses to the dangerous stimulus remained the same, rather than decreasing as in pseudo-conditioned subjects. The magnitude of these changes, however, did not correlate with learning specificity, suggesting that they did not reflect the fear memory. Together, our results identify a new, temporally restricted, function for cortical activity in associative learning. These results reconcile seemingly conflicting previous findings and provide for a neuronal code for determining individual patterns in learning.