Learning, Diversity and Adaptation in Changing Environments: The Role of Weak Links