Shannon entropy is one of the fundamental concepts of information theory and allows us to quantify the uncertainty of a random variable. A strongly related quantity is called mutual information (MI), which is a measure of the shared information between two random variables, or equivalently, the decrease in uncertainty/entropy of one random variable based on the knowledge of another. We use machine learning techniques to calculate the rate of flow of information between the different layers of the atmosphere, both in the quiet Sun and during solar flares. The analysis is performed on several IRIS spectral lines that have different formation heights. We find that the MI is maximized over the flare ribbons and at the peak of the GOES X-ray flux, indicating a positive relationship between MI and energy deposition.