Adapting to a constantly changing environment requires the human brain to flexibly switch among many demanding cognitive tasks, processing both specialized and integrated information associated with the activity in functional networks over time. In this study, we investigated the nature of the temporal alternation between segregated and integrated states in the brain during rest and six cognitive tasks using functional MRI. We employed a deep autoencoder to explore the 2D latent space associated with the segregated and integrated states. Our results show that the integrated state occupies less space in the latent space manifold compared to the segregated states. Moreover, the integrated state is characterized by lower entropy of occupancy than the segregated state, suggesting that integration plays a consolidating role, while segregation may serve as cognitive expertness. Comparing rest and the tasks, we found that rest exhibits higher entropy of occupancy, indicating a more random wandering of the mind compared to the expected focus during task performance. Our study demonstrates that both transient, short-lived integrated and segregated states are present during rest and task performance, flexibly switching between them, with integration serving as information compression and segregation related to information specialization.