Signals to learning / 7. Neural building blocks

Lesson 27 of 40 · Intermediate · About 30 minutes

Convolutions in neural networks

How does one learned filter scan an entire representation?

You will be able to

  • Explain parameter sharing and channel mixing.
  • Calculate a one-dimensional convolution-layer output length.

A reusable local detector

A neural convolution layer typically applies cross-correlation with a learned kernel at each location. Sharing that kernel reduces parameter count compared with a separate dense weight for every location. Multiple input channels are summed with their kernel slices; multiple output channels use different learned filters.

Equivariance has conditions

A stride-one shared operator on an unbounded grid is translation-equivariant: shift the input and the output shifts. Finite padding, stride, pooling and boundaries complicate that statement. It is not the same as translation invariance, which would mean the output stays unchanged. The lab shows a DSP convolution with a symmetric kernel, not a trained CNN.

L_out = floor((L_in+2P−D(K−1)−1)/S)+1

Worked example

For input length 10, kernel size 3, padding 0, dilation 1 and stride 2, output length is floor((10−3)/2)+1=4. A layer with 2 input channels, 3 output channels and K=3 has 18 kernel weights plus 3 biases.

A common trap

“Convolution” in an ML library often means cross-correlation. Check indexing rather than relying on the name.

Predict, then experiment

Does applying the same kernel at different indices require a different set of learned weights? Before touching the controls, say or write your prediction.

Interactive experiment

One output, multiply by multiply

Which input values contribute to one sample of a three-tap smoothing filter?

Blue is the input and dashed amber is the full output. The moving window and filled blue points show the samples under the kernel; the large amber point is the selected output. The fixed kernel is [0.25, 0.5, 0.25].

Your experiment

Move the output index and inspect the repeated coefficients. Explain what parameter sharing would mean if these coefficients were learned; then identify what a second output channel would need.

Change one parameter at a time. Compare what you observed with your prediction and record an explanation in your notes.

Check your understanding

Try from memory first. Hints and feedback are part of learning, not a penalty. These checks are for self-study, not a graded qualification.

1. Translation equivariance means…
Give me a hint

Distinguish moving the output from leaving it unchanged.

2. For length 10, kernel 3, stride 2, no padding and dilation 1, what is output length?

Accepted absolute tolerance: ±0.001 positions.

Give me a hint

Only count fully valid kernel positions.

Reference answers (after your attempt)
  1. the output shifts when the input shifts — Correct under the operator’s stated grid/stride assumptions.
  2. 4positions — floor((10−3)/2)+1=4.

Apply it: Audit a layer shape

Use paper, your notes, or a local notebook/editor. Code examples are Python 3 starting points to run yourself; this page does not execute code or automatically assess the practical task.

  1. For L=16,K=3,P=1,S=1,D=1, compute output length.
  2. For 2 input/4 output channels, compute weights and biases.
  3. State the convolution/correlation and padding convention.
Reference solution & review criteria

Output length is 16. Weights=4×2×3=24, biases=4. A conventional CNN cross-correlates without reversal; zero padding and channel layout must be recorded.

Your notebook

Notes and progress stay in this browser. They are not sent to the server; ordinary web-server request logs still operate. Export a backup from the course page.

Review list

Completion requires both correct checks and your practical-task acknowledgement.

Go deeper

Sources support further study; the worked examples and questions here are original. Browser experiments are small, disclosed models—not evidence of production-model quality or hardware performance.