Artificial Neural Networks

From one artificial neuron to networks with hidden layers, trained by gradient descent. The neuron shown to be logistic regression on breast cancer measurements, and the history from McCulloch and Pitts to backpropagation; the perceptron and its convergence theorem, proved and checked on iris flowers; the activation functions with their derivatives, vanishing gradients measured layer by layer and the Glorot and He initializations derived; and the multilayer perceptron, with backpropagation worked by hand, checked by finite differences and trained in NumPy against logistic regression in 30 seeded splits, overfitting and early stopping, and universal approximation.

A single artificial neuron, a weighted sum passed through a fixed function, fitted to two measurements of 569 breast tumors, is exactly a logistic regression. Join many such units in layers, let the outputs of some be the inputs of others, and fit all their weights together, and the result is a neural network. This unit follows that construction from the one neuron to networks with hidden layers, and asks at each step what the added structure buys and what it costs.

The unit is the applied introduction. It works on small public datasets with networks written from scratch in NumPy, so that every gradient can be checked by hand, and it compares each network with the simpler model it generalizes.

Order. The introduction comes first, because it defines the neuron, the layer and the vocabulary the other articles use. The perceptron follows as the simplest trainable network and the first learning machine with a theorem behind it. The activation functions come next, because the perceptron's step function is what stops it from training hidden layers. The multilayer perceptron closes the unit by putting the pieces together: layers, smooth activations, a loss, backpropagation and gradient descent.

Running data. The Wisconsin breast cancer data (569 tumors, 30 measurements of their cell nuclei) run through all four articles: two measurements for the single neuron and the hand-worked backpropagation, all thirty for the perceptron's slow convergence, the ten-layer networks of the activation article and the comparisons with logistic regression. Fisher's iris flowers check the perceptron's convergence bound, the wine data (178 wines, three cultivars) give a three-class network with a softmax output, and scikit-learn's two interleaving moons give the case where hidden units clearly help.

What is proved, shown and cited. Proved on the pages: the collapse of stacked linear layers into one; that no layered network with a single hidden unit of any nondecreasing activation computes XOR, while two units do; the perceptron convergence theorem with the bound $(R/\gamma)^2$, and a second proof by distance to a separating vector; that XOR is not linearly separable and that the rule cycles on it; the derivatives of the sigmoid, tanh, GELU and softmax, and the gradient $\mathbf{p} - \mathbf{y}$ of softmax with cross-entropy; the variance recursion that gives Glorot's and He's initializations; the backpropagation equations; the error bound for the ReLU interpolant; and the symmetries that make a network's weights unidentifiable. Cited: the history and its sources, the universal approximation theorems of Cybenko, Hornik and Leshno and colleagues, and the published experiments on initialization and activations. Shown by the scripts in tools/experiments/data-science/: every number, including the gradient norms layer by layer, the dying units at a large learning rate, the finite-difference checks and the 30-split comparisons.

Articles

  • Introduction to Artificial Neural Networks: what a neuron computes, shown on two tumor measurements to be logistic regression; the biological analogy and where it stops; the history from McCulloch and Pitts through Rosenblatt, Minsky and Papert and backpropagation to the deep learning revival; layers, parameter counts and why hidden layers need a nonlinearity; XOR from three threshold units, with worked problems proving that one hidden unit can never compute it and that small weights make a network nearly linear.
  • The Single-Layer Perceptron: Rosenblatt's threshold unit and its learning rule, traced by hand on AND; the rule as stochastic gradient descent on the perceptron criterion; the convergence theorem proved by Novikoff's argument and its bound checked on iris flowers; XOR and the limit of linear separability; breast cancer data that are separable yet take 1,335 mistakes; and the comparison with logistic regression, with worked problems on the XOR cycle, a second convergence proof and the size of the constant input.
  • Nonlinear Activation Functions: the step, sigmoid, tanh, ReLU, leaky ReLU, GELU and softmax with their derivatives; vanishing gradients measured layer by layer in a ten-layer network, where sigmoid units learn nothing in 50 epochs; Glorot and He initialization, with the variance recursion behind them derived and measured; dying ReLUs at a learning rate that is too large; softmax computed stably with its Jacobian; and which function to use where.
  • The Multilayer Perceptron: the forward pass in matrix form, the loss and gradient descent; backpropagation derived, worked by hand on one tumor and checked by finite differences; why the starting weights must be random; a NumPy network against logistic regression and scikit-learn in 30 seeded splits, winning on two moons and adding nothing on breast cancer and wine; overfitting in the probabilities of a 74,000-parameter network and early stopping; and universal approximation, with ReLU interpolants whose error bound is proved.

Where the site goes deeper

The Statistics collection holds the theory under the output layer and the generalization questions. Multinomial and Softmax Regression proves the properties of the softmax output with cross-entropy, the model a network's last layer fits, and Deviance and Inference for Generalized Linear Models proves when the logistic estimate exists, the separation that the perceptron article meets. Statistical Learning Theory asks when a training error can be trusted: Empirical Risk Minimization treats the surrogate losses, The VC Dimension proves that half-spaces in $d$ dimensions have dimension $d + 1$, Rademacher Complexity proves margin bounds for linear classifiers, and Why Classical Bounds Do Not Explain Deep Networks shows where these bounds stop for large networks.

The library's Language Models from Scratch collection takes the multilayer perceptron into a modern architecture: The Bigram Language Model trains with Adam, Building Self-Attention adds attention, and Assembling the Transformer Block places a ReLU feed-forward network, residual connections and layer normalization in each block. The Academics section's Neuroevolution topic trains networks without gradients, by evolving their weights in Evolving Neural Network Weights and their structure in NEAT. The Word Embeddings article of the Information Retrieval collection derives the gradient of skip-gram, a shallow network that learns word vectors from which words occur near which, and proves what its trained dot products equal.

Several subjects these pages touch would support fuller treatment in a later collection on deep learning: automatic differentiation, optimizers such as momentum and Adam, normalization layers, regularization by dropout and data augmentation, convolutional and recurrent architectures, and deep generative models.

References

Each article lists its own references. The sources the unit draws on throughout: record · 4 pages

  • Glorot, X., and Bengio, Y. (2010). Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, PMLR 9, 249–256. record · 2 pages
  • Goodfellow, I., Bengio, Y., and Courville, A. (2016). Deep Learning. MIT Press. 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. §4.5 and Chapter 11. 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. Chapter 10. record · 39 pages
  • Novikoff, A. B. J. (1962). On convergence proofs for perceptrons. In Proceedings of the Symposium on the Mathematical Theory of Automata (Vol. 12, pp. 615–622). Polytechnic Institute of Brooklyn. 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