Skip to content

Machine learning basics

Neural networks and CNNs

How the models inside PetalEdge learning blocks work, explained without heavy maths.

On this page

The idea in one minute

A neural network is a stack of simple maths units called neurons, arranged in layers. Each neuron takes some numbers in, multiplies them by its weights, adds them up and passes the result on. Training means finding weights that make the network's answers correct.

  1. 1InputThe features of one example
  2. 2Hidden layersNeurons combine the numbers
  3. 3OutputOne score per label
A small neural network

Layers you will meet in PetalEdge

LayerWhat it does
Dense (fully connected)Every input connects to every neuron. Good for lists of features.
Convolution (1D or 2D)Slides a small filter along the data to find local patterns.
PoolingShrinks the data by keeping the strongest values, so the network gets smaller and faster.
DropoutDuring training, switches off some neurons at random so the model can't just memorise.
Batch normalisationKeeps the numbers in a steady range, which makes training more stable.
Softmax (output)Turns the final numbers into scores that add up to 1.

What is a CNN?

A convolutional neural network (CNN) uses convolution layers. A convolution is a small window of weights (a filter) that slides over the data and lights up when it sees a certain pattern.

  • A 1D convolution slides along time. It can spot a quick "flick" anywhere in a motion recording.
  • A 2D convolution slides over a grid. It can spot an edge in an image, or a shape in a sound spectrogram.

Because the same filter is used everywhere, a CNN finds a pattern no matter where it appears, and it needs fewer weights than a dense network.

Pre-trained models and transfer learning

Training a big network from zero needs a lot of data. Transfer learning starts from a network that was already trained on millions of everyday photos (the ImageNet dataset). It already knows edges, textures and shapes. Training then only adjusts it to your labels, so it works with far fewer examples.

A simple example

A Dense network for three motion labels might look like this:

LayerSizeWeights (approx.)
Input387 features–
Dense128 neurons387 × 128 ≈ 49,500
Dense64 neurons128 × 64 ≈ 8,200
Output3 scores64 × 3 = 192

That is about 58,000 weights. Each one is a number the training adjusts.

Where you use this in PetalEdge