How the brain decides what to learn