How CNNs learn to recognize images, patterns, and spatial features
Convolutional Neural Networks (CNNs) are specialized neural networks designed to process grid‑like data such as images. They automatically learn spatial features like edges, textures, shapes, and objects, making them essential for computer vision.
These layers apply filters (kernels) that slide across the image to detect features.
output = convolution(input, filter)
ReLU is the most common activation in CNNs.
Pooling reduces spatial size and keeps important features.
These layers perform classification after feature extraction.
from tensorflow import keras
from tensorflow.keras import layers
model = keras.Sequential([
layers.Conv2D(32, (3,3), activation="relu", input_shape=(28,28,1)),
layers.MaxPooling2D((2,2)),
layers.Conv2D(64, (3,3), activation="relu"),
layers.MaxPooling2D((2,2)),
layers.Flatten(),
layers.Dense(64, activation="relu"),
layers.Dense(10, activation="softmax")
])
model.compile(optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"])
print(model.summary())
Now that you understand CNNs, you're ready to explore sequence‑based models in Lesson 33: Recurrent Neural Networks (RNNs).
← Back to Lesson Index