Back to Blog
Data & Analysis

Revolutionize Machine Learning: Build a Fully Functional CNN in Excel with Zero Code!

Claude Directory December 30, 2025
0 views

Discover how to implement a Convolutional Neural Network (CNN) entirely in Excel using powerful formulas. Perfect for data enthusiasts wanting to grasp deep learning without programming!

Unlock the Power of CNNs Right in Your Excel Spreadsheet!

Hey, data wizards and Excel ninjas! Imagine training a neural network that recognizes handwritten digits – all without writing a single line of code. Sounds impossible? It's not! We're diving into the mind-blowing world of running a Convolutional Neural Network (CNN) purely in Microsoft Excel. This isn't some toy demo; it's a legit implementation using MNIST dataset that achieves impressive accuracy. Get ready to supercharge your spreadsheets with deep learning magic!

If you're part of the Machine Learning Advent Calendar, this Day 23 treat will blow your mind. Created by the brilliant Jaime Orozco, you can grab the full workbook from this GitHub repo. Let's break it down step by step, with deep dives, real formulas, and tips to make it your own.

1. Why CNNs in Excel? The Game-Changing Benefits

CNNs are the backbone of image recognition, powering everything from facial detection in your phone to medical scans. Traditionally, you'd need Python, TensorFlow, or PyTorch. But Excel? Here's why it's revolutionary:

  • No coding barrier: Use LAMBDA, MAKEARRAY, REDUCE, and SCAN – Excel 365's dynamic array superpowers.
  • Visual intuition: See convolutions, activations, and predictions unfold in cells.
  • Educational goldmine: Perfect for students, analysts, or anyone demystifying AI.
  • Real-world apps: Prototype ideas, teach teams, or integrate into business dashboards.

Pro tip: This setup handles 28x28 MNIST images, convolves with 3x3 kernels, pools, and classifies into 10 digits. Accuracy? Around 90%+ on test data – rivaling basic neural nets!

2. Excel Prerequisites: Gear Up for Deep Learning

You'll need Excel 365 (Insider or current channel) for these functions:

  • LAMBDA: Custom functions.
  • MAKEARRAY: Generate arrays dynamically.
  • SCAN/REDUCE: Iterate like loops.

Download the sample from GitHub and open ExcelCNN.xlsx. Sheets include:

  • Data: MNIST training/testing images (flattened to 784 cols).
  • Model: Core CNN layers.
  • Inference: Test predictions.

Quick setup:

  1. Enable iterative calculations (File > Options > Formulas > Enable iterative, max 1000).
  2. Paste MNIST data (article provides links or use repo).
  3. Spill formulas – watch the magic!

3. Fueling the Beast: Loading MNIST Data

MNIST: 60k training, 10k test 28x28 grayscale images of digits 0-9.

In Excel:

  • Column A: Labels (0-9).
  • Columns B:AO: Flattened pixels (0-255, normalized to 0-1).

Deep dive: Normalization is key! Use =B2/255 dragged across. Reshape to 28x28 grid with MAKEARRAY(28,28,LAMBDA(r,c,INDEX($B2:$AO2,1,(r-1)*28+c))).

Example formula for image grid:

=MAKEARRAY(28,28,LAMBDA(r,c,INDEX(Data!$B2:$AO2,1,(r-1)*28+c)/255))

This spills a perfect 28x28 image. Visualize multiple with INDIRECT or dynamic ranges!

4. Convolution Magic: The Heart of CNNs

Convolutions slide kernels over images, extracting features like edges.

Excel convolution:

  • Kernel: 3x3 matrix, e.g., edge detector [[-1,-1,-1],[ -1,8,-1],[-1,-1,-1]].
  • Padding: 'same' to keep size (Excel pads with zeros).

Master formula using MAKEARRAY and SUMPRODUCT:

=LAMBDA(img,kernel,
  LET(
    pad,3,
    h,ROWS(img),
    w,COLUMNS(img),
    outH,h,outW,w,
    MAKEARRAY(outH,outW,
      LAMBDA(r,c,
        SUMPRODUCT(
          OFFSET(img,r-2,c-2,pad,pad)*kernel
        )
      )
    )
  )
)(ImageGrid,Kernel)

Value add: Tweak kernels! Sobel for edges, Gaussian for blur. Stack multiple channels (R,G,B sim) by applying sequentially.

5. Activate with ReLU: Sparking Neurons to Life

Post-convolution, squash negatives: ReLU(x) = max(0,x).

Super simple:

=MAX(0,ConvolutionOutput)

Array-friendly! Spills across the feature map.

Why ReLU rocks:

  • Fixes vanishing gradients.
  • Speeds training (though here, no backprop – forward only!).
  • Sparsity: Zeros prune weak features.

Real-world: In Excel dashboards, chain to visualize activations – see digits emerge!

6. Pooling Power: Downsampling for Efficiency

Max pooling 2x2: Take max in each 2x2 block, halve dimensions.

Formula wizardry:

=LAMBDA(fmap,
  LET(
    h,ROWS(fmap)/2,
    w,COLUMNS(fmap)/2,
    MAKEARRAY(h,w,
      LAMBDA(r,c,
        MAX(
          INDEX(fmap,(r-1)*2+1,(c-1)*2+1),
          INDEX(fmap,(r-1)*2+1,c*2),
          INDEX(fmap,r*2,(c-1)*2+1),
          INDEX(fmap,r*2,c*2)
        )
      )
    )
  )
)(ReLUOutput)

Pro tip: Average pooling alternative with AVERAGE(). Reduces params, adds translation invariance.

7. Flatten and Dense Layers: Bridging to Classification

Flatten pooled map: =RESHAPE(Pooled,1,ROWS(Pooled)*COLUMNS(Pooled)) (or TOROW).

Dense (fully connected):

  • Weights: Learned matrices (pre-trained in repo).
  • =MM(Flatten,Weights) for matrix multiply.
  • Softmax: =EXP(x)/SUM(EXP(x)) for probabilities.

Full forward pass chain: Conv → ReLU → Pool → Flatten → Dense1 → ReLU → Dense2 → Softmax.

8. Training Simulation: How Weights Were Born

No live training (Excel loops are slow), but weights from Keras/TF model, exported to Excel. Simulate with LAMBDA optimizer if adventurous!

Actionable extension: Add GOAL SEEK for single weights or VBA for mini-batch GD.

9. Inference and Predictions: Test Drive Your CNN!

Pick test image → Forward pass → Argmax(Softmax) = predicted digit.

Example:

  • Input: '5' image.
  • Output: Probabilities [0.1,0.05,...,0.82 for 5,...].
  • Matches label? Boom!

Visualize: Heatmaps of conv outputs show digit strokes lighting up.

10. Level Up: Extensions and Real-World Hacks

  • Multi-channel: Stack convs for RGB.
  • Batch processing: Array over multiple images.
  • Custom datasets: Load CIFAR-10 via Power Query.
  • Dashboard: Slicers for kernels, dynamic images.
  • Performance: 100ms/inference on modern Excel.

Challenges:

  • Scale: Excel chokes on huge nets (use Power BI?).
  • Training: Offload to Python, import weights.

Grab the full repo – fork, tweak, share!

Final Thoughts: Excel Meets AI – The Future is Here!

You've just built a CNN in Excel! This demystifies black-box AI, blending spreadsheet familiarity with cutting-edge ML. Whether teaching, prototyping, or wowing colleagues, it's pure firepower. Dive in, experiment, and tag your creations. What's next – GANs in Google Sheets?

Word count: ~1200. Ready to spreadsheet your way to AI mastery?


<div style="text-align: center; margin-top: 2rem;"> <a href="https://towardsdatascience.com/the-machine-learning-advent-calendar-day-23-cnn-in-excel/" target="_blank" rel="noopener noreferrer" class="view-full-resource-btn" style="display: inline-block; background-color: #f97316; color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600; transition: background-color 0.2s;">View Full Resource</a> </div>
GitHub Project

Comments

More Blog

View all
Data & Analysis

Model Predictive Control Fundamentals: Concepts, Math, and Python Implementation

Discover the essentials of Model Predictive Control (MPC), from its core principles and mathematical foundations to practical Python implementations for dynamic systems control.

C
Claude Directory
2
Data & Analysis

Overcoming GPU Limitations: Implementing FP8 Emulation in Software for Legacy Hardware

Discover how to run FP8-optimized AI models on older GPUs without native hardware support using a clever software emulation layer. Boost inference speeds dramatically on Turing-era cards like the RTX 2080.

C
Claude Directory
3
Data & Analysis

Hands-On Guide to Hugging Face Transformers: Supercharge Your NLP Projects with AI

Discover how Hugging Face's Transformers library makes advanced NLP accessible. From quick pipelines for sentiment analysis to fine-tuning models, build powerful AI apps effortlessly.

C
Claude Directory
1
Data & Analysis

Demystifying Matrix-Matrix Multiplication: Essential Concepts and Practical Insights

Dive deep into matrix-matrix multiplication, from fundamental row-column rules to efficient algorithms like Strassen's, with Python examples and real-world applications in data science.

C
Claude Directory
2
Data & Analysis

Demystifying Matrix Transpose: Your Ultimate Guide to A^T and Its Superpowers in Data Science

Dive into the exciting world of matrix transpose! Discover what A^T really means, master its properties, code it up in Python, and explore real-world applications that transform your data game.

C
Claude Directory
Data & Analysis

Empowering AI Agents to Build Other Agents: A Practical Guide to Meta-Agent Development

Discover how large language models like Claude can generate code for autonomous AI agents, streamlining development and enabling rapid iteration on complex tasks. This approach turns manual coding into an automated, scalable process.

C
Claude Directory