Free course · Lesson 2 of 5
Convolutional Neural Networks (CNNs) for Computer Vision
In this lesson you will
- Explain what a convolution filter does
- Describe the layers of a CNN
CNNs are specialized neural networks for image data. Instead of feeding raw pixels into a dense layer, CNNs use convolutional layers that slide small filters (kernels) across the image to detect features — edges, textures, shapes — at different scales. Pooling layers (like MaxPooling) downsample the image, keeping important features while reducing computation. This makes CNNs ideal for infrastructure inspection, flood mapping from satellite imagery, and medical image analysis.
Conv2Dlayer: applies learnable filters to detect visual patterns (edges, corners).MaxPool2Dlayer: reduces image size, makes the model robust to small shifts.- CNNs automatically learn hierarchical features — from simple edges to complex objects.
- Train on Google Colab with GPU acceleration; visualize filters with Matplotlib.
💡 Practical Skill: Apply CNNs to satellite imagery for flood damage assessment or road condition monitoring in South Sudan. Use TensorFlow or PyTorch with Jupyter Notebooks to iterate quickly.
# Building a CNN feature extractor using TensorFlow/Keras# Shows how Conv2D and MaxPool2D layers work together import tensorflow as tf # Build a CNN pipeline (just the feature extraction part)cnn_pipeline = tf.keras.Sequential([ # First Conv2D: 32 filters, each 3x3, looking for edges and textures tf.keras.layers.Conv2D( filters=32, kernel_size=(3, 3), activation='relu', input_shape=(64, 64, 1) ), # MaxPool2D: reduces size from 64x64 to 32x32, keeps strongest features tf.keras.layers.MaxPool2D(pool_size=(2, 2)), # Second Conv2D: 64 filters, detects more complex shapes tf.keras.layers.Conv2D( filters=64, kernel_size=(3, 3), activation='relu' ), # MaxPool2D: reduces from 32x32 to 16x16 tf.keras.layers.MaxPool2D(pool_size=(2, 2)), # Flatten: converts 2D feature maps into a 1D vector for the classifier tf.keras.layers.Flatten(), # Dense layer: makes the final decision (e.g., "flooded" vs "not flooded") tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid')]) # Print a summary of the architecturecnn_pipeline.summary() print("\n\u2705 CNN pipeline built! The model will automatically learn")print(" to detect edges \u2192 shapes \u2192 objects from image data.")
Practice exercise
Apply the filter [[1, 0, −1], [1, 0, −1], [1, 0, −1]] to a patch whose three rows are each [2, 5, 8] and say what the result means.
Key takeaways
- Images are grids of numbers in one or three channels
- Filters detect patterns such as edges and are learned from data
- Pooling shrinks feature maps and adds tolerance to small shifts
Free self-study lesson — no certificate. For the full instructor-led program, see registration options.