अब हम deep learning की सबसे क्रांतिकारी और रचनात्मक तकनीक को समझने जा रहे हैं —
🎭 Generative Adversarial Networks (GANs)
यह deep learning का एक ऐसा क्षेत्र है जो machines को नई चीजें “create” करना सिखाता है — जैसे इंसानों की तरह तस्वीरें बनाना, आर्टिफिशियल आवाज़ें, नए फैशन डिज़ाइन, और यहां तक कि पूरी दुनिया की नक़ल करना।
🔶 1. What is a GAN?
GANs एक तरह का generative model है जो deep learning का उपयोग करके नई data instances generate करता है।
GAN architecture में दो neural networks होते हैं जो एक-दूसरे के खिलाफ (adversarial) train होते हैं:
🎯 “एक network generate करता है, दूसरा उसे judge करता है।”
🔁 2. GAN Structure
Noise (z)
↓
[Generator Network]
↓
Fake Data (x̂)
↓
[Discriminator Network]
↑ ↓
Real Data (x) Real or Fake?
🔹 Generator (G):
- Random noise से fake data generate करता है
- इसका उद्देश्य है Discriminator को धोखा देना
🔹 Discriminator (D):
- असली और नकली data के बीच अंतर करने की कोशिश करता है
- इसका उद्देश्य है fake data को पकड़ना
🧠 3. Game Between Generator and Discriminator
- Generator चाहता है कि Discriminator को धोखा दे
- Discriminator चाहता है कि वो सही-सही असली और नकली data पहचान ले
👉 इसे कहा जाता है minimax game:

🔬 4. क्यों GANs ख़ास हैं?
Feature | Description |
---|---|
🎨 Creativity | नई images, art, music बना सकते हैं |
🧠 Learning | Unsupervised (no labels) |
🎯 High-Quality Output | Extremely realistic images |
🏆 Competition | Generator vs Discriminator improves quality |
🔧 5. PyTorch GAN Skeleton (Basic Idea)
# Generator
class Generator(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(
nn.Linear(100, 128),
nn.ReLU(),
nn.Linear(128, 784),
nn.Tanh()
)
def forward(self, z):
return self.net(z)
# Discriminator
class Discriminator(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(
nn.Linear(784, 128),
nn.LeakyReLU(0.2),
nn.Linear(128, 1),
nn.Sigmoid()
)
def forward(self, x):
return self.net(x)
📊 6. Real-World Applications of GANs
Area | Example |
---|---|
🎨 Art & Design | नई paintings, filters |
👨🎨 DeepFake | Face swap, video editing |
🖼️ Super-Resolution | Low-res → High-res images |
🧪 Healthcare | Synthetic medical data |
🎮 Gaming | Environment generation |
🌎 Simulation | Virtual world synthesis |
🧑🏫 Data Augmentation | Synthetic training data |
📝 Practice Questions:
- GAN क्या होता है और इसमें कौन-कौन से components होते हैं?
- Generator और Discriminator का क्या रोल होता है?
- GAN का objective function क्या है?
- GANs किस-किस क्षेत्र में उपयोग किए जा रहे हैं?
- GAN training को unstable क्यों कहा जाता है?
🧠 Summary
Concept | Description |
---|---|
GAN | Generative Adversarial Network |
Generator | Fake data create करता है |
Discriminator | Fake और real में अंतर करता है |
Output | Synthetic but realistic data |
Use Cases | Image generation, deepfake, super-resolution, etc. |