Skip to content
New
Latest News || 27 October 2026: Dr Soumava Mukherjee's invited talk at Queen's University Belfast joined device-level hardware innovation with channel-level control. || 22 October 2026: I received a Certificate of Appreciation for serving as a reviewer for IEEE IMAS 2026. || 15 October 2026: I presented a poster on beam-domain ML fingerprinting for RIS-aided mmWave localisation at the Centre for Wireless Innovation's annual symposium. || 15 October 2026: CWI's annual symposium brought research and industry perspectives on 6G, ISAC, optical wireless, AI, and future networks to Queen's University Belfast. || 14 October 2026: Erik Nordell of Ericsson visited our Keysight Lab for a live RIS-assisted video streaming demonstration.
Knowledge Hubmachine learning3. Parameters, Training and Generalization

machine learning learning note

3. Parameters, Training and Generalization

A beginner-friendly guide to common machine learning, deep learning, DNN, and DRL parameters such as seed, batch size, epoch, bias, overfitting, underfitting, learning rate, and exploration.

At a glance

  • Weights are learned; settings are chosenWeights and intercepts are parameters; learning rate, model capacity and regularization are hyperparameters.
  • Read training and validation togetherLow training error with high validation error suggests overfitting; a single curve cannot establish a bias/variance decomposition.
  • Separate optimization from evaluationBatch size and epochs control updates. Keep preprocessing inside the training split and use several seeds for a robust comparison.

Why These Parameters Matter

Machine learning is not only about choosing an algorithm. The final result also depends on many settings, choices, and training conditions.

Some of these are learned by the model:

  • Weights.
  • Bias terms.
  • Neural-network layer parameters.
  • Q-values or policy parameters in reinforcement learning.

Some are chosen by the researcher or engineer before training:

  • Learning rate.
  • Batch size.
  • Number of epochs.
  • Random seed.
  • Model depth.
  • Regularization strength.
  • Discount factor in reinforcement learning.

These user-chosen settings are called hyperparameters. They strongly affect speed, stability, accuracy, generalization, and reproducibility.

References for this section3
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Parameter vs. Hyperparameter

TermMeaningExample
ParameterLearned from data during trainingWeight w, coefficient β, neural-network bias
HyperparameterChosen before or during training setupLearning rate, batch size, number of layers
MetricUsed to evaluate performanceAccuracy, F1-score, MAE, reward
LossFunction the model tries to minimizeCross-entropy, MSE

Simple rule:

If the model learns it, it is usually a parameter.
If you set it before training, it is usually a hyperparameter.
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Random Seed

A seed controls randomness so experiments can be repeated.

Randomness appears in:

  • Train-test splitting.
  • Weight initialization.
  • Data shuffling.
  • Dropout.
  • Mini-batch selection.
  • Reinforcement-learning exploration.

If two experiments use the same seed and the same software/hardware behavior, the results are more likely to match.

import random
import numpy as np

random.seed(42)
np.random.seed(42)
References for this section3
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Effect of Seed

Seed behaviorEffect
Fixed seedBetter reproducibility
Different seedsBetter estimate of result stability
Reporting only one lucky seedCan exaggerate performance

Good practice is to run important experiments with multiple seeds and report the mean and variation.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Dataset Split

A dataset is usually divided into:

SplitPurpose
Training setUsed to fit the model
Validation setUsed to tune hyperparameters
Test setUsed once at the end for final evaluation

The test set should not influence training decisions. If it does, the evaluation becomes overly optimistic.

References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Feature Scaling

Feature scaling changes feature ranges so one feature does not dominate another.

Common methods:

MethodFormulaMeaning
Standardizationz = (x − μ) / σMean 0 and standard deviation 1
Min-max scalingx' = (x − xmin) / (xmax − xmin)Range between 0 and 1

Scaling is important for:

  • KNN.
  • SVM/SVR.
  • Ridge and Lasso.
  • Kernel Ridge Regression.
  • Neural networks.
  • Gradient descent.

Tree-based models usually need less scaling.

Why scale features? Stretched bowls slow gradient descent

1. Formula and symbols
L(w)=12∑jσj2(wj−wj⋆)2,curvatures λj=σj2L(w)=\tfrac12\sum_j\sigma_j^2(w_j-w_j^\star)^2,\qquad\text{curvatures }\lambda_j=\sigma_j^2
w←w−η∇L,η=1.6λmax⁡,κ=λmax⁡λmin⁡w\leftarrow w-\eta\nabla L,\quad\eta=\frac{1.6}{\lambda_{\max}},\qquad\kappa=\frac{\lambda_{\max}}{\lambda_{\min}}
zj=xj−μjσj ⇒ λj=1, κ=1z_j=\frac{x_j-\mu_j}{\sigma_j}\ \Rightarrow\ \lambda_j=1,\ \kappa=1
  • x1x_1: SNR feature in dB, spread σ₁ = 5
  • x2x_2: Bandwidth feature in hundreds of MHz, spread σ₂ = 1
  • wjw_j: Weight of feature j; w* is the best weight
  • σj\sigma_j: Standard deviation of feature j
  • λj\lambda_j: Curvature of the loss along w_j
  • η\eta: Learning rate; it must stay below 2/λ_max or the steep direction diverges
  • κ\kappa: Condition number: how stretched the loss bowl is
  • zjz_j: Standardised feature (mean 0, spread 1)

The steep direction limits the step size, so the shallow direction crawls. Standardising makes every direction equally steep.

w*startw₁ (equal scale on both axes)w₂04080−4−20steplog₁₀ L
Features
2. Work with the current inputs
λ=(25, 1),κ=25,η=1.625=0.064\lambda=(25,\ 1),\quad\kappa=25,\quad\eta=\frac{1.6}{25}=0.064
per-step factors: 1−ηλj=(−0.600, 0.936)\text{per-step factors: }1-\eta\lambda_j=(-0.600,\ 0.936)
L15=0.2750,steps to 1% of L0: 30L_{15}=0.2750,\quad\text{steps to }1\%\text{ of }L_0:\ 30
3. Result
Condition number κ25
Steps to reach 1% of the start loss30
Loss after 15 steps0.275
A linear model with two uncorrelated features whose spreads differ by 5×. Left: loss contours in weight space and the gradient-descent path from the origin. Unscaled, the bowl is a narrow valley: the step size must be small enough for the steep wall, so the path zigzags and crawls along the valley floor. Standardised, the bowl is round and the path goes straight to the minimum. Right: log₁₀ of the loss against the step.
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Loss Function

The loss function measures how wrong the model is during training.

For regression, a common loss is mean squared error:

MSE=1n∑i=1n(yi−y^i)2\mathrm{MSE}=\frac1n\sum_{i=1}^n(y_i-\widehat y_i)^2
  • nn: number of training examples
  • yiy_{i}: true value
  • y^i\widehat y_i: predicted value.
  • MSE: average squared prediction error; a large miss receives extra weight.

For classification, a common loss is cross-entropy:

L=−[ylog⁡p+(1−y)log⁡(1−p)]L=-\big[y\log p+(1-y)\log(1-p)\big]
  • LL: loss for one binary example
  • yy: true class (0 or 1)
  • pp: predicted probability of class 1.
  • log⁡\log: natural logarithm; probabilities should stay strictly between 0 and 1 in this expression.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Effect of Loss Function

Loss choiceEffect
MSEStrongly punishes large regression errors
MAEMore robust to outliers
Cross-entropyStandard for classification probabilities
Huber lossMixes MSE and MAE behavior
RL reward objectiveOptimizes long-term return, not ordinary prediction error
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Learning Rate

The learning rate controls how large each update step is during optimization.

θt+1=θt−η∇L(θt)\theta_{t+1}=\theta_t-\eta\nabla L(\theta_t)
  • θt\theta _{t}: parameter vector before update step t.
  • θt+1\theta _{t+1}: parameter vector after update step t.
  • η\eta: learning rate
  • ∇L(θt)\nabla L(\theta _{t}): gradient of the loss at the current parameters.

For reference:

SymbolMeaning
θmodel parameters
ηlearning rate
∇L(θ)gradient of the loss
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Effect of Learning Rate

Learning rateEffect
Too smallTraining is stable but slow
Good valueTraining improves smoothly
Too largeLoss may jump, oscillate, or explode

In deep learning, learning-rate schedules often reduce η during training.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Batch Size

Batch size is the number of training examples used before one parameter update.

Batch sizeEffect
Small batchNoisier updates, can generalize well, slower per epoch
Medium batchCommon practical balance
Large batchStable gradients, faster hardware use, may generalize worse if not tuned

Example:

N=10,000,B=100,⌈N/B⌉=100.N=10{,}000,\quad B=100,\quad \lceil N/B\rceil=100.
  • NN: training-set size.
  • BB: batch size.

Keep the last partial batch when NN is not divisible by BB.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Epoch

One epoch means the model has seen the full training dataset once.

1 epoch = one complete pass through the training set
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Effect of Epochs

Number of epochsEffect
Too fewUnderfitting
EnoughGood learning
Too manyPossible overfitting

Early stopping can stop training when validation performance stops improving.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Iteration

An iteration is one parameter update.

For mini-batch training:

updates per epoch=⌈NB⌉.\text{updates per epoch}=\left\lceil\frac NB\right\rceil.

This assumes one update per batch and keeps the last partial batch; dropping that batch uses the floor instead.

Epoch and iteration are related, but they are not the same.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Weight

A weight controls how strongly an input feature affects the output.

For a linear model:

y^=β0+∑j=1pβjxj\widehat y=\beta_0+\sum_{j=1}^{p}\beta_jx_j
  • y^\widehat y: prediction
  • β0\beta _{0}: intercept
  • βj\beta _{j}: learned weight for feature xⱼ.
  • pp: number of input features
  • ⋯\cdots continues the weighted sum.

The coefficients β₁, β₂, ..., βₚ are weights.

Large weights can make a model sensitive. Regularization keeps weights controlled.

References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Bias

The word bias has two common meanings in machine learning.

References for this section3
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Bias as an Intercept

In a model equation, bias is the constant term:

y^=β0+β1x\widehat y=\beta_0+\beta_1x
  • y^\widehat y: predicted value
  • xx: input feature
  • β1\beta _{1}: its learned weight.
  • β0\beta _{0}: intercept, often called bias in this model equation.

It shifts the prediction up or down.

References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Bias as Model Assumption

Bias can also mean the error caused by overly simple assumptions.

High bias often means:

  • The model is too simple.
  • Training error is high.
  • Validation error is high.
  • The model underfits.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Variance

Variance measures how much the model changes when the training data changes.

High variance often means:

  • The model is too flexible.
  • Training error is low.
  • Validation/test error is high.
  • The model overfits.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Underfitting

Underfitting happens when the model is too simple to learn the real pattern.

Signs:

  • High training error.
  • High validation error.
  • Model predictions are too crude.

Common fixes:

  • Use a more expressive model.
  • Train longer.
  • Add useful features.
  • Reduce excessive regularization.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Overfitting

Overfitting happens when the model learns the training data too closely, including noise.

Signs:

  • Very low training error.
  • Much higher validation/test error.
  • Model performs poorly on new data.

Common fixes:

  • Use more data.
  • Use regularization.
  • Use dropout.
  • Use early stopping.
  • Use data augmentation.
  • Reduce model complexity.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Bias-Variance Tradeoff

The model should be complex enough to learn real structure, but not so complex that it memorizes noise.

Training errorValidation errorLikely interpretation
HighHighUnderfitting
LowHighOverfitting
LowLowGood fit

Try the lab: vary the polynomial degree and compare training with validation MSE. Low training error alone does not show a useful model. This single fixed split illustrates model flexibility; statistical bias and variance require repeated datasets.

Does a more flexible model always validate better?

1. Formula and symbols
y^(x)=∑j=0pβjxj\widehat y(x)=\sum_{j=0}^{p}\beta_jx^j
(XTX+λP)β=XTy,P=diag⁡(0,1,…,1)(X^TX+\lambda P)\beta=X^Ty,\quad P=\operatorname{diag}(0,1,\ldots,1)
MSE=1N∑i(y^i−yi)2\mathrm{MSE}=\frac1N\sum_i(\widehat y_i-y_i)^2
  • pp: degree
  • XX: polynomial design matrix
  • β\beta: learned coefficients
  • yy: training targets
  • λ\lambda: penalty
  • PP: excludes the intercept from that penalty
  • NN: Number of examples in the set being scored

MSE is computed separately on training and validation sets of size N.

● Train · ○ Validation · Solid: fit · Dashed: generating functionx = −1x = +1; y-axis ±1.575
2. Work with the current inputs
(XTX+1.00×10−6P)β=XTy,p=3(X^TX+1.00\times10^{-6}P)\beta=X^Ty,\quad p=3
MSEtrain=112∑i(y^i−yi)2=0.0256\mathrm{MSE}_{\rm train}=\frac1{12}\sum_i(\widehat y_i-y_i)^2=0.0256
MSEval=140∑j(y^j−yj)2=0.0672\mathrm{MSE}_{\rm val}=\frac1{40}\sum_j(\widehat y_j-y_j)^2=0.0672
3. Result
Training MSE0.0256
Validation MSE0.0672
Prediction at x = 0.51.003
Twelve training and forty distinct validation examples from sin(πx)+0.3x with deterministic independent Gaussian noise. Only training labels enter fitting; validation is for tuning, not a final test score. Polynomial powers use x in [−1,1]; P leaves the intercept unpenalized. Outside the Ridge lab, λ=10⁻⁶ is a small fixed penalty. RBF KRR uses a fixed training-mean baseline. Axes rescale to show unstable fits; this is not a statistical bias/variance decomposition.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Regularization

Regularization discourages unnecessary complexity.

Common types:

MethodEffect
L1 regularizationCan push some weights to zero
L2 regularizationShrinks weights smoothly
DropoutRandomly disables neurons during training
Early stoppingStops before validation performance gets worse
Data augmentationCreates more varied training examples

Ridge Regression uses L2 regularization:

min⁡β0,β[∑i(yi−y^i)2+λ∑j=1pβj2]\min_{\beta_0,\beta}\left[\sum_i(y_i-\widehat y_i)^2+\lambda\sum_{j=1}^p\beta_j^2\right]
  • ii: example index
  • yi−y^iy_{i} - \widehat y_{i}: prediction error
  • jj: weight index
  • βj\beta _{j}: model weight.
  • λ\lambda: nonnegative regularization strength; the first sum fits data, the second penalizes large weights.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Dropout

Dropout is mainly used in neural networks. During training, some neurons are randomly ignored.

Effect:

  • Reduces dependence on individual neurons.
  • Helps prevent overfitting.
  • Can slow training slightly.

Dropout is usually turned off during final evaluation.

Dropout: train with a random half-network, test with the whole

1. Formula and symbols
mj∼Bernoulli(p),h~j=mj hjp(training)m_j\sim\mathrm{Bernoulli}(p),\qquad\tilde h_j=\frac{m_j\,h_j}{p}\quad\text{(training)}
E[h~j]=hj ⇒ E[∑jvjh~j]=∑jvjhj\mathbb E[\tilde h_j]=h_j\ \Rightarrow\ \mathbb E\Big[\sum_jv_j\tilde h_j\Big]=\sum_jv_jh_j
  • hjh_j: Activation of hidden neuron j
  • mjm_j: Random mask: 1 keeps the neuron for this step, 0 drops it
  • pp: Keep probability (drop rate = 1 − p)
  • h~j\tilde h_j: Activation actually passed on, scaled by 1/p (inverted dropout)
  • vjv_j: Output weight of neuron j

At inference time dropout is switched off and no scaling is needed, because the 1/p factor during training already kept the average output unchanged.

002.00000.331.170y = 1.70inputshidden (value passed on)Output over timedashes: full-network outputmarks: last 12 training steps
Phase
2. Work with the current inputs
m=(0,0,1,0,0,1,1,0),scale=1/0.6=1.667m=(0,0,1,0,0,1,1,0),\quad\text{scale}=1/0.6=1.667
y=∑jvjmjhj⋅1.667=1.700,y‾2000 masks=1.781≈yfull=1.850y=\sum_jv_jm_jh_j\cdot1.667=1.700,\quad\overline{y}_{2000\ \rm masks}=1.781\approx y_{\rm full}=1.850
3. Result
Active neurons this step3 of 8
Output this step1.700full network: 1.850
Average over 2000 masks1.781inverted dropout keeps the mean
Each training step draws a new random mask (new mask every 1.6 s): crossed-out neurons are silenced for that step only, so the network cannot rely on any single neuron. The survivors are scaled by 1/p, so the average output over many steps equals the full network’s output. Switch to inference to use every neuron without scaling.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

Optimizer

An optimizer decides how parameters are updated.

OptimizerCommon use
SGDSimple, strong baseline
MomentumSmooths noisy updates
RMSPropUseful for non-stationary gradients
AdamCommon default in deep learning
AdamWAdam with better weight decay behavior

Optimizer choice affects training speed and stability.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Activation Function

Activation functions introduce non-linearity in neural networks.

Without nonlinear activations, a stack of affine layers is equivalent to one affine model.

a=g ⁣(β0+∑j=1pβjxj)a=g\!\left(\beta_0+\sum_{j=1}^{p}\beta_jx_j\right)
  • aa: neuron output
  • gg: activation function applied after the weighted sum.
  • xjx_{j}: input feature j.
  • βj\beta _{j}: learned weight for feature j.
  • β0\beta _{0}: intercept
  • pp: feature count.
ActivationEffect
SigmoidOutputs 0 to 1, can saturate
TanhOutputs -1 to 1
ReLUFast and common, can create dead neurons
GELUCommon in transformer models
SoftmaxConverts class scores into probabilities

Activation functions and their slopes

1. Formula and symbols
σ(z)=11+e−z\sigma(z)=\frac1{1+e^{-z}}
σ′(z)=σ(z)(1−σ(z))≤0.25\sigma'(z)=\sigma(z)(1-\sigma(z))\le0.25
gradient through 10 such layers ∝ ∣a′(z)∣10\text{gradient through 10 such layers}\ \propto\ |a'(z)|^{10}
  • zz: Neuron input: the weighted sum before activation
  • a(z)a(z): Activation output passed to the next layer
  • a′(z)a'(z): Slope: how much a small change in z changes the output (used by backpropagation)

Without a non-linear activation, any stack of layers collapses into one linear map. The slope matters as much as the shape: where it is near zero, learning stalls.

−505−101z— a(z) Sigmoid- - slope a′(z)at z = 2.0:a = 0.88, a′ = 0.10
Activation
2. Work with the current inputs
a(2.0)=0.8808,a′(2.0)=0.1050a(2.0)=0.8808,\qquad a'(2.0)=0.1050
∣a′(z)∣10=1.63×10−10|a'(z)|^{10}=1.63\times10^{-10}
3. Result
Output a(z)0.881
Slope a′(z)0.105gradient passes
Slope over 10 layers1.6e-10
Solid: the activation a(z). Dashed: its slope a′(z), which backpropagation multiplies by at every layer. Sigmoid and tanh flatten for large |z| (saturation), so their slope goes to zero. ReLU keeps slope 1 for positive inputs but is exactly 0 for negative ones (a ‘dead’ neuron); Leaky ReLU and GELU keep a little slope there.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

DNN-Specific Parameters

ParameterEffect
Number of layersMore depth can learn more complex patterns but can overfit
Hidden unitsMore units increase capacity
Batch normalizationStabilizes layer inputs
Layer normalizationCommon in transformers
Residual connectionHelps train deep networks
Weight initializationAffects early training stability
Gradient clippingPrevents exploding gradients
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • Scikit-learn documentation, "Model evaluation".
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.

ML vs. DL vs. DNN vs. DRL

TermMeaning
MLGeneral field where models learn from data
DLDeep learning using neural networks with many layers
DNNDeep neural network architecture
RLReinforcement learning through actions and rewards
DRLDeep reinforcement learning, where deep networks are used inside RL

In short:

DL is a part of ML.
DNN is a type of DL model.
DRL combines deep learning with reinforcement learning.
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • Scikit-learn documentation, "Model evaluation".

DRL-Specific Parameters

Deep Reinforcement Learning has extra parameters because the agent learns by interacting with an environment.

TermMeaning
State sWhat the agent observes
Action aWhat the agent chooses
Reward rFeedback from the environment
Policy π(a given s)Rule for choosing actions
EpisodeOne full interaction run
ReturnTotal future reward

The common discounted return is:

Gt=rt+γrt+1+γ2rt+2+⋯G_t=r_t+\gamma r_{t+1}+\gamma^2r_{t+2}+\cdots
  • GtG_{t}: discounted return starting at step t
  • rtr_{t}: reward at that step.
  • γ\gamma: discount factor, usually between 0 and 1; later rewards receive powers of γ.
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Important DRL Hyperparameters

HyperparameterEffect
Discount factor γControls how much future rewards matter
Exploration rate εControls random exploration in epsilon-greedy methods
Replay buffer sizeControls how many past experiences are stored
Target-network update rateStabilizes Q-learning-style methods
Reward scalingChanges the magnitude of learning signals
Episode lengthControls how far the agent can interact before reset
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Effects in DRL

SettingIf too smallIf too large
γAgent becomes short-sightedAgent may overvalue distant uncertain rewards
εAgent may stop exploring too earlyAgent may behave too randomly
Replay bufferLearns from too little experienceUses more memory and may learn from stale data
Learning rateSlow learningUnstable Q-values or policy updates
Reward scaleWeak gradientsExploding or unstable updates
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Practical Tuning Order

For many ML/DL projects, tune in this order:

  1. Fix the data split and random seed.
  2. Choose a simple baseline.
  3. Check underfitting or overfitting.
  4. Tune learning rate.
  5. Tune batch size and epochs.
  6. Add regularization if overfitting.
  7. Increase model capacity only when the model underfits.
  8. Test with multiple seeds.
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Quick Diagnosis Table

ObservationLikely issueWhat to try
Training and validation errors are both highUnderfittingBigger model, better features, lower regularization
Training error is low but validation error is highOverfittingMore data, regularization, dropout, early stopping
Loss is unstable or explodesLearning rate too highLower learning rate, gradient clipping
Training is very slowLearning rate too low or model too largeIncrease learning rate carefully, simplify model
Results change a lot across runsSeed sensitivityRun multiple seeds and report mean/std
DRL reward is noisyExploration or environment varianceTune ε, replay buffer, reward scaling
References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Takeaway

  • Training setup: seed and train/validation/test split make comparisons reproducible.
  • Optimization: learning rate, batch size, and epochs control how the model updates.
  • Generalization: bias, variance, overfitting, underfitting, and regularization explain unseen-data performance.
  • Deep RL: also track exploration, discount factor, replay buffer, and reward design.

Continue with Gradient Descent to build on this note.

References for this section3
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Check your understanding

0 of 4 answered

  1. What is learned during ordinary model fitting?

  2. With 1,000 training examples and batches of 128, how many updates per epoch if the last partial batch is kept?

  3. Training MSE is 0.01 while validation MSE is 0.50. What should you investigate first?

  4. What is the role of an untouched final test set?

Complete references and further reading

  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Model evaluation".