As your baby's nervous system develops, and especially once his sense of hearing evolves, he has the opportunity to learn and remember from experience. How this process develops is not fully understood, but experts believe that the first signs of learning coincide with the unborn baby's ability to hear, at around this mid-stage of pregnancy.
In later months, more sound will reach your baby as the walls of the uterus become thinner. Although babies have been seen to be startled by a noise at this stage, they seem to learn not to react to the sound if it is repeated again and again, gradually adapting to it as it's repeated over time, and eventually ignoring it.
This simple test demonstrates that a fetus can adapt to a repeated stimulus. If, however, the sound pattern is not repeated for some time, your baby will have forgotten it and become startled by it if it occurs again.
Retaining a memory for events is a much more complex function and relies on pathways in the gray matter of the brain. It will be weeks before learning and memory are linked in the last stages of your pregnancy.