How to deduce the function of each layer in a neural network without being explicitly told beforehand? In research papers regarding deep learning you commonly get an explanation of how each layer functions.
For example in SRCNN, an image up scaling model (https://arxiv.org/pdf/1501.00092.pdf), the first layer extracts patches, the second layer learns a non-linear mapping from the low resolution patches to high resolution patches, and the 3rd layer reconstructs high resolution patches into a full high resolution image.

My question is how do I deduce what each layer does? I understand the code for models well (I think) and understand what they hyperparameters are for, but I would have no idea how to generate an image like the above for another network architecture.
Is there a procedure I can follow to work these things out? and/or do I just need a better mathematical understanding?
Thanks.
EDIT follow up question referenced in answer:
Is it just that the researchers have a goal in mind for each layer before they start coding? or do you need to find out through experiments (like printing the output of each layer to see what it does exactly)?
 A: I got an answer from my supervisor, so I thought I would post it here since a few people upvoted.

Firstly, always good to be remember that "layer" is a bit or an overload term. For example, there might be many low-level layers in each high-level layer of SRCNN.


At a high level, it appears that SRCNN maps the raw pixel data to an input feature vector, then maps that input feature vector to an output feature vector, and then maps that output feature vector back to an image.


You will see this pattern quite often in machine learning. That is: (1) encode unstructured high-dimensional data as a low-dimensional input feature vector, (2) map the input feature vector to an output feature vector, and then (3) decode/map the low-dimensional output feature vector to the final prediction (e.g. output image).


In practice, this is because the non-linear mapping tools of deep learning work better with low-dimensional feature vectors than they do with high-dimensional inputs (such as raw pixel data), but there is also lots of theory to back up why this is a good thing to do.


With regards to your follow-up question: it's a mix. Some of the ideas for the design of an architecture will come from theory, some from intuition built up from practical experience, and some from experimenting and trying different things.

