Artificial Intelligence Applications in Engineering (MUH-920), week 10 of 14: interactive lab

Neural network playground: Neurons, networks and optimisers

Prof. Dr. Utku Kose, Süleyman Demirel University

Part A shows a single neuron with adjustable weights, bias and activation over a two-dimensional input space, and Part B applies the perceptron rule one example at a time [1]. Part C trains a network with one or two hidden layers on circles, XOR, two moons or a spiral, with controls for width, depth, activation and learning rate [2], and Part D computes a backpropagation step number by number. Part E compares gradient descent, momentum and Adam on a narrow valley of a loss surface [3], and Part F writes out the steps of the three optimisers. Part G follows signals through many layers and normalises a mini-batch [4, 5], Part H counts parameters and applies weight decay and dropout [6], and Part I applies early stopping and trains a small network until it overfits.

Part A: One neuron

Part B: The perceptron rule step by step

The perceptron of the worked example learns AND from the start w = (0.5, 0.5), b = 0.1 with η = 0.2. Every visit to an example prints the score, the output, the error and the corrected weights, and the chart shows the firing region and the boundary after the last step. Every function of the list except XOR is linearly separable, and for XOR every epoch keeps a mistake [1, 7].

Part C: Train a network

Part D: Backpropagation number by number

The network of the worked example has two inputs, two sigmoid hidden units with the weights w11, w12, w21, w22 and the biases b1, b2, and a sigmoid output with the weights v1, v2 and the bias bo. The panel computes the forward pass, the loss, the error signals and all nine gradients with six decimals, as in the lecture, and applies the update. A central difference checks any gradient without rounding [2, 8].

Checking a gradient numerically

Part E: Optimisers in a narrow valley

Part F: Gradient descent, momentum and Adam step by step

The three optimisers minimise the loss L = a(w − w*)², by default (w − 3)² from w0 = 0 with η = 0.1, as in the worked example. The table lists every step, the panel writes out the arithmetic of a chosen step, and the error factor 1 − 2aη tells in advance whether gradient descent converges, oscillates or diverges [3, 8].

Part G: Initialisation, signal flow and batch normalisation

A deep stack of equal layers receives standardised inputs, and random error signals enter at the last layer. The chart shows on a logarithmic scale how the standard deviations of the activations and of the error signals change from layer to layer, for weights drawn uniformly from a multiple of the Glorot range. The second panel normalises any mini-batch of one unit [4, 5].

Signals through many layers

Batch normalisation of one unit

Part H: Parameters, weight decay and dropout

The first panel counts weights and biases layer by layer, by default for the concrete network of the worked example. The second applies one step of weight decay and follows a weight that receives no gradient. The third applies a dropout mask, gives the exact distribution of the weighted sum over all masks, and draws random masks to show that their mean is the value at test time [6, 8].

Counting parameters

Weight decay

Dropout

Part I: Early stopping and learning curves

The first panel applies early stopping with a patience to any losses, by default those of the worked example with two more epochs. The second trains a network with 40 tanh units on 12 noisy points of a sine curve: The training error keeps falling while the validation error rises again, and early stopping or weight decay, for example λ = 0.003, prevents the damage [8].

Early stopping by the numbers

A network that overfits

References

[1] Rosenblatt, F. (1958). The perceptron: A probabilistic model for information storage and organization in the brain. Psychological Review, 65(6), 386-408. https://doi.org/10.1037/h0042519

[2] Rumelhart, D. E., Hinton, G. E., & Williams, R. J. (1986). Learning representations by back-propagating errors. Nature, 323(6088), 533-536. https://doi.org/10.1038/323533a0

[3] Kingma, D. P., & Ba, J. (2015). Adam: A method for stochastic optimization. In 3rd International Conference on Learning Representations (ICLR 2015). https://arxiv.org/abs/1412.6980

[4] Glorot, X., & 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 (pp. 249-256).

[5] Ioffe, S., & Szegedy, C. (2015). Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Proceedings of the 32nd International Conference on Machine Learning, PMLR 37 (pp. 448-456). https://arxiv.org/abs/1502.03167

[6] Srivastava, N., Hinton, G., Krizhevsky, A., Sutskever, I., & Salakhutdinov, R. (2014). Dropout: A simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15(56), 1929-1958.

[7] Minsky, M., & Papert, S. (1969). Perceptrons: An Introduction to Computational Geometry. MIT Press.

[8] Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.

[9] Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals and Systems, 2(4), 303-314. https://doi.org/10.1007/BF02551274

[10] Hornik, K., Stinchcombe, M., & White, H. (1989). Multilayer feedforward networks are universal approximators. Neural Networks, 2(5), 359-366. https://doi.org/10.1016/0893-6080(89)90020-8