<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj" -->

---
title: SPP-Net Paper Walkthrough: Breaking the Fixed-Size...
description: SPP-Net solves the fixed-size input constraint of conventional CNNs by inserting a Spatial Pyramid Pooling layer between the convolutional stack and...
canonical: https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: SPP-Net Paper Walkthrough: Breaking the Fixed-Size Constraint | daily.dev
og:description: SPP-Net solves the fixed-size input constraint of conventional CNNs by inserting a Spatial Pyramid Pooling layer between the convolutional stack and...
og:url: https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj
og:image: https://api.daily.dev/og/posts/Q5NkoIkyJ.png
og:image:alt: SPP-Net Paper Walkthrough: Breaking the Fixed-Size Constraint
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SPP-Net Paper Walkthrough: Breaking the Fixed-Size Constraint

**[Towards Data Science](https://daily.dev/sources/tds)** · 20 min read · 0 upvotes · 0 comments

## Summary

SPP-Net solves the fixed-size input constraint of conventional CNNs by inserting a Spatial Pyramid Pooling layer between the convolutional stack and fully-connected layers. The SPP layer applies adaptive max pooling at multiple grid resolutions (4×4, 2×2, 1×1), flattens and concatenates the results into a fixed-length vector regardless of input image size. The post covers the theory behind SPP, its advantages (overfitting resistance, translation invariance, variable-resolution training), its 38× speed advantage over R-CNN on object detection at equal mAP, and a complete from-scratch PyTorch implementation of the ZF-5 backbone with SPP.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdatascience.com/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint>

## Questions this post answers

### Why does a CNN require fixed-size input images and how does SPP-Net fix that?

The fixed-size constraint comes from the fully-connected layers, not the convolutional layers. Conv layers use shared weights across spatial dimensions and naturally handle any input size, but FC layers require a fixed number of inputs. SPP-Net inserts a Spatial Pyramid Pooling layer between the conv stack and FC layers, applying adaptive max pooling at multiple grid resolutions (4×4, 2×2, 1×1) and concatenating the results into a fixed-length vector regardless of input size.

_Engineers adapting CNN architectures to variable-resolution inputs find the relevant tradeoffs covered on daily.dev._

### How much faster is SPP-Net compared to R-CNN for object detection?

SPP-Net is 38× faster than R-CNN while achieving the same mAP of 59.2. The speedup comes from running the CNN feature extractor only once on the full image, then classifying ~2000 bounding box candidates from the resulting feature map using SPP and FC layers — eliminating the repeated per-candidate CNN forward passes that make R-CNN slow. Single-scale inference pushes the speedup beyond 100× with a small mAP trade-off.

_Keeping up with object detection architecture benchmarks and trade-offs is easier when daily.dev surfaces the relevant papers and implementations._

### How do I implement a Spatial Pyramid Pooling layer in PyTorch?

Use `F.adaptive_max_pool2d(x, output_size=(grid, grid))` for each grid size (e.g., 4, 2, 1), flatten each result with `torch.flatten(pooled, start_dim=1)`, then concatenate all flattened tensors along dim=1. The SPP class needs no trainable parameters — only a `forward()` method. For a 256-channel feature map with grids [4,2,1], the output vector length is 256 × (16+4+1) = 5376.

_Developers building or adapting CNN architectures in PyTorch track implementation patterns like this on daily.dev._

## Similar posts on daily.dev

- [PANet Paper Walkthrough: When Feature Pyramids Go Bottom-Up](https://daily.dev/posts/panet-paper-walkthrough-when-feature-pyramids-go-bottom-up-wbnvzuic7) · Towards Data Science · 0 upvotes · 0 comments
- [CSPNet Paper Walkthrough: Just Better, No Tradeoffs](https://daily.dev/posts/cspnet-paper-walkthrough-just-better-no-tradeoffs-fqrnxz0s3) · Towards Data Science · 1 upvotes · 0 comments
- [Multi-Scale Physics-Constrained Neural Networks](https://daily.dev/posts/multi-scale-physics-constrained-neural-networks-xk9memtzw) · Medium · 0 upvotes · 0 comments
- [Accelerating Spatio-Temporal Attention for Video Diffusion on TPUs](https://daily.dev/posts/accelerating-spatio-temporal-attention-for-video-diffusion-on-tpus-by8crmpum) · Google Developers · 0 upvotes · 0 comments
- [NDSS 2025 – A New PPML Paradigm For Quantized Models](https://daily.dev/posts/ndss-2025-a-new-ppml-paradigm-for-quantized-models-chntrd1jv) · Security Boulevard · 0 upvotes · 0 comments

---

Tags: [#deep-learning](https://daily.dev/tags/deep-learning), [#computer-vision](https://daily.dev/tags/computer-vision), [#pytorch](https://daily.dev/tags/pytorch), [#object-detection](https://daily.dev/tags/object-detection)

[View this post on daily.dev](https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"SPP-Net Paper Walkthrough: Breaking the Fixed-Size Constraint","url":"https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj"},"datePublished":"2026-08-10T12:35:50.319Z","dateModified":"2026-08-10T12:36:21.831Z","description":"SPP-Net solves the fixed-size input constraint of conventional CNNs by inserting a Spatial Pyramid Pooling layer between the convolutional stack and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/47f1fb181ea07695413c7360f36229e8?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/47f1fb181ea07695413c7360f36229e8?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Towards Data Science","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Data Science","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/tds","url":"https://daily.dev/sources/tds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"deep-learning,computer-vision,pytorch,object-detection","timeRequired":"PT20M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Data Science","item":"https://daily.dev/sources/tds"},{"@type":"ListItem","position":3,"name":"SPP-Net Paper Walkthrough: Breaking the Fixed-Size Constraint"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/spp-net-paper-walkthrough-breaking-the-fixed-size-constraint-q5nkoikyj#faq","mainEntity":[{"@type":"Question","name":"Why does a CNN require fixed-size input images and how does SPP-Net fix that?","acceptedAnswer":{"@type":"Answer","text":"The fixed-size constraint comes from the fully-connected layers, not the convolutional layers. Conv layers use shared weights across spatial dimensions and naturally handle any input size, but FC layers require a fixed number of inputs. SPP-Net inserts a Spatial Pyramid Pooling layer between the conv stack and FC layers, applying adaptive max pooling at multiple grid resolutions (4×4, 2×2, 1×1) and concatenating the results into a fixed-length vector regardless of input size. Engineers adapting CNN architectures to variable-resolution inputs find the relevant tradeoffs covered on daily.dev."}},{"@type":"Question","name":"How much faster is SPP-Net compared to R-CNN for object detection?","acceptedAnswer":{"@type":"Answer","text":"SPP-Net is 38× faster than R-CNN while achieving the same mAP of 59.2. The speedup comes from running the CNN feature extractor only once on the full image, then classifying ~2000 bounding box candidates from the resulting feature map using SPP and FC layers — eliminating the repeated per-candidate CNN forward passes that make R-CNN slow. Single-scale inference pushes the speedup beyond 100× with a small mAP trade-off. Keeping up with object detection architecture benchmarks and trade-offs is easier when daily.dev surfaces the relevant papers and implementations."}},{"@type":"Question","name":"How do I implement a Spatial Pyramid Pooling layer in PyTorch?","acceptedAnswer":{"@type":"Answer","text":"Use `F.adaptive_max_pool2d(x, output_size=(grid, grid))` for each grid size (e.g., 4, 2, 1), flatten each result with `torch.flatten(pooled, start_dim=1)`, then concatenate all flattened tensors along dim=1. The SPP class needs no trainable parameters — only a `forward()` method. For a 256-channel feature map with grids [4,2,1], the output vector length is 256 × (16+4+1) = 5376. Developers building or adapting CNN architectures in PyTorch track implementation patterns like this on daily.dev."}}]}
```

