Week-04 ยท ML-2026
Alexei Kornaev,
Dr. Sc., Prof.
Innopolis University
Researcher at the RC for AI,
National RC for Oncology n.a. N.N. Blokhin

From artificial neurons to nonlinear multilayer architectures.
| Model | Prediction | What is learned? | Source of flexibility |
|---|---|---|---|
| Linear regression | Coefficients | Linear response | |
| Logistic regression | Decision boundary | Linear boundary in feature space | |
| Decision tree | Leaf value | Splits and leaves | Recursive partitioning |
| Forest / boosting | Ensemble prediction | Multiple trees | Combined partitions |
| MLP | Transformations and predictor | Learned nonlinear representation |
The final row adds learned features between the supplied input and the prediction.
Logistic regression
Two-layer network
collects all trainable parameters. The output transformation depends on the prediction task.
The model becomes richer; the learning loop remains familiar.
Earlier layers learn the features used by later layers.

Natural neuron. Receives electrochemical signals through dendrites and synapses, integrates them across space and time, and may generate an action potential transmitted along the axon.
Artificial neuron. Receives numerical inputs, scales them by learned weights, adds a bias, and applies an activation function to produce an output.
| Biological terminology | Artificial abstraction |
|---|---|
| Incoming signals | Inputs |
| Synaptic influence | Weights |
| Signal integration | Weighted sum and bias |
| Firing response | Activation function |
| Axon signal | Output |
This is a functional analogy, not a mechanistic model: biological neurons are dynamic, spiking, adaptive cells; an artificial neuron is a simplified differentiable computation.
The weighted sum collects signed evidence. The activation shapes the signal passed onward.
Range:
Preserves the affine signal.
Range:
Maps scores to bounded positive outputs.
Range:
Produces a zero-centred bounded signal.
Range:
Keeps positive evidence and clips negative values.
Variants such as Leaky ReLU modify the inactive side while preserving a piecewise-linear form.
Two affine layers reduce to one equivalent affine layer.
Nonlinearity prevents a deep network from collapsing into a single affine transformation.
Each neuron has its own weights and bias:
Stacking the neuron parameters gives one vectorized layer:
The rows of contain the neuronsโ weight vectors.
Follow values through the network and interpret its outputs.
One sample
Batch of samples
PyTorch stores each neuronโs weights as one row of weight, with shape .
Calculate the weighted contributions before revealing the result.
A layer performs several neuron calculations in one matrix operation.
Blue labels mark stored parameters; circles show intermediate values and the final prediction.
Forward propagation composes affine transformations with hidden-layer activations; the output transformation depends on the task.
| Task | Network output | Interpretation | Typical loss |
|---|---|---|---|
| Regression | real values | Predicted quantities | MSE |
| Binary classification | One logit | BCE with logits | |
| Multiclass classification | logits | Softmax probabilities; class | Cross-entropy |
BCEWithLogitsLoss and CrossEntropyLoss expect logits and apply the required stable transformation internally.
.
nn.Linear compute?nn.Linear performs the affine transformation. The activation is a separate operation.
Softmax converts relative evidence into a categorical probability distribution.
Numerically stable implementations subtract the largest logit before exponentiation.
Model output
Observed class
The one-hot target selects the log-probability assigned to the observed class. Higher probability gives a smaller loss; lower probability gives a larger loss.
cross_entropy expects logits. It applies a stable log-softmax and negative log-likelihood internally (PyTorch contributors, n.d.-b).
An architecture describes a mapping; the data, output interpretation, and loss define the task.
Scalar input and target suggest regression or function approximation.
Linear output; typical loss: MSE.
grayscale pixels enter two learned hidden representations. Ten output logits suggest multiclass classification; typical loss: cross-entropy.
The dimensions suggest an MNIST-like task, but architecture alone does not identify the dataset.
Matching input and output dimensions, approximate symmetry, and a -dimensional bottleneck suggest reconstruction. The learned representation can also support dimensionality reduction or anomaly detection.
The bottleneck asks the network to preserve useful information in a smaller representation.
Use the chain rule to assign sensitivity to every parameter.
How much would the loss change if this parameter changed slightly?
Supplied: . Trainable: .
The backward pass uses the graph structure and selected values produced during the forward pass.
Each operation combines its local derivative with the sensitivity arriving from later operations.
Along a dependency path, local derivatives multiply.
Along paths, derivatives multiply; where paths meet, gradient contributions add.
Forward values
| Quantity | Value |
|---|---|
Backward sensitivities
| Gradient | Value | Gradient | Value |
|---|---|---|---|
Forward propagation computes values. Backpropagation computes sensitivities.
| Quantity | Shape |
|---|---|
Incoming sensitivity โ parameter gradients โ sensitivity to the previous layer.
Backpropagation repeats the same layer-level calculation in reverse order.
Reverse-mode differentiation computes vectorโJacobian products without constructing every full Jacobian explicitly.
x = torch.tensor(3.0)
y = torch.tensor(2.0)
w = torch.tensor(2.0, requires_grad=True)
b = torch.tensor(-1.0, requires_grad=True)
a = torch.tensor(0.4, requires_grad=True)
c = torch.tensor(-1.0, requires_grad=True)
z = w * x + b
h = torch.relu(z)
y_hat = a * h + c
loss = 0.5 * (y_hat - y) ** 2
loss.backward()The scalar loss seeds the backward pass.
PyTorch accumulates .grad on leaf tensors with requires_grad=True. Intermediate gradients can be retained explicitly (PyTorch contributors, n.d.-a).
x.grad compute?| Tensor | Interpretation |
|---|---|
w.grad |
Loss sensitivity to a trainable weight; used by the optimizer |
x.grad |
Loss sensitivity to the input |
z.grad |
Not stored by default: is a non-leaf intermediate |
loss |
Seeds backward with |
Call z.retain_grad() before backward() to store an intermediate gradient. Input gradients support sensitivity analysis, saliency, adversarial methods, and input optimization (PyTorch contributors, n.d.-a).
Central finite difference
For the running example:
| Observation | Possible interpretation |
|---|---|
| Gradient near zero | Saturation, inactive path, convergence, or weak sensitivity |
| Very large gradient | Exploding gradient or poor scaling |
| No gradient stored | Backward has not run, gradients are disabled, the tensor is disconnected, or a non-leaf gradient was not retained |
NaN or Inf |
Numerical instability |
A gradient measures local sensitivity and provides a diagnostic signal; its negative gives the steepest-descent direction.
Turn gradients into useful learning and evaluate what generalizes.
Autograd computes gradients; the optimizer uses them to change the parameters.
PyTorch accumulates gradients, so clear them before the next backward pass (PyTorch contributors, n.d.-d, n.d.-e).
The objective defines the landscape; the training procedure determines how we move through it.
The surface depends on the model, data, and objective. The trajectory also depends on initialization, mini-batches, learning rate, and optimizer state. A two-dimensional contour is only a slice or projection.
The gradient measures local sensitivity; its negative supplies the descent direction, and the learning rate controls the update scale.
Too small can be slow; too large can overshoot or diverge. There is no universally optimal learning rate.
| Optimizer | Main mechanism | Practical consequence |
|---|---|---|
| SGD | Current mini-batch gradient | Simple; sensitive to learning rate and scale |
| Momentum | Accumulates a moving direction | Reduces oscillation and preserves motion |
| Adam | Adaptive first- and second-moment estimates | Often convenient and fast early in training |
| AdamW | Adam with decoupled weight decay | Shrinkage is separate from adaptive gradient scaling |
An optimizer transforms gradientsโand often their historyโinto parameter updates.
AdamW applies decoupled parameter shrinkage; it is not merely Adam plus an L2 term (Kingma and Ba 2015; Loshchilov and Hutter 2019).
| Smaller batch | Larger batch |
|---|---|
| Noisier estimate | More stable estimate |
| More updates per data pass | Fewer updates per data pass |
| Lower memory requirement | Higher memory requirement |
| Less parallel efficiency | Better utilization, up to a limit |
Mini-batches trade gradient certainty for computational efficiency and more frequent updates.
The estimate is not an โincorrect gradient.โ Its exact variance and unbiasedness depend on the sampling procedure.
Initialization should keep signals and sensitivities informative across layers.
These variance rules use simplifying assumptions; they do not guarantee stable training in every architecture (Glorot and Bengio 2010; He et al. 2015).
| Split | Role |
|---|---|
| Training | Fit model parameters |
| Validation | Select epoch, architecture, and hyperparameters |
| Test | Estimate final performance after decisions are fixed |
A decreasing training loss proves successful optimization, not successful generalization.
Early stopping selects an epoch from validation performance. The test set is not monitored as a training curve.
| Mechanism | Where it acts | Main effect |
|---|---|---|
| L1/L2 penalty | Objective | Discourages parameter configurations |
| Weight decay | Update rule | Shrinks selected parameters |
| Dropout | Network during training | Randomly masks activations or units during training |
| Data augmentation | Training data | Encodes plausible invariances |
| Early stopping | Training duration | Limits training-specific adaptation |
Regularization constrains parameters, representations, data, or training time.
L2 penalty and weight decay match for ordinary SGD under the corresponding update, but not generally for adaptive optimizers. Dropout is off at evaluation; the framework handles scaling. Biases and normalization parameters are often excluded from weight decay (Srivastava et al. 2014; Loshchilov and Hutter 2019).
1943 ยท A mathematical neuron
McCulloch and Pitts propose a logical model of neural computation.
1958 ยท A neuron that learns
Rosenblatt introduces the perceptron and its learning rule.
1969 ยท Limits of a single layer
Minsky and Papert analyze what single-layer perceptrons cannot represent.
1970sโ1986 ยท Learning through many layers
Reverse differentiation becomes a practical way to assign credit through composed computations.
2006โ2012 ยท The deep-learning revival
Better training, larger datasets, GPUs, and new architectures make deep networks practical.
Today ยท Differentiable programming
PyTorch constructs computation graphs and calculates gradients automatically.
Neural networks became transformative when expressive hidden representations met a practical method for assigning credit through many layers.

Geoffrey Hinton helped turn backward credit assignment into a practical foundation of modern deep learning.
1986 ยท Learning internal representations
Rumelhart, Hinton, and Williams showed how hidden representations can be learned by propagating error derivatives backward (Rumelhart et al. 1986).
2006 ยท Reviving deep networks
Hinton, Osindero, and Teh introduced an influential layer-wise training method for deep belief networks (Hinton et al. 2006).
2012 ยท Deep learning at scale
Krizhevsky, Sutskever, and Hinton demonstrated deep convolutional networks trained with GPUs on ImageNet (Krizhevsky et al. 2012).
Backpropagation organizes the chain rule through a computation graph. Autograd is the software machinery that performs this differentiation automatically.
2018 ACM Turing Award (Association for Computing Machinery 2019) ยท 2024 Nobel Prize in Physics (Nobel Prize Outreach 2024)
โ Lectures Introduction to Machine Learning ยท Week 04