Neural Network Architecture and Weights Explained With XOR
A neural network's architecture is its overall structure, meaning how many units it has and how those units connect to each other. The weights are different. They are the numbers that training chooses for a given architecture, so the architecture is the wiring diagram and the weights are the settings on the dials. Goodfellow, Bengio, and Courville define it this way in Section 6.4 of their Deep Learning book: "the overall structure of the network: how many units it should have and how these units should be connected to each other."
Most networks are organized in layers arranged in a chain, each layer a function of the one before it. The first is h⁽¹⁾ = g⁽¹⁾(W⁽¹⁾ᵀx + b⁽¹⁾), the second is h⁽²⁾ = g⁽²⁾(W⁽²⁾ᵀh⁽¹⁾ + b⁽²⁾), and so on. In those chain-based designs, the book says, the main architectural choices are the depth of the network and the width of each layer.
Try it by hand. The book's XOR network (Section 6.1) has two inputs, one hidden layer of two ReLU units, and one output: f(x; W, c, w, b) = wᵀ max{0, Wᵀx + c} + b. Count the parameters: W has 4 entries, c has 2, w has 2, and b has 1, so 9 in all. Those numbers are not part of the architecture. They are a choice. Take W = [[1, 1], [1, 1]], c = (0, −1), w = (1, −2), b = 0, the authors' solution. For the input (1, 1), the hidden pre-activations are (2, 2) + (0, −1) = (2, 1), ReLU leaves (2, 1), and the output is 1 × 2 − 2 × 1 = 0. The four inputs (0,0), (0,1), (1,0), (1,1) give 0, 1, 1, 0, which is XOR. Now keep every wire and every unit, and change only w to (1, 0). The hidden values are the same, but the output becomes the first hidden unit alone: 0, 1, 1, 2, which is x₁ + x₂. Same architecture, different function.
The distinction matters in practice. When someone says two models "have the same architecture", they mean the same layer sizes and connections, not the same behavior. The book also notes that the ideal architecture for a task must be found by experimentation guided by the validation set error, since deeper networks can need far fewer units per layer but tend to be harder to optimize.
The trap: treating an architecture and a set of trained weights as interchangeable descriptions. Rerun training with a different seed and you get the same architecture and different weights. Load another model's weights into a mismatched architecture and the shapes will not even fit.
Prof Rod's rule: say both when you describe a model: the architecture, then the weights it was trained into.
The weights used here are the book's published XOR solution, and the second weight vector is mine.