You may not believe it, but I am an ANN expert. Perhaps, for that reason, I am unable to grasp completely what the layers are in a Deep Forward Artificial Neural Network (DFANN).
According to the Deep Learning "bible", p. 164 "the model is associated with a" directed acyclic graph (DAG) "describing how the functions are composed together". Then it states that one of these functions $f^{(i)}$ is a layer. We know that an ANN is composed of neurons/units (the biological perspective) and a DAG is composed of nodes/vertices and edges/links. A trivial mapping can be established between (neural) units and nodes, and (neural) connections and edges (see also Fig. 6.2 in p. 170). However, defining the layers in a DAG is not that trivial, I would say.
In a quick internet search, I came across about the concept of graph drawing and layering algorithms. This concept is never mentioned in the ANN literature. If I understood well, formally, we would need such an algorithm to be able to define the layers in the DAG.
A more intuitive description is given by AIMA: DFANN "are usually arranged in layers, such that each unit receives input only from units in the immediately preceding layer". That sounds indeed like a layering algorithm.
So, formally, what are the layers in an Artificial Neural Network?
As a side note, a practical argument is given by https://cs231n.github.io/neural-networks-1/
One of the primary reasons that Neural Networks are organized into layers is that this structure makes it very simple and efficient to evaluate Neural Networks using matrix vector operations.
That's nice, but only from a practical perspective.
An interesting remark has been made by Chillston (see comments, I quote):
That's because an FFN is not a general DAG but a very regular kind of DAG, right.
I also thought that could be the case. But Bishop, 1995, p. 116 contradicts us:
More generally we can consider arbitrary network diagrams (not necessarily having a simple layered structure) since any network diagram can be converted into its corresponding mapping function. The only restriction is that the diagram must be feed-forward, so that it contains no feedback loops.
As I see it, according to Bishop, any (general) DAG is indeed an ANN.