Neural Networks Fundamentals

(न्यूरल नेटवर्क की मूल बातें)


🔷 1. परिचय (Introduction)

Neural Network एक ऐसा गणितीय मॉडल है जो इंसानी मस्तिष्क की तरह सीखने का प्रयास करता है। यह इनपुट को लेता है, layers के ज़रिए प्रोसेस करता है और फिर आउटपुट देता है।

Deep Learning = कई layers वाले Neural Network


🧱 2. Basic Structure of a Neural Network

एक Neural Network में मुख्यतः तीन प्रकार की layers होती हैं:

Layer Nameकार्य
Input Layerबाहरी डेटा को लेती है
Hidden Layersडेटा को प्रोसेस करती हैं
Output Layerअंतिम निर्णय या अनुमान देती है

🔁 Working Flow:

Input → Weights × Input + Bias → Activation → Output

🧠 3. Perceptron – सबसे सरल Neural Unit

➤ परिभाषा:

Perceptron एक single-layer neural network है, जो binary classification कर सकता है।

Perceptron Formula:

जहाँ:

  • xi​: Input
  • wi: Weights
  • b: Bias
  • f: Activation Function (जैसे: Step Function)

💡 4. Activation Functions

Activation function यह तय करता है कि कोई neuron activate होगा या नहीं। यह non-linearity introduce करता है।


🔂 5. Forward Pass & Backpropagation

🔄 Forward Pass:

Input → Output तक की गणना
(Weights, Biases, Activation के साथ)

🔁 Backpropagation:

Loss को Output से Input की तरफ propagate करना
→ Gradient निकालना (Chain Rule)
→ Weights update करना (Gradient Descent)


💻 आवश्यक कोड: एक सिंपल Neural Network (PyTorch)

import torch
import torch.nn as nn

# Simple feedforward network
class SimpleNN(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(2, 4) # Input layer to hidden
self.relu = nn.ReLU()
self.fc2 = nn.Linear(4, 1) # Hidden to output

def forward(self, x):
x = self.fc1(x)
x = self.relu(x)
return self.fc2(x)

model = SimpleNN()
print(model)

📌 Visualization: Neural Network Structure

yamlCopyEditInput Layer: x1, x2
        ↓
Hidden Layer (Neurons)
        ↓
Activation (ReLU)
        ↓
Output Layer: ŷ

🎯 Chapter Objectives (लक्ष्य)

  • Neural Network की मूल संरचना को समझना
  • Perceptron की कार्यप्रणाली को जानना
  • Activation Functions का महत्व जानना
  • Forward और Backpropagation के बीच का संबंध समझना
  • PyTorch में एक सरल मॉडल बनाना

📝 अभ्यास प्रश्न (Practice Questions)

  1. Neural Network में तीन मुख्य layers कौन-सी होती हैं?
  2. Perceptron का गणितीय फ़ॉर्मूला लिखिए और समझाइए।
  3. ReLU और Sigmoid में क्या अंतर है?
  4. Forward Pass और Backpropagation क्या होते हैं?
  5. नीचे दिए गए कोड में कितने neurons hidden layer में हैं? pythonCopyEditself.fc1 = nn.Linear(3, 5)