DenseNet and EfficientNet
3.4.10· AI-ML › Convolutional Neural Networks
Overview
Do landmark architectures jo CNN design ko revolutionize kar gaye: DenseNet dense connections ke through feature reuse maximize karta hai, jabki EfficientNet networks ko systematically scale karta hai optimal accuracy-efficiency tradeoff ke liye.

DenseNet: Dense Convolutional Networks
Dense block mein layer ke liye:
jahan channel dimension ke saath concatenation denote karta hai, aur ek composite function hai: BN → ReLU → Conv3×3.
Ye kyun important hai:
- Gradient highway: Gradients directly early layers tak flow kar sakte hain (vanishing gradients kam hote hain)
- Feature reuse: Late layers early layers ke raw low-level features access kar sakti hain
- Parameter efficiency: Redundant features dobara seekhne ki zaroorat nahi
Growth Rate aur Parameters Derive Karna
First principles se derivation:
- Layer 0: input mein channels hain
- Layer 1: channels receive karta hai, naye channels output karta hai → total =
- Layer 2: channels receive karta hai, naye channels output karta hai → total =
- Layer : channels receive karta hai, output karta hai → total =
- layers ke baad: channels
Chhota kyun kaam karta hai: Typical ya hota hai. Har layer "collective knowledge" mein feature maps ka ek chhota set contribute karti hai, lekin sabhi predecessors se rich combined feature set access karti hai.
1×1 convolution kyun? Expensive 3×3 convolution se pehle dimensionality reduce karta hai.
Ek bottleneck layer ke liye parameter calculation:
- Agar input mein channels hain:
- 1×1 conv: parameters
- 3×3 conv: parameters
- Bottleneck ke bina: parameters
Jaise badhta hai (block mein late stages mein), reasonable ke liye , toh bottlenecks parameters bachate hain.
Agar ek dense block channels output karta hai, toh transition layer channels tak compress karta hai jahan compression factor hai (typically ).
Compression kyun? Model size aur computational cost control karta hai. Har dense block ke baad channels ko half karna growth ko manageable rakhta hai.
Total layers: conv layers dense blocks ke andar, plus transitions ≈ bottlenecks ke saath 121 layers.
Ye configuration kyun kaam karti hai: Early blocks (kam layers) low/mid-level features seekhte hain. Deep blocks (zyada layers) high-level abstractions seekhte hain. Har ek ke paas sabhi prior features ka access hota hai.
Ye step kyun? Har layer apna output () running total mein concatenate karta hai.
ke saath transition ke baad: channels.
Ye sahi kyun lagta hai: Dono "skip" connections hain jo gradients mein help karte hain.
Sahi baat: DenseNet feature maps ko concatenate karta hai: . Ye sabhi prior information explicitly preserve karta hai, jabki ResNet ka addition features ko merge karta hai (individual identity kho jaati hai). Concatenation true feature reuse enable karta hai lekin memory zyada lagti hai; addition memory-efficient hai lekin kam reuse hota hai.
EfficientNet: Compound Scaling
constraint ke saath: , jahan .
Ye constraint kyun? mein har unit increase ke saath FLOPs doubling approximate karta hai.
Scaling Law Derive Karna
Ek layer ke liye total FLOPs:
Agar hum har dimension scale karte hain:
ke har increment par FLOPs double karne ke liye:
Ye kyun important hai: Ek given computational budget (FLOPs) ke liye, ye formula batata hai ki maximum accuracy ke liye depth, width, aur resolution mein scaling kaise distribute karein.
Check karo: ✓
ke saath EfficientNet-B1 create karne ke liye:
- Depth:
- Width:
- Resolution: pixels
ke saath EfficientNet-B7 ke liye:
- Depth:
- Width:
- Resolution: pixels
Ye step kyun? Har dimension ke saath exponentially badhta hai, lekin constrained hai taki total FLOPs bhi exponentially badhe ( ke har increment mein ≈ 2× FLOPs).
- Expand: 1×1 conv se channels ko factor se expand karo (typically 6)
- Depthwise: 3×3 ya 5×5 depthwise conv (ek filter per channel)
- Squeeze-and-Excitation (SE): channel attention
- Project: 1×1 conv se output channels par project wapas karo
- Skip connection agar input/output dimensions match karein
MBConv kyun? Extremely parameter-efficient. Depthwise separable convolutions standard convolutions ke comparison mein FLOPs dramatically reduce karte hain.
Strategy 1: Sirf Depth ()
- FLOPs: ✓
- Result: Bahut deep, narrow network. Risk: vanishing gradients, train karna mushkil.
Strategy 2: Sirf Width ()
- FLOPs: ✓
- Result: Wide, shallow network. Risk: limited representational depth.
Strategy 3: Sirf Resolution ()
- FLOPs: ✓
- Result: Higher resolution, same depth/width. Risk: fine spatial details hain lekin koi added abstraction layers nahi.
Strategy 4: Compound scaling (, )
- FLOPs: ✓
- Result: Sabhi dimensions mein balanced growth. Empirically higher accuracy achieve karta hai.
Compound scaling kyun jeetta hai: Depth abstraction add karta hai, width har layer mein capacity add karti hai, resolution finer patterns capture karta hai. Teeno scale karne se kisi bhi single dimension mein bottleneck avoid hota hai.
Ye sahi kyun lagta hai: Zyada better hota hai, hai na?
Sahi baat: Unconstrained scaling FLOPs explode kar deta hai: FLOPs increase (2× nahi). Tum apna compute budget uda dete ho. constraint ensure karta hai ki tum ek target computational envelope ke andar scale karo. Empirically, exponents 1, 2, 2 reflect karte hain ki depth, width, aur resolution convolutional layers mein FLOPs ko kaise impact karte hain.
DenseNet aur EfficientNet Compare Karna
| Aspect | DenseNet | EfficientNet | |--------|--------------| | Core Idea | Feature reuse ke liye dense connectivity | Efficiency ke liye compound scaling | | Parameter Efficiency | Feature reuse se kam params | MBConv + AutoML se kam params | | Memory | High (concatenation sabhi intermediate features store karta hai) | Low (inverted bottlenecks) | | Training | Memory-intensive ho sakta hai | Efficient, lekin careful scaling chahiye | | Strength | Excellent gradient flow, feature reuse | State-of-the-art accuracy/FLOP tradeoff | | Use Case | Jahan feature reuse matter karta hai (medical imaging, fine-grained classification) | Resource-constrained ya production deployment |
Recall Feynman Explanation (ELI12)
Socho tum ek LEGO tower (ek neural network) bana rahe ho.
DenseNet: Har baar jab tum LEGO bricks ki ek nayi layer add karte ho, tum usse sirf neeche wali layer se nahi jodte, balki tum strings (connections) neeche ki har layer tak chalate ho. Toh top brick bottom se, middle se, sab se connected hai. Matlab har brick dekh sakti hai ki sabhi earlier bricks ne kya seekha. Ye bilkul aise hai jaise class mein sablog apne notes sabke saath share karein—koi bhi important info miss nahi karta. Downside? Tumhe bahut zyada string (memory) chahiye.
EfficientNet: Ab socho tum apna tower aur lamba banana chahte ho. Tum bas aur layers stack kar sakte ho (use deeper bana sakte ho). Ya har layer ko wider bana sakte ho (zyada bricks per layer). Ya bade bricks use kar sakte ho (higher resolution images). EfficientNet kehta hai: teeno karo, lekin balanced tarike se. Agar tum usse 20% deeper banate ho, toh usse 10% wider banao aur 15% bade bricks use karo, sab ek saath. Is tarah tower mazboot aur balanced rehta hai bina girne ke ya zyada material use kiye.
Dono smart hone ke baare mein hain: DenseNet sab kuch share karta hai, EfficientNet sab kuch proportionally scale karta hai.
Connections
- ResNet - DenseNet skip connections ko full dense connectivity tak extend karta hai
- Inception - Multi-scale processing, dono 1×1 bottlenecks use karte hain
- MobileNet - EfficientNet MobileNetV2 ke MBConv blocks par build karta hai
- Neural Architecture Search - EfficientNet baseline architecture find karne ke liye NAS use karta hai
- Batch Normalization - Dono architectures mein critical component
- Model Compression - Dono architectures efficiency research ko motivate karte hain
#flashcards/ai-ml
DenseNet mein dense connectivity pattern kya hai? :: Har layer channel dimension ke saath concatenation ke zariye sabhi preceding layers se feature maps receive karti hai, aur apna output sabhi subsequent layers ko pass karti hai.
DenseNet mein growth rate kya hota hai aur ye chhota kyun ho sakta hai?
Ek DenseNet block kitne channels output karta hai agar input mein channels hain, layers hain, aur growth rate hai?
DenseNet mein 1×1 bottleneck layers ka kya purpose hai?
DenseNet mein transition layers kya karte hain?
EfficientNet mein compound scaling kya hai? :: Network depth (), width (), aur resolution () ko ek compound coefficient use karke ek saath uniformly scale karna, ke constraint ke saath FLOPs control karne ke liye.
Compound scaling constraint mein aur kyun hain, linear terms ki jagah?
MBConv blocks kya hain aur EfficientNet inhe kyun use karta hai? :: Mobile Inverted Bottleneck Convolution blocks: channels expand karo (1×1 conv), depthwise conv apply karo (3×3 ya 5×5), SE attention add karo, neeche project karo (1×1 conv), skip connection. Depthwise separable convolutions ki wajah se extremely parameter-efficient hote hain.