An artificial neuron computes $a = g(\mathbf{w}^{\mathsf{T}}\mathbf{x} + b)$. Whatever its activation $g$, it is a linear classifier with the hyperplane $\mathbf{w}^{\mathsf{T}}\mathbf{x} + b = 0$ as its boundary, and with a sigmoid $g$ and maximum likelihood weights it is exactly logistic regression. On two standardized measurements of the 569 Wisconsin breast tumors, mean radius and mean texture, the fitted neuron has weights 3.7220 and 0.9374 and bias −0.7076, and classifies 507 tumors correctly (89.1%, a training accuracy). Networks stack such units in layers, and a dense layer has $(n_{\text{in}} + 1)\,n_{\text{out}}$ parameters. Without a nonlinear activation, any number of layers collapses into one linear layer. Two hidden threshold units compute XOR, which no single neuron, and no layered network with one hidden unit, can.
A pathologist has measured the cell nuclei in a fine-needle aspirate of a breast mass. Two of the measurements are the mean radius of the nuclei and their mean texture, the standard deviation of the gray levels inside them. For the first tumor in the Wisconsin diagnostic data (Wolberg, Mangasarian, Street and Street, 1993), these are 17.99 and 10.38. Expressed in standard deviations from the mean of all 569 tumors, they are $x_1 = 1.0971$ and $x_2 = -2.0733$: a large radius and an unusually smooth texture.
A simple rule for judging the tumor multiplies each measurement by a weight, adds the products and a constant, and passes the total through a function that turns it into a number between 0 and 1:
$$z = 3.7220 \times 1.0971 + 0.9374 \times (-2.0733) - 0.7076 = 1.4321, \qquad p = \frac{1}{1 + e^{-z}} = 0.8072.$$
The weights favor malignancy for a large radius and, more weakly, for a coarse texture. This tumor's large radius outweighs its smooth texture, and the rule assigns it a probability of malignancy of 0.81. It was malignant. The first benign tumor in the file (tumor 19, radius 13.54 and texture 14.36) gets $z = -2.4038$ and $p = 0.0829$.
That computation, a weighted sum of inputs followed by a fixed nonlinear function, is an artificial neuron, the unit from which every neural network is built. It is also exactly logistic regression: the weights above are the maximum likelihood coefficients of a logistic regression of diagnosis on the two standardized measurements. A neural network is what results when many such units are connected, the outputs of some becoming the inputs of others, and all their weights are fitted together. This article describes the neuron, where the idea came from, and how networks are put together. The rest of the topic covers the single-layer perceptron and its learning rule, the nonlinear activation functions that make layers useful, and the multilayer perceptron and how it is trained.
What a neuron computes
An artificial neuron receives $n$ inputs $x_1, \ldots, x_n$. It holds one weight $w_j$ for each input and a bias $b$, and computes
$$z = w_1 x_1 + w_2 x_2 + \cdots + w_n x_n + b = \mathbf{w}^{\mathsf{T}} \mathbf{x} + b, \qquad a = g(z).$$
The weighted sum $z$ is the neuron's pre-activation, $g$ is its activation function, chosen in advance and not learned, and $a$ is its output, or activation. A positive weight means a larger input pushes the output up, a negative weight that it pushes the output down, and a weight near zero that the input hardly matters. The bias sets how large the weighted sum must be before the output turns on; it plays the role of the intercept in a regression, and machine learning texts call intercepts biases (James, Witten, Hastie and Tibshirani, 2021, §10.2, who note that this "bias" has nothing to do with the bias of the bias-variance tradeoff). A common device treats the bias as the weight on an extra input that always equals 1, so that $z = \tilde{\mathbf{w}}^{\mathsf{T}} \tilde{\mathbf{x}}$ with $\tilde{\mathbf{x}} = (x_1, \ldots, x_n, 1)$.
Two activation functions recur throughout this topic. The step function outputs 1 when $z \geq 0$ and 0 otherwise, so the neuron makes a yes-or-no decision. The sigmoid (or logistic function) $\sigma(z) = 1/(1 + e^{-z})$ rises smoothly from 0 to 1, passing through 0.5 at $z = 0$, so the neuron reports a graded value that can be read as a probability. With the weights above, the two choices make the same decisions, since $\sigma(z) \geq 0.5$ exactly when $z \geq 0$: both call 507 of the 569 tumors correctly (89.1%). They differ in what else they say. The step neuron cannot distinguish a tumor that barely crosses the line from one far beyond it, and, more important for training, its output does not change at all when a weight changes by a small amount, so it gives no signal about which way to adjust the weights. The article on activation functions covers these and the others in use.
Whatever the activation, the boundary between the two decisions is where $z = 0$, the set of inputs with $\mathbf{w}^{\mathsf{T}}\mathbf{x} + b = 0$. With two inputs it is a straight line, with three a plane and in general a hyperplane. A single neuron is therefore a linear classifier, like logistic regression and the support vector classifier: it can only separate classes that a hyperplane can separate.
The biological analogy
The name comes from a loose analogy with nerve cells. A biological neuron receives signals from other neurons at junctions called synapses, mostly on its branched dendrites and its cell body; the signals combine, and if the combined excitation at a given moment exceeds a threshold the neuron fires an impulse along its axon to the synapses of the next neurons. Some synapses excite and others inhibit. In the artificial neuron, the inputs stand for incoming signals, the weights for the strength and sign of each synapse, the weighted sum for the combined excitation, and the step function for the threshold. Hastie, Tibshirani and Friedman (2009, §11.3) give the same mapping: units were neurons, connections were synapses, and in early models a neuron fired when the total signal passed to it exceeded a threshold, which corresponds to a step activation.
The analogy explains the vocabulary, not how the methods work. Real neurons signal with timed electrical pulses, and their synapses change through chemical processes over many time scales; an artificial neuron is a fixed formula with real-valued inputs and outputs. The networks used in data science are better understood as what Hastie et al. (2009, §11.3) call them, nonlinear statistical models: functions with many adjustable coefficients, fitted to data by minimizing a loss. The smooth sigmoid replaced the step function precisely because the step function "is not smooth enough for optimization" (Hastie et al., 2009, §11.3), a statistical reason, not a biological one.
A short history
McCulloch and Pitts (1943). The first artificial neurons were logical devices. Warren McCulloch, a neurophysiologist, and Walter Pitts, a logician, argued that "because of the 'all-or-none' character of nervous activity, neural events and the relations among them can be treated by means of propositional logic" (McCulloch and Pitts, 1943, abstract). Their idealized neuron fired if a fixed number of its excitatory synapses were active at once, and any active inhibitory synapse prevented it from firing at all; the structure of the net did not change with time (assumptions 1 to 5 of their Section 2). They showed that the behavior of every net without loops can be written as an expression of propositional logic, and that every such expression satisfying certain conditions is realized by some net. They added, at the end of their Section 3, that a net supplied with a tape and scanners, as a Turing machine is, can compute exactly the numbers a Turing machine can. Their units had thresholds but no learning: the connections were designed, not fitted.
Rosenblatt (1958). Frank Rosenblatt's perceptron added learning. His paper describes a system of sensory points (a retina), association units, each receiving connections from a number of sensory points, and response units fed by the association units; an association unit fires when the algebraic sum of its excitatory and inhibitory inputs reaches its threshold, and learning changes the influence each association unit has on the responses, so that a stimulus comes to evoke the response it has been reinforced for (Rosenblatt, 1958). In the simplified form used today, a perceptron is a single neuron with a step activation, and the perceptron learning rule adjusts its weights after each mistake. When the two classes can be separated by a hyperplane the rule is guaranteed to find one in a finite number of steps; the next article proves this.
Minsky and Papert (1969). A single neuron can only draw one hyperplane, and some simple functions need more. The standard example is exclusive or (XOR) of two binary inputs, which is 1 when exactly one input is 1: no line separates its two 1s from its two 0s. Marvin Minsky and Seymour Papert's book Perceptrons (1969) analyzed what single-layer perceptrons can and cannot compute. Goodfellow, Bengio and Courville (2016, §1.2.1) describe the criticism of these flaws of linear models, XOR the best known, as causing "a backlash against biologically inspired learning in general," the first major dip in the popularity of neural networks. A network with a hidden layer can compute XOR easily, as shown below; what was missing was a way to train the hidden layer.
Backpropagation (1970s and 1986). That method is to compute the gradient of the error with respect to every weight by the chain rule, working backward from the output, and to adjust all weights by gradient descent. Hastie et al. (2009, bibliographic notes to Ch. 11) credit it to Werbos (1974), Parker (1985) and Rumelhart, Hinton and Williams (1986), and attribute the resurgence of neural networks in the mid-1980s to their work. Rumelhart, Hinton and Williams showed that the hidden units of networks trained this way "come to represent important features of the task domain", and they contrasted this with "earlier, simpler methods such as the perceptron-convergence procedure" (1986, abstract). The multilayer perceptron article derives the method.
Decline and revival. James et al. (2021, Ch. 10) describe what followed. Neural networks rose to fame in the late 1980s and were then analyzed by machine learners, mathematicians and statisticians. Support vector machines, boosting and random forests followed; they needed less tinkering, and on many problems they outperformed poorly trained networks, so networks fell somewhat from favor in the first decade of the new century. A core group of researchers kept going, and after 2010 neural networks returned under the name deep learning, with new architectures and successes in image and video classification, speech and text, which many in the field attribute chiefly to ever larger training sets. One change in the networks themselves was the switch from sigmoid to rectified linear activations, $g(z) = \max(0, z)$. Nair and Hinton (2010) used them in place of binary units in restricted Boltzmann machines, and Glorot, Bordes and Bengio (2011) found that deep networks of rectifiers, trained by supervised learning alone, did as well as or better than networks of hyperbolic tangent units. The activation functions article measures why such units train more easily. The Language Models from Scratch collection builds a modern deep network, a small GPT, step by step.
From neurons to networks
A feed-forward neural network arranges neurons in layers. The input layer holds the feature values; it computes nothing. Each hidden layer is a set of neurons that all receive the outputs of the layer before; each neuron has its own weights and bias, and all apply the same activation function. The output layer produces the prediction. Connections run only forward, from each layer to the next, with no loops; networks with loops, which carry a state from one item of a sequence to the next, are recurrent networks and are not covered here. When every unit of a layer receives every output of the previous layer, the layer is fully connected (or dense).
With one hidden layer of $K$ units and an input vector $\mathbf{x}$ of length $p$, hidden unit $k$ computes $a_k = g(\mathbf{w}_k^{\mathsf{T}} \mathbf{x} + b_k)$, and output $m$ computes $z_m = \boldsymbol{\beta}_m^{\mathsf{T}} \mathbf{a} + \beta_{m0}$. James et al. (2021, §10.1) describe the hidden layer as deriving $K$ new features, each a nonlinear transformation of a different linear combination of the inputs, and the output layer as a linear model in those derived features. Hastie et al. (2009, §11.3) make the same point: the network is a linear model, or a multinomial logistic model, applied to a basis expansion of the inputs, with the difference from fixed basis expansions that "the parameters of the basis functions are learned from the data."
The output layer depends on the task. For a numerical outcome it is a single unit with no activation, $f(\mathbf{x}) = z$. For a yes-or-no outcome it is one unit with a sigmoid, giving a probability. For $K$ classes it is $K$ units followed by a softmax, $p_m = e^{z_m} / \sum_{l} e^{z_l}$, which turns $K$ numbers into $K$ positive probabilities that sum to one (James et al., 2021, eq. 10.13). With a softmax output and the cross-entropy loss, the network is, in Hastie et al.'s words, "exactly a linear logistic regression model in the hidden units" (2009, §11.4). The Statistics collection's Multinomial and Softmax Regression proves the properties of that output model: its gradient, its concavity in the output weights, and when its estimate exists.
Stacking layers is a matter of feeding each layer's activations to the next. For a whole dataset at once, with the $n$ examples as the rows of a matrix $X$, one hidden layer computes
$$A^{(1)} = g\big(X W^{(1)} + \mathbf{1}\mathbf{b}^{(1)\mathsf{T}}\big),$$
where $W^{(1)}$ is a $p \times K$ matrix whose column $k$ holds the weights of hidden unit $k$, and $g$ is applied to every entry. The next layer applies the same pattern to $A^{(1)}$. Every unit in a deeper layer is still a function of the original inputs, through the chain of layers before it (James et al., 2021, §10.2).
Counting parameters
A dense layer from $n_{\text{in}}$ units to $n_{\text{out}}$ units has $n_{\text{in}} \times n_{\text{out}}$ weights and $n_{\text{out}}$ biases, $(n_{\text{in}} + 1)\, n_{\text{out}}$ parameters in all. The network used later in this topic for the wine data, with 13 inputs, 16 hidden units and 3 outputs, has $14 \times 16 = 224$ parameters in its first layer and $17 \times 3 = 51$ in its second, 275 in all. The network James et al. (2021, §10.2) fit to the MNIST handwritten digits, with 784 pixel inputs, hidden layers of 256 and 128 units and 10 outputs, has $785 \times 256 + 257 \times 128 + 129 \times 10 = 235{,}146$ parameters, more than 33 times the $785 \times 9 = 7{,}065$ of a multinomial logistic regression on the same pixels (nine sets of coefficients, with one class as the reference). Parameter counts grow with the product of adjacent layer widths, which is one reason networks need a great deal of data or explicit regularization.
Descriptions of architecture count differently from source to source. Some count layers of units (input, hidden, output), others layers of weights; some describe a network by its hidden layer sizes alone, as scikit-learn's hidden_layer_sizes=(16,) does. Input "units" only hold values, so they are not neurons in the computing sense; hidden and output units both are. Stating the sizes of every layer, as in 13-16-3, avoids the ambiguity.
Why the hidden layers need a nonlinearity
If the activation function were the identity, $g(z) = z$, a hidden layer would add nothing. Two linear layers compute
$$(X W^{(1)} + \mathbf{1}\mathbf{b}^{(1)\mathsf{T}})\, W^{(2)} + \mathbf{1}\mathbf{b}^{(2)\mathsf{T}} = X\,(W^{(1)} W^{(2)}) + \mathbf{1}\,(W^{(2)\mathsf{T}}\mathbf{b}^{(1)} + \mathbf{b}^{(2)})^{\mathsf{T}},$$
a single linear layer with weight matrix $W^{(1)}W^{(2)}$. Any number of linear layers collapses the same way. For a random 3-4-2 network the two computations agree to within $9 \times 10^{-16}$, rounding error. A network without nonlinear activations is therefore a linear model however deep it is; James et al. (2021, §10.1) call the nonlinearity "essential" for this reason, and show that with it, two hidden units can produce an interaction: with $g(z) = z^2$, $\tfrac14 (x_1 + x_2)^2 - \tfrac14 (x_1 - x_2)^2 = x_1 x_2$.
XOR with three threshold units
A network with one hidden layer of two step-function units computes XOR. Let
$$h_1 = \operatorname{step}(x_1 - x_2 - 0.5), \qquad h_2 = \operatorname{step}(x_2 - x_1 - 0.5), \qquad \text{output} = \operatorname{step}(h_1 + h_2 - 0.5).$$
Unit $h_1$ is on only when $x_1 = 1$ and $x_2 = 0$ ("$x_1$ and not $x_2$"), unit $h_2$ only when $x_2 = 1$ and $x_1 = 0$, and the output unit is on when either hidden unit is (an OR):
| $x_1$ | $x_2$ | $h_1$ | $h_2$ | output | XOR |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
Each hidden unit draws one line, and the output combines the two half-planes. This is the general picture of what hidden layers do: each unit contributes a simple boundary or feature, and later layers combine them into shapes no single unit could make. The construction here was done by hand, in the spirit of McCulloch and Pitts. Finding such weights from data is the subject of the rest of the topic; the Academics section's Evolving Neural Network Weights finds XOR weights for a sigmoid network by a genetic algorithm instead of by gradients, and NEAT evolves the hidden structure as well.
Training in outline
A network's weights are chosen to make a loss small on the training data: the mean squared error for numerical outcomes, or the cross-entropy (log loss) for classes, the same criterion that logistic regression maximizes as a likelihood and that Loss Functions for Classification examines. There is no closed-form solution, and unlike logistic regression the loss of a network with hidden layers is not convex: it can have many local minima, and which one training reaches depends on the starting weights (Hastie et al., 2009, §11.5.5). Networks are fitted by gradient descent: start from small random weights, compute the gradient of the loss with respect to every weight, move every weight a small step against its gradient, and repeat. Backpropagation is the bookkeeping that computes all those gradients in one backward pass through the network. Because a network can have far more parameters than there are training examples, it is usually stopped early or penalized to keep it from fitting noise, which links neural networks to the bias-variance tradeoff and to the use of validation data. The multilayer perceptron article works all of this through and trains a network written from scratch.
Worked problems
The course notes behind this unit hold no assignments, so the problems below extend the article on its own running data. The script checks every number.
Problem 1 (the neuron's contours in the original units). The figure of the 569 tumors gives the decision boundary as radius = 18.78 − 0.206 × texture and draws the contours where the output is 0.1 and 0.9. Derive these lines from the fitted weights, and find how many tumors fall between the 0.1 and 0.9 contours.
Solution. The neuron works on standardized inputs, $x_1 = (r - m_r)/s_r$ and $x_2 = (t - m_t)/s_t$, where $r$ and $t$ are the mean radius and texture, and the means and standard deviations over the 569 tumors are $m_r = 14.1273$, $s_r = 3.5210$, $m_t = 19.2896$ and $s_t = 4.2973$. The output equals $p$ where $z = \ln\big(p/(1 - p)\big)$, so the contour at output $p$ is the line $z = z_0$ with $z_0 = \ln(p/(1-p))$: $z_0 = 0$ for $p = 0.5$ and $z_0 = \pm\ln 9 = \pm 2.1972$ for $p = 0.9$ and $0.1$. Substituting the standardized inputs into $w_1 x_1 + w_2 x_2 + b = z_0$ and solving for $r$,
$$r = m_r - \frac{s_r}{w_1}\Big(b - z_0 - \frac{w_2 m_t}{s_t}\Big) - \frac{s_r w_2}{s_t w_1}\, t.$$
The slope, $-s_r w_2/(s_t w_1) = -(3.5210 \times 0.9374)/(4.2973 \times 3.7220) = -0.2064$, does not depend on $z_0$, so every contour is parallel to the boundary, as the figure shows. The intercepts are 18.7772 for $p = 0.5$, 20.8557 for $p = 0.9$ and 16.6987 for $p = 0.1$. Along the radius axis the contours for 0.5 and 0.9 are $s_r \ln 9 / w_1 = 2.0785$ apart, a little more than half a standard deviation of radius: the neuron moves from undecided to confident over a short distance, because its weight on radius is large. Of the 569 tumors, 203 lie strictly between the 0.1 and 0.9 contours, and the neuron classifies 149 of them correctly (73.4%); of the 366 outside that band it classifies 358 correctly (97.8%). Its 62 errors are concentrated where its probabilities say it is unsure.
Problem 2 (one hidden unit cannot compute XOR). The XOR network above has two hidden units. Show that no layered network with a single hidden unit, in which the output depends on the inputs only through that unit, can compute XOR, whatever nondecreasing activation the hidden unit uses (step, sigmoid, ReLU and tanh all qualify) and whether the output is linear or a threshold; then give an exact two-unit network with ReLU units and a linear output.
Solution. With one hidden unit the network computes $h = g(u)$ with $u = w_1 x_1 + w_2 x_2 + b$, and then an output $\phi(h)$, where $\phi$ is monotone: a linear output $ch + d$ is increasing or decreasing (or constant), and a threshold of it is nondecreasing or nonincreasing. Write $u_{00}, u_{01}, u_{10}, u_{11}$ for the hidden unit's weighted sums at the four inputs. They satisfy
$$u_{00} + u_{11} = b + (w_1 + w_2 + b) = (w_2 + b) + (w_1 + b) = u_{01} + u_{10}.$$
Suppose the network computed XOR, so $\phi(h)$ is 1 at $(0, 1)$ and $(1, 0)$ and 0 at $(0, 0)$ and $(1, 1)$. If $\phi$ is nondecreasing, a larger output needs a strictly larger $h$, so each of $h_{01}, h_{10}$ exceeds each of $h_{00}, h_{11}$. A nondecreasing $g$ gives a strictly larger value only at a strictly larger argument, so $u_{00} < u_{01}$ and $u_{11} < u_{10}$; adding, $u_{00} + u_{11} < u_{01} + u_{10}$, which contradicts the identity. If $\phi$ is nonincreasing, the same steps give each of $h_{00}, h_{11}$ above each of $h_{01}, h_{10}$, then $u_{01} + u_{10} < u_{00} + u_{11}$, again a contradiction. A constant $\phi$ gives the same output everywhere. So in a layered network one hidden unit is never enough. The hypothesis matters: with direct connections from the inputs to the output, one unit suffices, for example $h = \operatorname{step}(x_1 + x_2 - 1.5)$ and output $\operatorname{step}(x_1 + x_2 - 2h - 0.5)$, which gives 0, 1, 1 and 0 at $(0, 0)$, $(0, 1)$, $(1, 0)$ and $(1, 1)$. Within the layered architecture of this article, two ReLU units with a linear output suffice:
$$\text{output} = \operatorname{ReLU}(x_1 - x_2) + \operatorname{ReLU}(x_2 - x_1) = |x_1 - x_2|,$$
which is 0 at $(0, 0)$ and $(1, 1)$ and 1 at the other two inputs, exactly XOR, with no threshold at the output.
Problem 3 (small weights give a nearly linear network). This is Exercise 11.2 of Hastie et al. (2009), restated: if the weights from the inputs to the hidden layer are near zero, a network with sigmoid hidden units and a linear output is nearly linear in the inputs. Show it, find how fast the departure from linearity shrinks, and check it on the two standardized tumor measurements.
Solution. Scale the input weights by a small factor $\varepsilon$, so the network computes $f(\mathbf{x}) = \beta_0 + \sum_m \beta_m \sigma(\varepsilon\, \boldsymbol{\alpha}_m^{\mathsf{T}} \mathbf{x})$, with the hidden biases set to zero for the moment. The Taylor series of the sigmoid at zero is $\sigma(v) = \tfrac12 + \tfrac{v}{4} - \tfrac{v^3}{48} + O(v^5)$. It has no $v^2$ term, because $\sigma(v) - \tfrac12$ is an odd function ($\sigma(-v) = 1 - \sigma(v)$). Hence
$$f(\mathbf{x}) = \Big(\beta_0 + \tfrac12 \textstyle\sum_m \beta_m\Big) + \frac{\varepsilon}{4} \sum_m \beta_m \boldsymbol{\alpha}_m^{\mathsf{T}} \mathbf{x} - \frac{\varepsilon^3}{48} \sum_m \beta_m (\boldsymbol{\alpha}_m^{\mathsf{T}} \mathbf{x})^3 + O(\varepsilon^5),$$
a linear function of $\mathbf{x}$ plus a remainder of order $\varepsilon^3$, while the linear part itself is of order $\varepsilon$. Relative to the linear part, the nonlinearity therefore shrinks like $\varepsilon^2$. (With nonzero hidden biases of order one, $\sigma''$ at the bias is not zero, and the remainder is of order $\varepsilon^2$; the model is still linear to first order.) For a 2-8-1 network with standard normal weights drawn with seed 0 and output bias 0.3, evaluated on the 569 standardized tumors, the largest departure of $f$ from its linear part is 0.0062 at $\varepsilon = 0.1$, 4.4% of the largest linear term, and $6.8 \times 10^{-6}$ at $\varepsilon = 0.01$, 0.048% of it. A tenfold smaller $\varepsilon$ shrinks the departure about 924-fold, close to the factor of 1,000 that the $\varepsilon^3$ term predicts. This is why a network started from small random weights starts close to a linear model, the point that The Multilayer Perceptron uses to explain early stopping.
Open questions
- Does the two-measurement neuron hold its accuracy on new tumors, and what do the other 28 measurements add? The 89.1% above is a training accuracy. Refitting the two-input and the 30-input logistic regressions on the 30 seeded splits of The Single-Layer Perceptron and comparing their test accuracy and log loss split by split would settle it, with Paired Comparisons of Models for the paired differences.
- Where does the perceptron rule end up on these two measurements? The two classes overlap, so no line separates them and the rule never completes an epoch without a mistake (the next article shows what that does to its weights). Running the averaged perceptron on the same two standardized inputs for 30 orders and comparing its boundary with the logistic line, radius = 18.78 − 0.206 × texture, would show how far a rule that counts mistakes lands from one that maximizes a likelihood.
- How much data does a network of a given size need? The 235,146 parameters of the digit network count weights, and how many examples a network of that size needs is not settled by the count alone. Comparing published VC-dimension bounds for such networks with the sample sizes at which the networks of this unit stop overfitting is the question that The VC Dimension and Why Classical Bounds Do Not Explain Deep Networks frame and do not settle for networks.
Where neural networks fit
Among the methods in this collection, neural networks sit at the flexible end. A network with one hidden layer and enough units can approximate any continuous function on the unit cube (and so, after rescaling the inputs, on any bounded box) as closely as desired (Cybenko, 1989, Theorem 2), which no fixed linear model can do; The Multilayer Perceptron states the theorem and its later forms and builds such approximations from ReLU units. The flexibility has costs. The fitted weights do not have the direct reading of regression coefficients or the rules of a decision tree; training involves choices (architecture, learning rate, initialization, stopping) that change the result; and the networks need more data than simpler methods to estimate their many parameters well. On tabular data of modest size a logistic regression can be as accurate: on the breast cancer and wine data, in the multilayer perceptron article, it matched a network with a hidden layer in 30 seeded splits. Networks pay off when the relationship between inputs and outcome is strongly nonlinear and there are many examples, and above all for images, sound and text, where specialized architectures exploit the structure of the input.
The next article, The Single-Layer Perceptron, takes the single threshold neuron and its learning rule, proves that the rule finds a separating hyperplane in finitely many mistakes whenever one exists with a margin, and measures how many mistakes it needs.
In Python
The neuron of the opening example is a logistic regression, and scikit-learn fits it directly:
import numpy as np
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
data = load_breast_cancer()
cols = [list(data.feature_names).index(c) for c in ("mean radius", "mean texture")]
X = StandardScaler().fit_transform(data.data[:, cols])
y = (data.target == 0).astype(int) # 1 = malignant
neuron = LogisticRegression(penalty=None, tol=1e-10, max_iter=10000).fit(X, y)
w, b = neuron.coef_[0], neuron.intercept_[0] # [3.7220, 0.9374], -0.7076
z = X @ w + b # pre-activations
p = 1 / (1 + np.exp(-z)) # sigmoid activations
print(z[0], p[0]) # 1.4321, 0.8072
In scikit-learn's data the label 0 means malignant, so the code recodes it to 1. The tight tolerance makes the solver run all the way to the maximum likelihood estimate; with its default tolerance it stops slightly short, at weights of 3.7183 and 0.9367. Networks with hidden layers are fitted with sklearn.neural_network.MLPClassifier or MLPRegressor, or written out in NumPy as in the multilayer perceptron article. The numbers in this article are computed by tools/experiments/data-science/introduction-to-neural-networks.py in the site's repository.
References
- Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals, and Systems, 2(4), 303–314. record · 2 pages
- Glorot, X., Bordes, A., and Bengio, Y. (2011). Deep sparse rectifier neural networks. In Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics, PMLR 15, 315–323. record · 2 pages
- Goodfellow, I., Bengio, Y., and Courville, A. (2016). Deep Learning. MIT Press. §1.2.1. https://www.deeplearningbook.org record · 3 pages
- Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.). Springer. Ch. 11 and Exercise 11.2. record · 39 pages
- James, G., Witten, D., Hastie, T., and Tibshirani, R. (2021). An Introduction to Statistical Learning with Applications in R (2nd ed.). Springer. Ch. 10. record · 39 pages
- McCulloch, W. S., and Pitts, W. (1943). A logical calculus of the ideas immanent in nervous activity. Bulletin of Mathematical Biophysics, 5, 115–133. Read in the reprint, Bulletin of Mathematical Biology, 52(1/2), 99–115 (1990). record
- Minsky, M., and Papert, S. (1969). Perceptrons: An Introduction to Computational Geometry. MIT Press. Cited by attribution, through Goodfellow et al. (2016); not read for this article. record · 2 pages
- Nair, V., and Hinton, G. E. (2010). Rectified linear units improve restricted Boltzmann machines. In Proceedings of the 27th International Conference on Machine Learning (pp. 807–814). record · 2 pages
- Parker, D. B. (1985). Learning-Logic: Casting the Cortex of the Human Brain in Silicon. Technical Report TR-47, Center for Computational Research in Economics and Management Science, MIT. Cited by attribution (Hastie et al., 2009, whose bibliography gives the number as TR-87; the report itself is TR-47). record · 2 pages
- Rosenblatt, F. (1958). The perceptron: A probabilistic model for information storage and organization in the brain. Psychological Review, 65(6), 386–408. record · 2 pages
- Rumelhart, D. E., Hinton, G. E., and Williams, R. J. (1986). Learning representations by back-propagating errors. Nature, 323, 533–536. record · 3 pages
- Werbos, P. J. (1974). Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences. PhD thesis, Harvard University. Cited by attribution (Hastie et al., 2009). record · 2 pages
- Wolberg, W., Mangasarian, O., Street, N., and Street, W. (1993). Breast Cancer Wisconsin (Diagnostic) [Data set]. UCI Machine Learning Repository. https://doi.org/10.24432/C5DW2B record · 15 pages
Reviewed: verified, 23 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 23 Nov 2026 · editorial review, 23 Nov 2026 · 7 revisions