Artificial neural networkParticle Swarm OptimisationBanknote authentication

Teaching a neural network by moving a swarm through its weights

A visual journey through the coursework implementation: four banknote image features, a configurable ANN, particles as flattened weight vectors, cross-entropy fitness, and the experiments that found the strongest configuration.

4 features

variance, skewness, curtosis, entropy

50 particles

final PSO implementation

99.12%

reported final average score

Particles move through possible ANN weights. The best candidates pull neighbors toward lower loss.

Journey map

From image features to optimized classifier

The project is easiest to understand as a pipeline. Each stage changes the object being optimized until the swarm can evaluate a complete ANN candidate.

1. Data

Banknote images become four numerical signals

The dataset starts as genuine and forged banknote-like specimens. A wavelet transform turns each image into variance, skewness, curtosis, and entropy, then the notebook splits those rows into 80% training and 20% testing.

The ANN only sees four standardized numbers per note. The visual problem becomes a compact binary classification problem.
X = df.iloc[:, 0:4].values
y = df.iloc[:, 4].values.reshape(-1, 1)

X_train, X_test, y_train, y_test = train_test_split(
  X, y, test_size=0.2, random_state=42
)

Data to decision

The banknote is reduced, scaled, and classified

The notebook uses StandardScaler so each feature contributes on a comparable scale. The final output is binary: authentic or counterfeit, represented by class 0 or 1 in the dataset.

Variance

x1

wavelet variance

How much transformed image intensity varies across regions.

Skewness

x2

wavelet skewness

Asymmetry in the transformed image distribution.

Curtosis

x3

wavelet curtosis

Tail behavior in the transformed image distribution.

Entropy

x4

image entropy

Information density in the source image.

ANN architecture

Change the layer shape and watch the search space change

Every added neuron creates more weights and biases for PSO to search. The winning story was not to make it huge; it was to give the network enough width without making the optimizer chase too many parameters.

49

weights + biases in vector

99.31%

reported average accuracy

input8 houtput

Biological inspiration

Why a flock helps explain Particle Swarm Optimisation

The flocking video shows complex group motion emerging from many local decisions. No single bird draws the whole shape, yet the group moves coherently because each individual responds to nearby motion and changing pressure.

Local sensing

PSO particles use neighborhood information instead of a central controller.

Individual memory

Each particle remembers its own best ANN weight vector.

Collective pull

Better neighbors pull the swarm toward lower-loss regions.

The analogy has a limit: this coursework does not simulate birds. It borrows the same principle of decentralized collective movement and applies it to a mathematical search through neural network weights.

Flocking as the visual intuition behind swarm search.Open video

Swarm mechanics

Tune the PSO forces and see the motion pattern change

This visualization is deterministic, but it mirrors the real PSO equation: inertia preserves motion, c1 pulls particles toward their own best position, and c2 pulls them toward a neighborhood best.

personal best pullneighborhood best pull
simulated convergence score: 62.9

PSO controls

Final reported PSO setting

50 particles, 60 iterations, neighborhood size 14, c1 = 3, c2 = 1, inertia = 0.5. The report records average accuracy 99.12% and standard deviation 0.0053 for the chosen PSO combination.

Experiment evidence

The work improved by running disciplined phases

Each experiment ran the ANN multiple times, then recorded average accuracy and standard deviation. The important lesson is the pattern across runs, not a single lucky score.

Activations

Leaky ReLU gave the best phase-1 score

The first phase held the network shape modest and changed only the hidden-layer activation. Leaky ReLU led the table and was carried into later PSO experiments.

Linear2.18%

No nonlinear separation.

Tanh46.18%

Better, but unstable here.

ReLU84.73%

Strong nonlinear baseline.

ELU53.82%

Moderate in these runs.

SELU53.82%

Similar to ELU here.

Leaky ReLU90.55%

Best phase-1 result and chosen for later experiments.

Final interpretation

What the technology demonstrates

The project is not just an ANN classifier. It demonstrates how biologically inspired optimization can train a model by population search, how each PSO knob affects exploration, and why extra model flexibility can hurt when it expands the search space faster than the optimizer can exploit it.

Best activation

Leaky ReLU avoided dead neurons and outperformed linear, tanh, ELU, SELU, and standard ReLU in phase 1.

Best search story

The final PSO balanced a larger swarm, local neighborhoods, stronger self pull, and moderate inertia.

Best model lesson

The wider single hidden layer was enough; deeper or encoded variants added complexity without clear benefit.