Neural network building blocks
standardintermediateA neuron computes a weighted sum of its inputs, then applies a nonlinear activation function to the result. A layer is a group of neurons applied in parallel. A neural network is layers stacked in sequence. A computational graph is the record of every operation performed, which is what makes automatic differentiation (and therefore training) possible.
Think of it as
Stack these ideas from smallest to largest. A single neuron is a linear operation (a weighted sum plus a bias) followed by a nonlinearity — without that nonlinearity, stacking any number of neurons would still only ever compute a linear function, no more powerful than plain linear regression. A layer runs many neurons on the same input in parallel, each with its own learned weights, so the layer as a whole can learn many different features of the input at once. A network stacks layers sequentially, so later layers combine the features earlier layers extracted — this is what lets a deep network build up from simple patterns (edges, in an image) to complex ones (faces) across its depth. A computational graph is the bookkeeping structure a framework like PyTorch builds automatically as these operations run: every operation is recorded as a node, with edges to whatever it depended on, and that recorded graph is exactly what backpropagation (§9.2) walks backward over to compute every gradient via the chain rule.
- A diagram of a 4-layer neural network: an input layer of 4 nodes, two hidden layers of 5 nodes each, and an output layer of 3 nodes.
- Every node in each layer is connected by a line to every node in the next layer — a real, fully drawn set of 60 connections.
- An arrow beneath the input layer labeled "forward pass" shows the direction data flows through the network.
Remember: A neuron is a weighted sum plus a nonlinearity; without the nonlinearity, stacking layers would still be linear. A layer runs many neurons in parallel; a network stacks layers so later ones combine earlier features. A computational graph records every operation, which backpropagation walks backward over.
See also: forward pass and backpropagation · activation functions







