Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
📘 Lesson  ·  Lesson 58

Activation Functions

Activation function क्या है

Activation function neural network में neuron के output को तय करता है। यह neuron का input लेकर बदलता है, non-linearity जोड़कर ताकि network complex patterns सीख सके। आम हैं Sigmoid, Tanh, ReLU और Softmax — हर एक का अलग आकार और इस्तेमाल।

💡 Activation functions non-linearity जोड़ते हैं — वो चाबी जो deep networks को curves सीखने देती है, सिर्फ़ सीधी lines नहीं।

इनकी ज़रूरत क्यों

Activation function बिना, हर layer बस एक linear equation होती, और कई linear layers stack करना फिर भी एक linear result देता। वो असली, curvy patterns कभी model नहीं कर पाता। Activation functions output को मोड़ते हैं, तो कई layers साथ मिलकर rich, complex relationships सीख सकती हैं। यही deep learning को शक्तिशाली बनाता है।

Sigmoid

किसी भी input को 0 और 1 के बीच value में दबा देता है।

  • Range: 0 से 1।
  • किसके लिए बढ़िया: binary (हाँ/ना) समस्याओं की output layer।
  • कमज़ोरी: deep networks में vanishing gradient problem कर सकता है।

Tanh

Sigmoid जैसा पर -1 और 1 के बीच output देता है।

  • Range: -1 से 1 (0 पर केंद्रित)।
  • किसके लिए बढ़िया: hidden layers जहाँ केंद्रित output मदद करे।
  • कमज़ोरी: बहुत deep networks में अब भी vanishing gradients झेलता है।

ReLU

सबसे लोकप्रिय विकल्प — input positive हो तो उसे, वरना 0 output करता है।

def relu(x):
    return max(0, x)

print(relu(5))    # 5
print(relu(-3))   # 0
5
0

ReLU सरल और तेज़ है, और vanishing gradient problem से काफ़ी बचता है, तो यह ज़्यादातर आधुनिक networks की hidden layers में default है।

Softmax

numbers की list को ऐसी probabilities में बदलता है जो जुड़कर 1 होती हैं।

  • Output: probabilities का set (हर एक 0 से 1, जोड़ 1)।
  • किसके लिए बढ़िया: multi-class समस्याओं की output layer (जैसे 10 categories में classify)।
  • विचार: सबसे बड़े input को सबसे ऊँची probability मिलती है।

कौन-सा इस्तेमाल करें

FunctionRangeआम इस्तेमाल
ReLU0 से ∞Hidden layers (default)
Sigmoid0 से 1Binary output
Tanh-1 से 1कुछ hidden layers
Softmax0 से 1 (जोड़ 1)Multi-class output

आम भ्रम

  • हर जगह Sigmoid इस्तेमाल करना। hidden layers में ReLU बेहतर; Sigmoid मुख्यतः binary output को।
  • यह भूलना कि non-linearity मायने रखती है। Activations बिना, extra layers कुछ नहीं जोड़तीं।
  • Softmax बनाम Sigmoid confusion। एक हाँ/ना output को Sigmoid; कई classes में से चुनने को Softmax।
  • Vanishing gradients अनदेखा करना। Deep Sigmoid/Tanh networks बहुत धीरे train हो सकते हैं — ReLU मदद करता है।

सारांश

  • Activation functions non-linearity जोड़ते हैं ताकि networks complex patterns सीखें।
  • ReLU hidden layers के लिए तेज़, लोकप्रिय default है।
  • Sigmoid (0-1) binary output को; Tanh (-1 से 1) कुछ hidden layers को।
  • Softmax multi-class output के लिए class probabilities देता है।
  • Activations बिना, deep layers एक linear layer जैसा व्यवहार करती हैं।

आगे, model quality सीखिए overfitting और underfitting में, या architectures तुलना कीजिए CNN बनाम RNN में।

अक्सर पूछे जाने वाले प्रश्न (FAQ)

Neural network में activation function क्या है?
Activation function neuron के output को उसके input के आधार पर तय करता है। यह non-linearity जोड़ता है, जो network को complex patterns सीखने देता है। इसके बिना, deep network एक अकेली सरल layer जैसा व्यवहार करता।
Neural networks को activation functions क्यों चाहिए?
ये non-linearity लाते हैं। activation function बिना, layers stack करना बस एक और linear equation देता है, तो network curves या complex relationships नहीं सीख पाता। Activations deep learning को संभव बनाते हैं।
ReLU क्या है और लोकप्रिय क्यों है?
ReLU (Rectified Linear Unit) input positive हो तो उसे output करता है, वरना 0। यह सरल, तेज़ है, और vanishing gradient problem से बचता है जो Sigmoid और Tanh को धीमा करती है, इसीलिए यह ज़्यादातर hidden layers में default है।
Sigmoid या Softmax कब इस्तेमाल करूँ?
binary (हाँ/ना) समस्याओं के output layer में Sigmoid, क्योंकि यह 0 और 1 के बीच value देता है। multi-class समस्याओं के output layer में Softmax, क्योंकि यह probabilities देता है जो जुड़कर 1 होती हैं।
Vanishing gradient problem क्या है?
Sigmoid और Tanh के साथ, deep networks में gradients बहुत छोटे हो सकते हैं, तो शुरुआती layers बहुत धीरे सीखती हैं। ReLU इससे काफ़ी बचता है क्योंकि positive inputs के लिए इसका gradient 1 रहता है, deep networks को तेज़ train होने में मदद करके।
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.
अगला topicCNN vs RNN आपकी प्रगति: 58 / 66 (88%) · Lesson 59 / 66 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें