A neural network architecture diagram shows the layers of a model in order and the shape of the tensor flowing between them. This sample is a small convolutional network that classifies 28x28 handwritten digits (MNIST): two convolution and pooling stages extract features, then a dense head picks one of ten classes. These are deep-learning layer diagrams, not UML; UML covers software structure and behaviour, and layer diagrams are the standard notation used alongside it for model internals.
1. The Diagram
Box height is drawn roughly in proportion to the size of each layer's output, so you can see the spatial maps shrink while the channel count grows.
Input: one grayscale channel, 28x28 pixels, so the tensor is 1x28x28 (PyTorch's channels-first order).
Conv1: 32 filters of 3x3 with padding 1 keep the 28x28 size and produce 32 feature maps. Parameters: 3*3*1*32 weights + 32 biases = 320.
Pool1: 2x2 max pooling halves height and width to 14x14 and has no parameters.
Conv2: 64 filters of 3x3 over 32 input channels: 3*3*32*64 + 64 = 18,496 parameters.
Pool2 shrinks to 64x7x7, and Flatten turns it into a vector of 3,136 numbers.
Dense: 3,136*128 + 128 = 401,536 parameters, by far the largest layer, followed by dropout to fight overfitting.
Output: 10 units, one per digit; softmax turns the scores into probabilities.
2. How to Read It
Read left to right as the forward pass. Shapes under each box are the layer's output; checking that each shape follows from the previous one is the fastest way to catch a wrong padding or stride before running any code.
3. Variant: Neuron Graph
The classic neuron-and-edge drawing shows a plain multilayer perceptron, where every unit connects to every unit in the next layer. It explains what "fully connected" means, but it cannot show 784 inputs, so ellipses stand in for the missing nodes. For anything bigger than a toy network, prefer the layer-box style above.
4. Pros, Cons, and When to Use
Pros
Tensor shapes make shape bugs visible before training.
Parameter counts show where memory and compute go.
Matches how frameworks print model summaries.
Scales to deep networks by grouping repeated blocks.
Familiar to anyone who reads ML papers.
Cons
No standard notation; every paper draws it differently.
Skip connections and branches get messy in a single row.
Hides training details: loss, optimizer, data augmentation.
Proportional box sizes are approximate.
When to use
Model design reviews and papers.
Explaining a model to a new team member.
Debugging shape mismatches.
When not to use
Describing the serving system around the model.
Very large models, where a block diagram is clearer.
5. As Diagrams-as-Code
The layer chain in Graphviz DOT (record nodes carry the shapes):