Machine Learning
Deep Learning
Convolutional Neural Networks

Convolutional Neural Networks (CNNs)

CNNs excel at processing spatial data like images through local feature detection and hierarchical pattern recognition. In financial services, they analyze documents and signatures for fraud detection. In retail, they enable visual search, inventory management, and automated quality control.

Mathematical Foundation

Convolution Operation

The core operation that detects local patterns:

For 2D Images:

Symbol Definitions:

  • [mathematical expression] = Feature map output at position [mathematical expression] (detected feature)
  • [mathematical expression] = Input image pixel at position [mathematical expression] (raw data)
  • [mathematical expression] = Kernel/filter weight (learned feature detector)
  • [mathematical expression] = Convolution operator (sliding window operation)
  • [mathematical expression] = Output position coordinates
  • [mathematical expression] = Input position coordinates

Feature Map Computation

Complete convolution layer with bias and activation:

Symbol Definitions:

  • [mathematical expression] = Output feature map at position [mathematical expression] for filter [mathematical expression]
  • [mathematical expression] = Input at spatial position [mathematical expression] channel [mathematical expression]
  • [mathematical expression] = Weight for filter [mathematical expression] at position [mathematical expression] channel [mathematical expression]
  • [mathematical expression] = Bias term for filter [mathematical expression]
  • [mathematical expression] = Activation function (typically ReLU)
  • [mathematical expression] = Number of input channels, [mathematical expression] = Filter dimensions

CNN Architecture Components

Pooling Operation

Reduces spatial dimensions while preserving important features:

Max Pooling:

Average Pooling:

Symbol Definitions:

  • [mathematical expression] = Pooled output at position [mathematical expression] (downsampled feature)
  • [mathematical expression] = Stride/pooling window size (reduction factor)
  • [mathematical expression] = Local window coordinates
  • [mathematical expression] = Input within pooling window

Receptive Field

The input region that influences each output neuron:

Symbol Definitions:

  • [mathematical expression] = Receptive field size at layer [mathematical expression]
  • [mathematical expression] = Kernel size at layer [mathematical expression]
  • [mathematical expression] = Stride at layer [mathematical expression]
  • [mathematical expression] = Product of all previous strides

Financial Services Example: Check Fraud Detection

Business Context: A bank uses CNNs to automatically detect fraudulent checks by analyzing visual patterns, signatures, and document authenticity in real-time.

Input: Check images (224×224×3 RGB pixels)

CNN Architecture:

Layer 1 - Edge Detection:

  • Filters: 32 filters of size 5×5
  • Output: 220×220×32 feature maps
  • Purpose: Detect edges, lines, and basic shapes

Layer 2 - Pattern Recognition:

  • Filters: 64 filters of size 5×5
  • Output: 216×216×64 feature maps
  • Purpose: Combine edges into patterns

Pooling Layer:

  • Output: 108×108×64
  • Purpose: Reduce spatial dimensions, increase translation invariance

Higher-Level Features:

  • Filters: 128 filters of size 3×3
  • Output: 106×106×128
  • Purpose: Detect complex patterns like signatures, fonts

Global Features:

Symbol Definitions:

  • [mathematical expression] = Global Average Pooling (spatial summary)
  • [mathematical expression] = Spatial dimensions of final feature map
  • [mathematical expression] = All channels at spatial position [mathematical expression]

Classification Layer:

Fraud Detection Features Learned:

  1. Signature Analysis: Unusual pen pressure, stroke patterns
  2. Font Consistency: Inconsistent character spacing or style
  3. Paper Texture: Non-standard paper or printing quality
  4. Alteration Detection: Erasure marks, overwriting patterns

Business Impact:

  • Accuracy: 98.5% fraud detection rate
  • Processing Speed: 1,000 checks per second
  • Cost Reduction: 25M annual savings from prevented fraud
  • False Positive Rate: Reduced from 2% to 0.3%

Retail Example: Visual Product Search and Quality Control

Business Context: A fashion retailer uses CNNs for visual product search, allowing customers to upload photos and find similar items, plus automated quality control in manufacturing.

Visual Product Search System

Input Processing:

Feature Extraction Network:

Convolutional Layers:

Feature Embedding:

Symbol Definitions:

  • [mathematical expression] = Query image embedding vector (product representation)
  • [mathematical expression] = Unit vector normalization for similarity comparison
  • [mathematical expression] = Feature map at layer [mathematical expression]

Similarity Computation:

Top-K Product Retrieval:

Symbol Definitions:

  • [mathematical expression] = Total catalog size (number of products)
  • [mathematical expression] = Number of similar products to return
  • [mathematical expression] = Select top-k highest similarity scores

Quality Control System

Defect Detection Network:

Multi-Scale Feature Extraction:

Feature Fusion:

Defect Classification:

Quality Classes:

  • Perfect (Class 0): No defects detected
  • Minor Defects (Class 1): Small stitching issues, minor color variations
  • Major Defects (Class 2): Significant flaws requiring rejection

Loss Function (Multi-Class Cross-Entropy):

Symbol Definitions:

  • [mathematical expression] = True label for class [mathematical expression] (one-hot encoded)
  • [mathematical expression] = Predicted probability for class [mathematical expression]

Business Applications:

1. Automated Inspection Pipeline:

2. Search Recommendation Scoring:

Symbol Definitions:

  • [mathematical expression] = Weighting coefficients for ranking factors
  • [mathematical expression] = Historical click-through rate
  • [mathematical expression] = Price range compatibility score

Business Impact:

  • Search Accuracy: 92% customer satisfaction with visual search results
  • Quality Control: 99.2% defect detection accuracy
  • Processing Speed: 50 items per second automated inspection
  • Cost Savings: 60% reduction in manual quality control labor
  • Customer Experience: 40% increase in product discovery through visual search

Advanced CNN Techniques

Transfer Learning

Leveraging pre-trained models for domain adaptation:

Symbol Definitions:

  • [mathematical expression] = Features from large-scale pre-trained model
  • [mathematical expression] = Target domain dataset (financial/retail specific)
  • [mathematical expression] = Small learning rate for fine-tuning

Data Augmentation

Increasing training data diversity through transformations:

Symbol Definitions:

  • [mathematical expression] = Set of transformations (rotation, scaling, brightness)
  • [mathematical expression] = Transformed version of image [mathematical expression]
  • [mathematical expression] = Expanded training dataset

Common Transformations:

  • Rotation: [mathematical expression]
  • Scaling: [mathematical expression]
  • Color Jittering: [mathematical expression]

Performance Optimization

Batch Normalization

Normalizes layer inputs for stable training:

Symbol Definitions:

  • [mathematical expression] = Normalized input for sample [mathematical expression]
  • [mathematical expression] = Batch mean (computed across batch dimension)
  • [mathematical expression] = Batch variance
  • [mathematical expression] = Small constant for numerical stability

Depthwise Separable Convolutions

Efficient computation for mobile/edge deployment:

Computational Savings:

Symbol Definitions:

  • [mathematical expression] = Spatial dimensions
  • [mathematical expression] = Input channels, [mathematical expression] = Output channels
  • [mathematical expression] = Kernel size

CNNs revolutionize visual processing in both financial services and retail by automatically learning hierarchical feature representations, enabling sophisticated pattern recognition for fraud detection, product search, and quality control applications.