AI Fundamentals
What are CNNs (Convolutional Neural Networks)?
A convolutional neural network (CNN) is a neural-network architecture that uses learned filters across local regions of an input. CNNs became foundational to modern computer vision because they can detect patterns regardless of where those patterns appear and reuse the same parameters across an image.
A CNN does not convert an image from non-numerical to numerical form—the image already arrives as a tensor of pixel values. Its purpose is to transform that tensor into feature maps that are useful for classification, detection, segmentation, or another task.
Key takeaways
- A convolution combines local input values with a learned kernel to produce a feature map.
- Stride, padding, dilation, and pooling control spatial resolution and receptive field.
- Weight sharing makes CNNs more parameter-efficient than a fully connected network over raw pixels.
- Vision transformers offer an alternative, but CNNs remain strong for efficient and data-constrained systems.

How convolution works
A kernel is a small grid of trainable weights. At each position, the CNN multiplies the kernel values by the corresponding input values, sums the results, and usually adds a bias. Repeating this across the input produces a feature map.
For a color image, a kernel spans all input channels. A layer uses multiple kernels to create multiple output channels. During training, backpropagation computes gradients for these kernel weights; the convolution operation does not manufacture a new fixed set of weights from each image.
Stride, padding, and dilation
- Stride controls how far the kernel moves. A stride greater than one reduces spatial resolution.
- Padding adds values around an input so border information can be processed and output size can be controlled.
- Dilation spaces kernel elements apart, expanding the receptive field without proportionally increasing parameters.
The receptive field is the region of the original input that can influence a unit. Stacking convolutions expands it, allowing later features to combine information from broader areas.
Activation, normalization, and pooling
Convolutional layers are commonly followed by nonlinear activations and normalization. Pooling summarizes local regions using an operation such as maximum or average. Learned strided convolutions can also downsample.
Pooling is not mandatory. Many modern networks use global average pooling near the output instead of flattening a large feature map into a fully connected stack. This reduces parameters and lets the network aggregate spatial evidence.
A modern CNN architecture
A typical vision model contains a stem, a sequence of feature blocks, downsampling stages, and a task head. Residual connections let a block learn a modification to its input and provide a direct route for information and gradients. The success of residual networks made it practical to train much deeper CNNs.
Classification heads produce class scores. Detection heads predict categories and boxes. Segmentation architectures add decoder paths that recover spatial detail. The same CNN backbone can be reused through transfer learning.
What CNN layers learn
It is common to visualize early filters that respond to edges or textures and later representations that correlate with parts or objects. This is a useful intuition, but it is not a fixed rule. Features depend on the task, architecture, data, objective, and training process, and some units combine information that does not map neatly to a human concept.
CNNs versus vision transformers
Vision transformers divide images into patches and use attention to model relationships among them. They can scale effectively with large pretraining datasets. CNNs build locality and translation-related assumptions directly into the architecture, which can make them more efficient and data-effective in smaller settings.
Many practical systems combine convolution and attention. The right architecture depends on accuracy, latency, memory, training data, hardware, and deployment—not on which family is newest.
Limitations and practical considerations
CNNs can be sensitive to distribution shift, adversarial perturbations, background shortcuts, and biased training data. They are not perfectly invariant to position, rotation, scale, or viewpoint. Augmentation and architecture choices can improve robustness but do not guarantee it.
For deployment, measure end-to-end latency, memory, throughput, and subgroup behavior. Quantization and pruning can reduce cost, especially for edge AI, but compressed models must be revalidated.
Convolution, receptive fields, and modern CNN blocks
A convolutional layer slides learned kernels across a grid and shares weights across positions. Kernel size, stride, dilation, and padding determine output shape and receptive field. Early layers often respond to local edges or textures; deeper layers combine information over larger regions, though learned representations need not map cleanly to human concepts. Pooling or strided convolution reduces spatial resolution. Channels carry feature maps, while grouped and depthwise separable convolution trade cross-channel mixing for lower compute. Residual connections make very deep networks easier to optimize.
For an input height and width, padding controls boundary treatment and stride controls sampling. Aggressive downsampling can erase small objects; zero padding can create edge artifacts; dilation expands context without the same parameter growth but can produce gridding. Batch normalization depends on training statistics, while alternatives may behave better at small batch sizes. Modern architectures combine bottlenecks, multi-scale features, attention, or inverted residuals. Select architecture using task resolution, memory bandwidth, latency, and target hardware rather than image-classification accuracy alone.
Training, interpretation, and deployment
Use augmentations that preserve labels and reflect real variation, and split by subject or scene before augmentation. Transfer learning is common: replace the task head, train it, then cautiously unfreeze the backbone. Evaluate class-specific performance, calibration, robustness to blur, compression, lighting, scale, crop, and adversarial perturbation. Visualization methods such as feature maps and saliency can reveal shortcuts, but they are sensitive to method and baseline. Confirm suspected reliance with counterfactual images, occlusion tests, or dataset changes.
Exported CNNs may be fused, quantized, or compiled for GPU, NPU, browser, or microcontroller. Validate the deployed graph, including preprocessing and postprocessing, on exact devices. Measure end-to-end latency, memory, energy, and thermal behavior; input decode may dominate a small model. Monitor camera and image statistics, output distribution, and confirmed errors. Signed model artifacts, protected update channels, and graceful sensor failure are part of production design. CNNs encode a useful locality bias, but they do not automatically understand objects or causal scenes.
Worked example: deploying a CNN on an inspection camera
A CNN classifies surface defects from high-resolution line-scan images. Engineers tile images with overlap so small defects survive downsampling, preserve coordinates for review, and validate augmentations against real optical variation. A residual CNN and a lighter depthwise model are compared at equal recall. Tests include edge defects, glare, compression, motion, material batches, and camera replacements, with independent production lots reserved for final evaluation.
Compilation fuses and quantizes the model for an edge accelerator, but the deployed graph is compared against the reference on sensitive defect cases. Decode, tiling, inference, and merge latency are measured end to end. The system flags dead pixels and exposure drift separately from product defects. Operators can inspect source tiles and override results. Model and camera changes roll out gradually, and the line retains a safe manual inspection procedure when the vision pipeline is unavailable.
Implementation evidence and operational readiness
A production decision needs more than a successful demonstration. Define the intended users, operating environment, inputs, outputs, dependencies, owner, and the consequence of each important failure. Establish a reproducible baseline and a versioned evaluation set before tuning. Test ordinary cases, boundary conditions, malformed or missing input, distribution shift, dependency outage, misuse, and the groups or environments most likely to be underserved. Measure task quality together with calibration or uncertainty, latency, throughput, resource cost, accessibility, privacy, and security. Record every transformation and threshold so an independent reviewer can reproduce the result and distinguish evidence from an attractive prototype.
Before launch, assign authority for release, exceptions, changes, rollback, and retirement. Use a staged rollout, preserve a safe fallback, and verify monitoring with deliberately injected failures. Operational telemetry should reveal input quality, output behavior, model or rule version, dependency health, human overrides, and confirmed outcomes without collecting unnecessary sensitive data. Define alert thresholds and a response owner, then review real-world evidence after deployment rather than assuming offline performance will persist. Reevaluate whenever data sources, users, models, vendors, policies, hardware, or objectives change. A maintained system also needs documented recovery, incident learning, deletion and retention procedures, and a clear point at which it should be disabled or replaced.
Frequently asked questions
Does a CNN always need pooling?
No. A CNN can downsample with strided convolution and can preserve resolution for dense prediction. Pooling is one design tool rather than a defining requirement.
Are CNN filters hand-designed?
In a trained CNN, kernel values are normally learned from data. This differs from classical vision filters whose coefficients are chosen in advance for operations such as edge detection.












