3.4.10 · HinglishConvolutional Neural Networks

DenseNet and EfficientNet

2,986 words14 min readRead in English

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.

Figure — DenseNet and EfficientNet

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).

  1. Expand: 1×1 conv se channels ko factor se expand karo (typically 6)
  2. Depthwise: 3×3 ya 5×5 depthwise conv (ek filter per channel)
  3. Squeeze-and-Excitation (SE): channel attention
  4. Project: 1×1 conv se output channels par project wapas karo
  5. 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?
wo feature maps ki sankhya hai jo har layer produce karti hai. Ye chhota ho sakta hai (jaise 12-32) kyunki har layer concatenation ke zariye sabhi predecessors ke rich collective feature set access karti hai, toh usse sirf ek chhota naya contribution add karna hota hai.
Ek DenseNet block kitne channels output karta hai agar input mein channels hain, layers hain, aur growth rate hai?
channels, kyunki layers mein se har ek concatenated set mein naye feature maps add karta hai.
DenseNet mein 1×1 bottleneck layers ka kya purpose hai?
Expensive 3×3 convolutions se pehle dimensionality reduce karna, taaki dense block aage badhne par input channels mein explosion na ho. Typical bottleneck: BN-ReLU-Conv1×1 → 4k channels → BN-ReLU-Conv3×3 → k channels.
DenseNet mein transition layers kya karte hain?
Dense blocks ke beech spatial dimensions reduce karte hain (2×2 average pooling ke zariye) aur channels compress karte hain (1×1 conv ke zariye compression factor ke saath, typically 0.5) taaki model size control mein rahe.

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?
Kyunki width FLOPs ko quadratically affect karti hai (convolutions mein input channels × output channels) aur resolution FLOPs ko quadratically affect karta hai (spatial dimensions ), jabki depth FLOPs ko linearly scale karta hai.

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.

Agar EfficientNet-B0 ki depth hai aur tum aur se B1 banate ho, toh nayi depth kya hogi?
(20% deeper).
DenseNet ke skip connections aur ResNet ke skip connections mein kya key difference hai?
DenseNet feature maps ko concatenate karta hai (sabhi prior information explicitly preserve hoti hai, channels badhte hain), jabki ResNet feature maps ko element-wise add karta hai (features merge ho jaate hain, channels constant rehte hain). Concatenation se stronger feature reuse hota hai lekin zyada memory chahiye.
Compound scaling (teeno dimensions) sirf depth, width, ya resolution scale karne se better kyun perform karta hai?
Sirf ek dimension scale karne se bottlenecks create hote hain: sirf depth se vanishing gradients ka risk, sirf width se limited abstraction, sirf resolution se detail add hoti hai bina added capacity ke. Balanced scaling ensure karta hai ki koi bhi single dimension bottleneck na ho, empirically ek given FLOP budget ke liye higher accuracy achieve hoti hai.
DenseNet ki architecture ka memory tradeoff kya hai?
Training ke dauran high memory usage, kyunki concatenation backpropagation ke liye sabhi intermediate feature maps store karta hai. Lekin parameter count kam hota hai feature reuse ki wajah se (koi redundant re-learning nahi).

Concept Map

uses

via

governed by

output channels k0 + Lk

enables

enables

reduces channels with Conv1x1

compress between blocks

scales

balances

DenseNet

EfficientNet

Dense Connectivity

Channel Concatenation

Growth Rate k

Bottleneck Layers

Transition Layers

Gradient Highway

Feature Reuse