<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ojas Arora on Medium]]></title>
        <description><![CDATA[Stories by Ojas Arora on Medium]]></description>
        <link>https://medium.com/@ojas.arora14?source=rss-08e512e965cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9v334fskEq7eY8c8v0gnsA.png</url>
            <title>Stories by Ojas Arora on Medium</title>
            <link>https://medium.com/@ojas.arora14?source=rss-08e512e965cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:11:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ojas.arora14/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DLS Part 5 : Main Kal Market Gaya — Agar Neural Network Ko Kal Yaad Hi Na Ho Toh Kya Faayda?]]></title>
            <link>https://medium.com/@ojas.arora14/dls-part-5-main-kal-market-gaya-agar-neural-network-ko-kal-yaad-hi-na-ho-toh-kya-faayda-1f00d13d5069?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f00d13d5069</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Sat, 12 Sep 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-09-12T02:31:01.911Z</atom:updated>
            <content:encoded><![CDATA[<h4>Har sentence mein previous words matter karte hain. Bank ka matlab kya hai — paison wala ya nadi wala? Context se pata chalta hai. ANN ke paas context nahi, RNN ke paas hai. Forward Propagation, Backpropagation Through Time, Many-to-Many, Vanishing Gradients</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*YY5E-jpJaISP0uvRCDUSEg.png" /></figure><h3>Ek Imaginary WhatsApp Chat Se Shuru Karte Hain</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0g6RdaEJA9w3r-z3YMGMhA.png" /></figure><p><strong>Yahi farak hai.</strong></p><p>ANN har input ko <strong>akele</strong> dekhta hai — jaise ek aisa insaan jo har 5 second mein apni memory kho deta hai. RNN har input ko <strong>pichhle inputs ke context mein</strong> dekhta hai — jaise ek normal insaan jo baat ka flow samajhta hai.</p><p>Aur yeh farak itna fundamental hai ki iske bina — text generation, speech recognition, machine translation, sentiment analysis, stock prediction — <strong>kuch bhi possible nahi tha.</strong></p><blockquote>ANN ne kaha — main har word alag dekhta hoon,<em> </em>Sentence ka matlab? Bhai, mujhe kya pata.<em> </em>RNN aaya, bola — pichla word yaad rakh,<em> </em>Context mein dekh, tab samajh mein aata.</blockquote><h3>Pehle Samjho — ANN Sequences Ke Saath Kyun Fail Karta Hai?</h3><p>CNN ne images samajhna seekh liya. ANN ne tabular data pe kaam kar liya. Lekin jab baat <strong>sequences</strong> ki aaye — text, audio, time series — toh dono haath khade kar dete hain.</p><p><strong>Kyun?</strong> Teen bade reasons:</p><h4>Reason 1: Order Matters, ANN Ko Nahi</h4><p><strong><em>Dog bites man</em></strong> aur <strong><em>Man bites dog </em></strong>— ANN ke liye <strong>same input</strong> hai. Kyun? Kyunki ANN inputs ka order nahi dekhta — sirf values dekhta hai. Dono mein same words hain, bus rearranged hain.</p><p>Lekin matlab toh <strong>bilkul ulta</strong> hai.</p><h4>Reason 2: Variable Length Inputs</h4><p>ANN ko <strong>fixed size input</strong> chahiye. Har sentence alag length ki hoti hai — <strong><em>Hi</em></strong> 1 word, <strong><em>I love this incredible movie </em></strong>5 words. Kya karein? Padding lagaayein? Truncate karein? Dono mein information loss.</p><h4>Reason 3: No Memory</h4><p>ANN ke neurons ke paas <strong>koi memory nahi hai.</strong> Input aaya, output diya, bhool gaya. Agle input ka pichhle se koi connection nahi.</p><p>Jaise koi insaan jo har conversation <strong>scratch se</strong> shuru karta hai. Aap 30 minute baat karo, phir poochho maine kya bola tha? — blank stare.</p><p><strong>Sequences samajhne ke liye chahiye ek aisa network jo </strong>Input ka <strong>order</strong> samjhe , <strong>Variable length</strong> handle kare and Previous inputs <strong>yaad</strong> rakhe.</p><p><strong>Enter: Recurrent Neural Network.</strong></p><h3>RNN Kya Hai — Concept</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnHycSnxC8jBKOKoQtygDQ.png" /></figure><p>Ek line mein definition:</p><h4><strong><em>RNN ek aisa neural network hai jisme har time step ka output agle time step ko influence karta hai — ek hidden state ke through jo pichhle saare inputs ki compressed memory rakhta hai.</em></strong></h4><p>Zyada simple bhasha mein? <strong>Ek loop hai.</strong></p><p>ANN mein information sirf ek direction mein jaati hai — input → hidden → output. One-way street.</p><p>RNN mein hidden layer ke output ka <strong>ek hissa wapas aata hai</strong> — agle step mein input ke saath. Loop. Wahi hidden layer, baar-baar, har word/step ke liye.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMCqDOR_qPR3QEqNtJQRJA.png" /></figure><p>Woh <strong><em>h₁, h₂, h₃</em></strong>— yeh <strong>hidden state</strong> hai. Yahi RNN ki <strong>yaaddasht</strong> hai.</p><h3>Forward Propagation — RNN Andar Se Kaise Kaam Karta Hai?</h3><p>Chaliye math dekhte hain. Daraiye mat — intuition pehle, formula baad mein.</p><h4>Har Time Step Pe Kya Hota Hai?</h4><p>Maan lo aap sentence process kar rahe hain: <strong>“I love movies”</strong></p><p><strong>Time step 1:</strong> Word =<strong><em> </em>“I”</strong></p><pre>h₁ = tanh(W_xh × x₁ + W_hh × h₀ + b_h)<br>y₁ = softmax(W_hy × h₁ + b_y)</pre><p>Kya ho raha hai?</p><ul><li><strong><em>x₁</em></strong> = &quot;I&quot; ka vector representation (embedding)</li><li><strong><em>h₀ </em></strong>= initial hidden state (usually zeros)</li><li><strong><em>W_xh </em></strong>= input se hidden layer tak ke weights</li><li><strong><em>W_hh</em></strong> = <strong>previous hidden state se current hidden state tak ke weights</strong> ← YAHI RNN KA MAGIC HAI</li><li><strong><em>h₁</em></strong> = naya hidden state, jo &quot;I&quot; ki information encode karta hai</li><li><strong><em>y₁</em></strong> = output (agar chahiye toh)</li></ul><p><strong>Time step 2:</strong> Word = <strong>“love”</strong></p><pre>h₂ = tanh(W_xh × x₂ + W_hh × h₁ + b_h)</pre><p>Ab dekhiye — <strong><em>h₁</em></strong>already <strong>&quot;I&quot;</strong> ki information rakhta hai. Jab <strong>&quot;love&quot;</strong> process hua, toh <strong><em>h₂</em></strong>ke andar <strong>&quot;I&quot; + &quot;love&quot;</strong> dono ki information hai.</p><p><strong>Time step 3:</strong> Word = <strong><em>“movies”</em></strong></p><pre>h₃ = tanh(W_xh × x₃ + W_hh × h₂ + b_h)</pre><p><strong><em>h₃ </em></strong>ke andar ab <strong>&quot;I&quot; + &quot;love&quot; + &quot;movies&quot;</strong> — poori sentence ki compressed memory.</p><h3>Sabse Important Baat Jo Dhyan Se Padhiyega</h3><p>Weight matrices<strong> <em>W_xh, W_hh, W_hy </em>— </strong>yeh SAARE TIME STEPS MEIN SAME HAIN.</p><p>Same weights, baar-baar, har word ke liye. Isliye isko “recurrent” kehte hain — same computation <strong>recur</strong> hota hai. Iska faayda? Parameters bahut kam hote hain. 100 words ka sentence ho ya 5 words ka — <strong>same number of parameters.</strong></p><pre>import tensorflow as tf<br>from tensorflow.keras.layers import SimpleRNN, Dense, Embedding<br><br>model = tf.keras.Sequential([<br>    Embedding(input_dim=10000, output_dim=128),  # words → vectors<br>    SimpleRNN(64, return_sequences=False),         # 64 hidden units<br>    Dense(1, activation=&#39;sigmoid&#39;)                 # sentiment output<br>])<br>model.compile(optimizer=&#39;adam&#39;, loss=&#39;binary_crossentropy&#39;, metrics=[&#39;accuracy&#39;])</pre><p>Itne mein ek basic sentiment analyzer ready hai. <strong><em>SimpleRNN(64)</em></strong>— 64 hidden units, matlab hidden state 64 numbers ka vector hai. Poori sentence ki memory <strong>64 numbers mein compress</strong> ho rahi hai.</p><h3>RNN Ke Types — Kaunsa Architecture Kab?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRpirVIxba11mF1jyDToSg.png" /></figure><p>Yeh sabse interesting part hai. Sequences ke saath ek flexibility hai jo images ke saath nahi — input aur output dono <strong>variable length</strong> ho sakte hain. Isse 4 main architectures bante hain:</p><h4>1. One-to-One ← (Boring wala, yeh toh ANN hai basically)</h4><p>Ek input, ek output. Fixed size. Koi sequence nahi. Technically RNN hai, practically koi isko use nahi karta is mode mein. Mention sirf completeness ke liye.</p><h4>2. Many-to-One ← Sentiment Analysis Ka Hero</h4><p>Poori sequence input, ek single output.</p><pre>&quot;I&quot;  →  [RNN]<br>&quot;love&quot; →  [RNN]<br>&quot;this&quot; →  [RNN]<br>&quot;movie&quot; →  [RNN] → &quot;Positive&quot; ✓</pre><p><strong>Use cases:</strong> Sentiment analysis, spam detection, document classification. Poora sentence padho, end mein ek label do.</p><pre># Many-to-One: return_sequences=False (default)<br>SimpleRNN(64, return_sequences=False)  # sirf last hidden state output hota hai</pre><h4>3. One-to-Many ← Creative AI Ka Darwaza</h4><p>Ek input, multiple outputs generate karta hai.</p><pre>[Image] → [RNN] → &quot;A&quot;<br>                → &quot;cat&quot;<br>                → &quot;sitting&quot;<br>                → &quot;on&quot;<br>                → &quot;a&quot;<br>                → &quot;mat&quot;</pre><p><strong>Use cases:</strong> Image captioning (ek image, poora sentence generate karo), music generation (ek seed note, poori melody).</p><h4>4. Many-to-Many ← Translation Ka King</h4><p>Sequence in, sequence out.</p><p><strong>Same length wala (Synchronized):</strong></p><pre>&quot;I&quot;     → [RNN] → &quot;Main&quot;<br>&quot;love&quot;  → [RNN] → &quot;pyaar&quot;<br>&quot;you&quot;   → [RNN] → &quot;karta hoon&quot;</pre><p><strong>Use cases:</strong> Named Entity Recognition (har word ko tag karo), POS tagging.</p><pre># Many-to-Many: return_sequences=True<br>SimpleRNN(64, return_sequences=True)  # har time step ka output milega</pre><p><strong>Alag length wala (Encoder-Decoder):</strong></p><pre>Encoder: &quot;I love you&quot; → [RNN] → context vector<br>Decoder: context vector → [RNN] → &quot;Main tumse pyaar karta hoon&quot;</pre><p>Input 3 words, output 5 words. Lengths alag. Encoder poori input sentence ko ek vector mein compress karta hai, Decoder us vector se output sentence generate karta hai.</p><p><strong>Use cases:</strong> Machine translation (Google Translate ka original approach), text summarization, chatbots.</p><h3>Backpropagation Through Time (BPTT) — RNN Seekhta Kaise Hai?</h3><p>ANN mein backpropagation seedhi hoti hai — output se input ki taraf gradients bhejo, weights update karo.</p><p>RNN mein ek twist hai — <strong>time ka dimension.</strong> Error sirf layers mein neeche nahi jaata, <strong>time mein peeche bhi jaata hai.</strong></p><h4>Concept</h4><p>Maan lo 5 words ka sentence hai. RNN ne process kiya, final output pe loss calculate hua. Ab weights update karne hain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*-KoGjDRt1colbJpZsZQrhA.png" /></figure><h3>RNN Ka Sabse Bada Dard — Vanishing &amp; Exploding Gradients</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rgt0TOjq0g8TOhfIm7Ikrg.png" /></figure><p>Yeh dekhe dhyan se. <strong>Kyunki yahi woh problem hai jiski wajah se LSTM aur GRU paida hue.</strong></p><h4>Problem Kya Hai?</h4><p>BPTT mein gradient ko <strong>har time step pe multiply</strong> karna padta hai. Agar 20 words ka sentence hai, toh gradient 20 baar multiply hoga.</p><p>Ab yaad kariye — <strong><em>h_t = tanh(W_hh × h_{t-1} + …) </em></strong>. Gradient mein <strong><em>W_hh</em></strong> baar-baar multiply ho raha hai.</p><h4><strong>Scenario 1: Vanishing Gradient</strong></h4><p>Agar <strong><em>W_hh </em></strong>ke values chhoti hain (&lt; 1), toh:</p><pre>0.5 × 0.5 × 0.5 × ... (20 baar) = 0.5²⁰ = 0.000001</pre><p>Gradient <strong>practically zero</strong> ho jaata hai. Pehle time steps ke weights <strong>update hi nahi hote.</strong> Matlab? Model <strong>poore sentence ki shuruwaat bhool jaata hai.</strong> Sirf last few words yaad rehte hain.</p><p><em>Ek aisa insaan jo 10 line ki poem padh ke sirf last 2 lines yaad rakh paaye.</em></p><h4><strong>Scenario 2: Exploding Gradient</strong></h4><p>Agar <strong><em>W_hh </em></strong>ke values badi hain (&gt; 1):</p><pre>1.5 × 1.5 × 1.5 × ... (20 baar) = 1.5²⁰ = 3325.26</pre><p>Gradient <strong>bahut bada</strong> ho jaata hai. Weights wildly update hote hain. Loss NaN ban jaata hai. Training <strong>blast</strong> ho jaati hai.</p><h3>Real Example Mein Kya Hota Hai?</h3><p>Sentence: <em>The cat, which was sitting on the mat near the window of the old house on the hill, </em><strong><em>was</em></strong><em> sleeping.</em></p><p>RNN ko samajhna hai ki <strong><em>was sleeping</em></strong> ka subject<strong><em> cat </em></strong>hai — jo <strong>15 words pehle</strong> aaya tha. Vanishing gradient ki wajah se <strong><em>cat </em></strong>ki information time step 15 tak <strong>survive nahi karti.</strong> Model confused ho jaata hai.</p><h4>Solutions</h4><p><strong><em>Exploding Gradient ka fix — Gradient Clipping:</em></strong></p><pre>optimizer = tf.keras.optimizers.Adam(clipnorm=1.0)  # gradient ko 1.0 pe cap karo</pre><p>Simple. Gradient ek threshold se bada ho toh <strong>kaat do.</strong> Crude lekin effective.</p><p><strong><em>Vanishing Gradient ka fix — Architecture badlo:</em></strong></p><p>Gradient clipping vanishing gradient mein kaam nahi karta (gradient already zero hai, kya clip karoge?). Iska fix hai <strong>architecture change</strong> — LSTM (Long Short-Term Memory) ya GRU (Gated Recurrent Unit).</p><p>LSTM ka core idea? Ek <strong>explicit memory cell</strong> add karo jo information ko lambe time tak preserve kar sake — bina gradient chain se multiply hue. Ek highway banao jispe information bina degradation ke travel kar sake.</p><p><strong>Lekin LSTM ki poori kahani agle article mein. Aaj RNN ka foundation strong karna tha.</strong></p><h3>Sentiment Analysis — Ek Complete Example</h3><p>Chaliye theory ko code mein dekhte hain. <strong>IMDB movie reviews ka sentiment predict karna hai</strong> — positive ya negative.</p><pre>import tensorflow as tf<br>from tensorflow.keras.datasets import imdb<br>from tensorflow.keras.preprocessing.sequence import pad_sequences<br><br># 1. Data Load karo<br>vocab_size = 10000<br>max_length = 200<br>(X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=vocab_size)<br># 2. Sequences ko same length banao (padding)<br>X_train = pad_sequences(X_train, maxlen=max_length, padding=&#39;post&#39;, truncating=&#39;post&#39;)<br>X_test = pad_sequences(X_test, maxlen=max_length, padding=&#39;post&#39;, truncating=&#39;post&#39;)<br># 3. Model banao<br>model = tf.keras.Sequential([<br>    tf.keras.layers.Embedding(vocab_size, 128, input_length=max_length),<br>    tf.keras.layers.SimpleRNN(64, dropout=0.2, recurrent_dropout=0.2),<br>    tf.keras.layers.Dense(64, activation=&#39;relu&#39;),<br>    tf.keras.layers.Dropout(0.5),<br>    tf.keras.layers.Dense(1, activation=&#39;sigmoid&#39;)<br>])<br># 4. Compile aur Train<br>model.compile(<br>    optimizer=&#39;adam&#39;,<br>    loss=&#39;binary_crossentropy&#39;,<br>    metrics=[&#39;accuracy&#39;]<br>)<br>history = model.fit(<br>    X_train, y_train,<br>    epochs=10,<br>    batch_size=128,<br>    validation_split=0.2<br>)</pre><h4>Code Mein Kya Ho Raha Hai?</h4><ul><li><strong>Embedding Layer</strong> — har word ko ek 128-dimensional vector mein convert karta hai.<strong><em> love</em></strong> = [0.23, -0.45, 0.78, …].</li><li><strong>SimpleRNN(64)</strong> — 64 hidden units. Har word process karke hidden state update hota hai. <strong><em>return_sequences=False</em></strong> default hai — sirf last hidden state output hoga (Many-to-One).</li><li><strong>Dense(1, sigmoid)</strong> — binary classification. Output 0–1, threshold 0.5. Above = positive, below = negative.</li></ul><h4>Expected Results</h4><p>SimpleRNN se aapko roughly <strong>75–80% accuracy</strong> milegi. Kyun itni kam? <strong>Vanishing gradient.</strong> 200 words ka sequence hai — RNN pehle 150 words ka information end tak properly retain nahi kar paata.</p><p>LSTM se same problem pe <strong>85–88% accuracy</strong> milegi. GRU se bhi similar. <strong>Yahi farak hai.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouPMvHiIOY3UnrdtQi5p7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QxTTe6BIqxTrVQg_2Q2LcA.png" /></figure><blockquote>ANN bola — main har word alag padhunga,<em> </em>RNN bola — pichla word yaad rakh, tab samjhunga.<em> </em>Pehle words ka context, pehle ka silsila,<em> </em>Bina yaaddasht ke koi sentence samjha kya?<em> </em>Lekin RNN ki bhi ek majboori hai yaar,<em> </em>Lambi baat yaad nahi rehti, chhoti hai memory ki taar.<em> </em>LSTM aayega, gates lagayega, yaaddasht badhayega,<em> </em>Lekin pehle RNN ki base jo hai — woh hi kaam aayega.</blockquote><p>RNN Deep Learning ka woh chapter hai jisne machines ko <strong>time</strong> samajhna sikhaaya. CNN se pehle machines andhi thi — RNN se pehle machines <strong>bhoolakad</strong> thi. RNN ne unhe memory di.</p><p>Lekin yeh memory <strong>chhoti</strong> hai. 10–15 steps se zyada RNN bhool jaata hai. Vanishing gradient naam ka villain hai jo purani information ko mita deta hai.</p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Z2-XQhelN9kpd9FzBatr-w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f00d13d5069" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DLS Part 4 : Ek Billi Ne Deep Learning Ki Duniya Badal Di — Aur Aapko Pata Bhi Nahi]]></title>
            <link>https://medium.com/@ojas.arora14/dls-part-4-ek-billi-ne-deep-learning-ki-duniya-badal-di-aur-aapko-pata-bhi-nahi-663387ff90c6?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/663387ff90c6</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-09-10T02:31:01.199Z</atom:updated>
            <content:encoded><![CDATA[<h4>1959, Hubel &amp; Wiesel, ek billi, aur ek electrode. Us experiment se nikla ek idea jo aaj self-driving cars, face unlock, aur medical imaging ka backbone hai. CNN ki kahani — neuroscience se production deployment tak.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*aoCrZRjwxAaC-2OCCxORHQ.png" /></figure><h3>Kahani Shuru Hoti Hai Ek Lab Se — Aur Ek Billi Se</h3><p><strong>1959. Harvard Medical School. Ek andhera kamra.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S5XpOPH_q78fuhsR.JPG" /></figure><p>Do neuroscientists — <strong>David Hubel</strong> aur <strong>Torsten Wiesel</strong> — ek billi ke dimaag mein ek microscopic electrode daalte hain. Saamne ek screen hai. Woh screen pe alag-alag patterns dikhate hain — dots, circles, random shapes — aur dekhte hain ki billi ke visual cortex ke neurons kab fire karte hain.</p><p>Ghanton kuch nahi hota. Neurons chup baithe rehte hain. Dots dikhaye — kuch nahi. Circles dikhaye — kuch nahi. Frustration badh rahi hai.</p><p><strong>Phir accidentally ek cheez hoti hai.</strong></p><p>Glass slide projector mein ek slide atak jaati hai. Screen pe ek <strong>thin black line</strong> slowly move karti hai. Aur achanak — <strong>neurons paagalon ki tarah fire karte hain.</strong></p><p>Hubel aur Wiesel stun ho jaate hain. Experiment dobara karte hain. Line vertical hai — kuch specific neurons fire karte hain. Line ko 45° tilt karo — <strong>doosre</strong> neurons fire karte hain. Horizontal karo — <strong>teesre</strong> neurons.</p><p><strong>Us din duniya ko pata chala ki dimaag images kaise dekhta hai:</strong></p><p>Dimaag ek photo ko seedha <strong>samajhta nahi</strong>. Pehle <strong>edges</strong> detect karta hai. Phir un edges ko combine karke <strong>shapes</strong> banata hai. Phir shapes se <strong>objects</strong>. Phir objects se <strong>scenes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*12CEfAPa4qa7ClQDvV6MVQ.png" /></figure><p>Ek hierarchical, layer-by-layer process. Simple se complex ki taraf. Isi discovery ke liye Hubel aur Wiesel ko <strong>1981 mein Nobel Prize</strong> mila.</p><p>Aur isi discovery ne ek Japanese computer scientist <strong>Kunihiko Fukushima</strong> ko inspire kiya jo 1980 mein <strong>Neocognitron</strong> banaya — pehla neural network jo visual hierarchy use karta tha. Phir 1998 mein <strong>Yann LeCun</strong> ne isko refine karke <strong>LeNet</strong> banaya. Phir 2012 mein <strong>Alex Krizhevsky</strong> ne <strong>AlexNet</strong> se ImageNet competition jeeti — aur duniya pagal ho gayi.</p><p>Sab kuch shuru hua — <strong>ek billi se, ek electrode se, aur ek accidentally moving line se.</strong></p><blockquote>Billi ke dimaag mein ek electrode tha,<em> </em>Line chali screen pe, neuron ne bola — yeh mera scene tha.<em> </em>Edges se shapes bani, shapes se chehra bana,<em> </em>Billi ne sikhaya computer ko — dekhna kaise hai jaana.</blockquote><p>Woh hierarchical processing jo billi ke dimaag mein ho rahi thi — exactly wahi CNN mein ho rahi hai. Bas neurons ki jagah <strong>filters</strong> hain, visual cortex ki jagah <strong>layers</strong> hain, aur billi ki jagah <strong>GPU</strong> hai.</p><h3>CNN Kya Hai — Ek Line Mein Samjho</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yFhlW918wgvoJ43L.png" /></figure><p><strong>Convolutional Neural Network ek aisa neural network hai jo images (ya koi bhi grid-like data) se features automatically seekhta hai — pehle simple features (edges, lines), phir complex features (shapes, textures), phir high-level features (faces, objects).</strong></p><p>Exactly wahi hierarchy jo Hubel-Wiesel ne billi ke dimaag mein dekhi thi.</p><p><strong><em>Regular Neural Network (ANN) mein kya hota hai?</em></strong> Har neuron <strong>har pixel</strong> se connected hota hai. 224×224 RGB image = 150,528 input neurons. Pehli hidden layer mein 1000 neurons hain? <strong>150 million weights.</strong> Sirf pehli layer mein. Memory explode. Training impossible. Aur koi spatial understanding nahi — model ko pata hi nahi ki pixel 1 aur pixel 2 neighbours hain.</p><h4>CNN ne 3 revolutionary ideas se yeh sab solve kiya:</h4><p><strong>Pehla — Local Connectivity.</strong> Har neuron poori image nahi dekhta, sirf ek <strong>chhota sa patch</strong> (receptive field) dekhta hai. Jaise aap book padhte waqt ek line pe focus karte hain, poora page nahi.</p><p><strong>Doosra — Weight Sharing.</strong> Jo filter ek jagah edges detect karta hai, <strong>wahi filter</strong> poori image pe slide karta hai. Weights share hote hain. Parameters drastically kam.</p><p><strong>Teesra — Hierarchical Feature Learning.</strong> Pehli layer edges dhundhti hai. Doosri un edges se textures banati hai. Teesri textures se parts banati hai (aankh, naak). Chauthi parts se poora object (chehra).</p><p>Yahi teen ideas CNN ko powerful banate hain. Ab inhe detail mein dekhte hain.</p><h3>Convolution Operation — CNN Ka Dil</h3><p>Yeh woh operation hai jispe poora CNN tika hai. Agar yeh samajh gaya, baaki sab apne aap clear hoga.</p><h4>Kya Hota Hai Convolution Mein?</h4><p>Ek chhota sa matrix hota hai — <strong>filter</strong> ya <strong>kernel</strong> (usually 3×3 ya 5×5). Yeh filter image ke upar <strong>slide</strong> karta hai, har position pe ek mathematical operation karta hai, aur ek naya output banata hai — jise <strong>feature map</strong> kehte hain.</p><p><strong>Mathematical operation:</strong> Filter aur image ke us patch ka <strong>element-wise multiplication</strong>, phir sab values ka <strong>sum</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SlqB27GuCT6xDAe7Pm5m9g.png" /></figure><p>Yeh <strong><em>-6</em></strong> feature map ka ek pixel ban gaya. Filter agle position pe slide hoga, phir agla pixel banega. Poori image pe slide karke poora feature map ban jayega.</p><h4>Filter Actually Detect Kya Karta Hai?</h4><p>Upar wala filter dekhiye — left column mein +1, right column mein -1. Yeh <strong>vertical edges</strong> detect karta hai. Jahan left bright hai aur right dark — wahan strong response. Jahan dono same hain — zero response.</p><p>Alag-alag filters alag-alag cheezein detect karte hain. Vertical edges, horizontal edges, diagonal lines, blurred regions, sharp regions. <strong>Aur sabse important baat — yeh filters manually design nahi kiye jaate.</strong> CNN training ke dauran <strong>khud seekhta hai</strong> ki kaunse filters useful hain.</p><pre>import tensorflow as tf<br>from tensorflow import keras<br>from tensorflow.keras.layers import Conv2D<br><br># Pehli convolutional layer<br>model = keras.Sequential([<br>    Conv2D(<br>        filters=32,           # 32 alag filters seekhega<br>        kernel_size=(3, 3),   # har filter 3×3 ka hoga<br>        activation=&#39;relu&#39;,<br>        input_shape=(224, 224, 3)  # 224×224 RGB image<br>    )<br>])</pre><p><strong>32 filters = 32 alag feature maps.</strong> Har map image ka ek alag<strong><em> aspect </em></strong>capture karti hai — koi edges, koi textures, koi corners.</p><h3>Padding — Border Ka Masla</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*8kTcfhaGWeAoZvFk.png" /></figure><h4>Problem Kya Hai?</h4><p>Jab 3×3 filter 5×5 image pe slide karta hai, toh output <strong>3×3</strong> hota hai — chhota ho gaya. Har convolution pe image <strong>shrink</strong> hoti jaati hai. 10 layers baad kuch bachega hi nahi.</p><p>Aur doosra problem — <strong>corner pixels sirf ek baar process hote hain</strong>, center pixels kai baar. Border ki information <strong>underrepresented</strong> rehti hai.</p><h4>Fix: Padding</h4><p>Image ke charon taraf <strong>extra pixels add karo</strong> (usually zeros). Ab filter border pixels pe bhi properly slide kar sakta hai.</p><pre># Same Padding — output size = input size<br>Conv2D(32, (3,3), padding=&#39;same&#39;)    # 224×224 → 224×224<br><br># Valid Padding - no padding, output shrinks<br>Conv2D(32, (3,3), padding=&#39;valid&#39;)   # 224×224 → 222×222</pre><p><strong>same padding use kariye</strong> jab aap size preserve karna chahte hain (default choice). <strong><em>valid</em></strong> tab jab intentionally shrink karna ho ya edge artifacts se bachna ho.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oL9QBMin99FDgG4QPJ8w2w.png" /></figure><h3>Strides — Filter Kitna Dooor Koodega?</h3><p>Default mein filter <strong>1 pixel</strong> shift hota hai har step pe (stride=1). Lekin agar stride=2 karo, toh <strong>2 pixels</strong> koodega — output size aadhi ho jayegi.</p><pre># Stride 1 — detailed, bada output<br>Conv2D(32, (3,3), strides=1)    # 224→222<br><br># Stride 2 - fast, chhota output<br>Conv2D(32, (3,3), strides=2)    # 224→111</pre><p><strong>Stride badhane se:</strong></p><ul><li>Output size <strong>ghatata hai</strong> — computational cost kam.</li><li>Detail <strong>kam</strong> hoti hai — kyunki pixels skip ho rahe hain.</li><li><strong>Downsampling</strong> ka kaam karta hai (pooling ki tarah).</li></ul><p><strong>Practice mein:</strong> Zyada-tar convolution layers mein stride=1 rakhte hain aur size reduction <strong>pooling layers</strong> pe chhod dete hain. Lekin modern architectures (jaise Inception, ResNet) mein stride=2 convolutions bhi common hain.</p><h3>Pooling — Zaroori Cheez Rakho, Baaki Fenko</h3><p>Convolution ke baad feature maps bade hote hain. Har map 224×224 hai aur 32 maps hain? Yeh bahut data hai. Pooling isko <strong>chhota</strong> karta hai — important information rakhke, baaki fenkke.</p><h4>Max Pooling — Sabse Popular</h4><p>Ek window (usually 2×2) slide karti hai feature map pe. Har window se <strong>sirf maximum value</strong> rakhte hain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ldA2pU7us1wfJtzOpMNuPw.png" /></figure><p>4×4 ka feature map → <strong>2×2</strong> ho gaya. Data 75% kam. Lekin dominant features — jo sabse zyada activated the — woh <strong>bach gaye</strong>.</p><pre>from tensorflow.keras.layers import MaxPooling2D<br><br>MaxPooling2D(pool_size=(2, 2), strides=2)</pre><h4>Average Pooling</h4><p>Maximum ki jagah <strong>average</strong> lete hain. Smoother output, lekin less sharp features. Last layers mein kabhi-kabhi use hota hai.</p><h4>Pooling Kyun Zaroori Hai?</h4><p><strong>Pehla</strong> — <strong>Dimensionality reduction.</strong> Kam data = kam computation = fast training. <strong>Doosra</strong> — <strong>Translation invariance.</strong> Agar billi image mein 5 pixels left shift ho jaaye, pooling ke baad bhi same feature map banega. Model ko position se farak nahi padta — sirf presence se padta hai. <strong>Teesra</strong> — <strong>Overfitting control.</strong> Kam parameters = kam chance ki model training data ratta maare.</p><h3>CNN Architecture — Sab Saath Mein Kaise Jodein?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbZvY-v8F6jtL0WUHhNLaw.png" /></figure><p><strong>Pattern dekhiye:</strong> Jaise-jaise deeper jaate hain — spatial size <strong>ghatata</strong> hai (pooling se), lekin channels (filters) <strong>badhte</strong> hain. <strong><em>224×224×3 → 112×112×64 → 56×56×128 → 28×28×256</em></strong>. Matlab — image chhoti hoti jaati hai, lekin <strong>har pixel zyada rich information</strong> carry karta hai.</p><h3>LeNet-5 — Pehla Successful CNN (1998)</h3><p>Yann LeCun ne banaya tha handwritten digits (0–9) recognize karne ke liye. Simple architecture — sirf 5 layers:</p><pre>model = keras.Sequential([<br>    # Layer 1: Convolution + Pooling<br>    Conv2D(6, (5,5), activation=&#39;tanh&#39;, input_shape=(32,32,1)),<br>    MaxPooling2D(2,2),<br>    <br>    # Layer 2: Convolution + Pooling<br>    Conv2D(16, (5,5), activation=&#39;tanh&#39;),<br>    MaxPooling2D(2,2),<br>    <br>    # Flatten + Dense layers<br>    keras.layers.Flatten(),<br>    keras.layers.Dense(120, activation=&#39;tanh&#39;),<br>    keras.layers.Dense(84, activation=&#39;tanh&#39;),<br>    keras.layers.Dense(10, activation=&#39;softmax&#39;)<br>])</pre><p>Aaj ke standards se yeh <strong>baby CNN</strong> hai. Lekin 1998 mein isse banks mein cheques pe handwriting read karne ke liye use kiya jaata tha. <strong>Pehla commercially successful deep learning application.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-O8C9eMGIQlulUUApTLw4Q.png" /></figure><h3>Backpropagation in CNN — Model Seekhta Kaise Hai?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*K3AXgiHgv8DYgHII" /></figure><p>CNN mein backpropagation conceptually same hai — chain rule se gradients calculate karo, weights update karo. Lekin implementation mein kuch interesting differences hain.</p><h4>Convolution Layer Mein Backprop</h4><p>Forward pass mein filter image pe slide karke feature map banata hai. Backward pass mein kya hota hai?</p><p><strong>Gradient feature map se filter ke weights tak</strong> jaana chahiye. Kyunki <strong>ek filter poori image pe shared hai</strong> (weight sharing), toh gradient bhi <strong>saari positions ka sum</strong> hota hai. Matlab agar filter ne 10,000 positions pe kaam kiya, toh gradient un 10,000 positions ke gradients ka accumulation hai.</p><h4>Pooling Layer Mein Backprop</h4><p><strong>Max Pooling:</strong> Sirf woh position jahan maximum value thi — <strong>wahi</strong> gradient pass hota hai. Baaki positions ko <strong>zero gradient</strong> milta hai. Matlab sirf <strong><em>winner</em></strong> neuron seekhta hai.</p><p><strong>Average Pooling:</strong> Gradient equally distribute hota hai saari positions mein.</p><h4>Practical Mein Aapko Kya Karna Hai?</h4><p><strong>Kuch nahi.</strong> Keras/PyTorch yeh sab automatically handle karte hain. Aapko sirf <strong><em>model.fit()</em></strong> call karna hai. Lekin samajhna isliye zaroori hai kyunki jab debugging karni hoti hai — gradient vanish ho raha hai, loss converge nahi ho raha — tab yeh knowledge kaam aati hai.</p><h3>Data Augmentation — Kam Data Se Zyada Seekhna</h3><h4>Problem</h4><p>Deep learning ka sabse bada dard — <strong>data chahiye, bahut saara data chahiye.</strong> ImageNet mein 14 million images hain. Aapke paas? Shayad 5000. Itne kam data pe CNN train karenge toh <strong>overfit</strong> hoga guaranteed.</p><h4>Fix: Data Augmentation</h4><p>Existing images ko transform karke <strong>“naye” training examples</strong> banao. Model ko lagega ki alag image hai, lekin actually wahi image hai thodi modified.</p><pre>from tensorflow.keras.preprocessing.image import ImageDataGenerator<br><br>datagen = ImageDataGenerator(<br>    rotation_range=20,          # 20° tak rotate karo<br>    width_shift_range=0.2,      # horizontally shift karo<br>    height_shift_range=0.2,     # vertically shift karo<br>    shear_range=0.2,            # shear transform<br>    zoom_range=0.2,             # zoom in/out<br>    horizontal_flip=True,       # horizontally flip karo<br>    fill_mode=&#39;nearest&#39;         # empty space fill karo<br>)</pre><p><strong>5,000 images × 10 augmentations = effectively 50,000 images.</strong> Model zyada diverse data dekhta hai, better generalize karta hai.</p><h4>Kaunsi Augmentations Use Karein?</h4><p>Yeh aapke <strong>domain pe depend</strong> karta hai:</p><p><strong>Medical X-rays?</strong> Rotation theek hai, lekin horizontal flip <strong>mat karo</strong> — kyunki dil hamesha left mein hota hai, flip karne pe anatomy galat ho jayegi.</p><p><strong>Satellite images?</strong> Rotation, flip, zoom — sab chalega.</p><p><strong>Document OCR?</strong> Slight rotation aur noise theek hai, lekin zyada distortion se characters bigad jaayenge.</p><p><strong>Rule of thumb:</strong> Socho ki real world mein yeh variation naturally aa sakta hai ya nahi. Agar haan — augmentation laga do. Agar nahi — mat lagao.</p><h3>Pretrained Models — Kyun Pehle Se Seekha Hua Model Use Karein?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*Z2qRXLOqunDQmycwnCTeCg.png" /></figure><h4>ImageNet Aur ILSVRC — Ek Quick Context</h4><p><strong>ImageNet</strong> ek massive dataset hai — <strong>14+ million images, 20,000+ categories.</strong> Stanford ne banaya tha.</p><p><strong>ILSVRC (ImageNet Large Scale Visual Recognition Challenge)</strong> — har saal competition hoti thi jismein researchers apne models test karte the. 2012 mein <strong>AlexNet</strong> ne jeetke CNN ko mainstream bana diya.</p><h4>Pretrained Models Kya Hain?</h4><p>Kisi ne ek bahut bada CNN train kiya hai ImageNet pe — <strong>millions of images</strong>, hafton ki training, <strong>lakhs ka GPU bill</strong>. Us trained model ke weights publicly available hain.</p><p>Aap un weights ko download karke apne model mein <strong>directly use</strong> kar sakte hain. Matlab — kisi aur ne mehnat ki, aap result le lo.</p><pre>from tensorflow.keras.applications import VGG16, ResNet50<br><br># ImageNet pe pretrained model load karo<br>base_model = VGG16(weights=&#39;imagenet&#39;, include_top=False, input_shape=(224,224,3))<br><br># Uske upar apna classifier lagao<br>model = keras.Sequential([<br>    base_model,<br>    keras.layers.GlobalAveragePooling2D(),<br>    keras.layers.Dense(256, activation=&#39;relu&#39;),<br>    keras.layers.Dropout(0.5),<br>    keras.layers.Dense(10, activation=&#39;softmax&#39;)  # aapki 10 classes<br>])<br><br># Base model ki weights freeze karo (optional)<br>base_model.trainable = False<br><br>model.compile(optimizer=&#39;adam&#39;, loss=&#39;categorical_crossentropy&#39;, metrics=[&#39;accuracy&#39;])</pre><h3>Transfer Learning — Kyun Kaam Karta Hai?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*hKlKnIVkzusDmC8f" /></figure><p>Yaad hai humne bola tha — CNN ki pehli layers <strong>edges</strong> detect karti hain, beech ki <strong>textures</strong>, aakhri ki <strong>objects</strong>?</p><p>Edges aur textures <strong>universal</strong> hain. Chahe aap cats classify karo ya cars ya cancer cells — edges edges hain, textures textures hain. Sirf last few layers ko aapke specific task ke liye retrain karna padta hai.</p><p><strong>Yahi transfer learning hai</strong> — purane knowledge ko naye task mein<strong><em> transfer</em></strong> karna.</p><h4>Popular Pretrained Models</h4><p><strong>VGG16/VGG19</strong> — simple, deep, easy to understand. Lekin slow aur heavy (138M parameters).</p><p><strong>ResNet50/101/152</strong> — skip connections se deep networks train karna possible hua. Production mein bahut common.</p><p><strong>InceptionV3</strong> — multiple filter sizes parallel mein. Efficient aur accurate.</p><p><strong>EfficientNet</strong> — neural architecture search se optimized. Best accuracy-to-compute ratio.</p><p><strong>MobileNet</strong> — mobile devices ke liye designed. Light, fast, surprisingly accurate.</p><h4>Kab Kaunsa?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTdepLzDB8_9V96l87bYrg.png" /></figure><h3>CNN Actually Dekhta Kya Hai? — Visualization</h3><p>Yeh sabse fascinating part hai. Hum jaante hain CNN kaam karta hai — lekin <strong>andar kya ho raha hai?</strong> Kaunsa filter kya detect kar raha hai?</p><h4>Feature Map Visualization</h4><p>Har convolution layer ke output (feature maps) ko image ki tarah visualize kar sakte hain:</p><pre># Intermediate layer ka output nikalo<br>layer_outputs = [layer.output for layer in model.layers[:8]]<br>activation_model = keras.Model(inputs=model.input, outputs=layer_outputs)<br><br># Ek image pass karo<br>activations = activation_model.predict(sample_image)<br><br># Dekho pehli layer kya detect kar rahi hai<br>import matplotlib.pyplot as plt<br>first_layer_activation = activations[0]<br>plt.imshow(first_layer_activation[0, :, :, 0], cmap=&#39;viridis&#39;)<br>plt.title(&#39;Filter 1 - Pehli Layer&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lBn3VvdlqoP_jCQ8uSyEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*QWRU8MQaymMnenLzr6IASQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QxTTe6BIqxTrVQg_2Q2LcA.png" /></figure><blockquote><em>1959 mein ek billi ne aankh kholi,</em> <em>Electrode ne padhi dimaag ki boli.</em> <em>Edges se shapes bani, shapes se jahaan,</em> <em>Us billi ke experiment ne banaya AI ka asmaan.</em> <em>Aaj har phone mein CNN chalta hai,</em> <em>Face unlock se cancer detect — sab yahi karta hai.</em> <em>Hubel ne dekha, Wiesel ne likha, LeCun ne code kiya,</em> <em>Aur ek billi ne bina jaane — Deep Learning ko jeena sikha diya.</em></blockquote><p><strong><em>CNN Deep Learning</em></strong> ka <strong>sabse important chapter</strong> hai. Computer Vision — jo aaj trillion dollar industry hai — iska poora foundation CNN pe khada hai. Face recognition, self-driving cars, medical imaging, satellite analysis, manufacturing quality control — sab CNN.</p><p>Aur yeh sab shuru hua <strong>ek accidental observation se</strong> — ki billi ke dimaag ke neurons lines ko dekhke fire karte hain.</p><p>Science mein har badi discovery aise hi hoti hai. Koi <strong><em>eureka </em></strong>plan nahi tha. Ek glass slide atak gayi, ek line screen pe chali, kuch neurons fire hue, aur 60 saal baad hum self-driving cars bana rahe hain.</p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Z2-XQhelN9kpd9FzBatr-w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=663387ff90c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DLS Part 3 : SGD Se Adam Tak — Ek Optimizer Doosre Ki Galti Se Paida Hua]]></title>
            <link>https://medium.com/@ojas.arora14/dls-part-3-sgd-se-adam-tak-ek-optimizer-doosre-ki-galti-se-paida-hua-78710b08a6be?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/78710b08a6be</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[optimizer]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-09-08T02:31:01.179Z</atom:updated>
            <content:encoded><![CDATA[<h4>SGD slow tha, Momentum ne speed di lekin overshoot kiya, NAG ne thoda sambhala, AdaGrad ne learning rate tune kiya lekin mar gaya, RMSProp ne bachaya, aur Adam ne sab jod diya</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*VbIl6HwCBAeX41RKRpeh4Q.png" /></figure><blockquote>Gradient tha seedha, loss tha gehri khaai,<br>optimizers ne milke raah dikhaayi…</blockquote><blockquote>Deep Learning ki sabse filmi kahani: har naya optimizer, pichhle wale ki problem ka jawab tha.</blockquote><p>Sabse phele ek baat batata hoon jo shayad sabne mostly ki ho.</p><p>Jab maine pehla serious neural network banaya, toh optimizer kaise choose kiya? Google kiya — <em>best optimizer for deep learning.</em></p><p>Har jagah ek hi naam — <strong>Adam</strong>.</p><p>Maine <strong><em>optimizer=’adam’</em></strong> daal diya. Model train hua. Results decent aaye. Life set. Main toh genius tha.</p><p><em>Phir ek din reality check aaya.</em></p><p>Ek tabular dataset pe kaam kar raha tha. Adam lagaya. Validation accuracy <strong>72%</strong> pe atak gayi. Jaisi jami thi, waise hi rahi. Ek hafte tak maine kya nahi kiya — layers badhaye, neurons badle, dropout tune kiya, batch size badla. Kuch nahi hua .</p><h4>Frustration mein ek line change ki:</h4><pre># optimizer = keras.optimizers.Adam(learning_rate=0.001)<br>optimizer = keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)</pre><p>Result? <strong>81%.</strong></p><p>Woh 9% ka jump mujhe ek simple baat samjha gaya jo 2 saal mein kisi article ne nahi samjhayi thi:</p><h4><strong><em>Main optimizer choose nahi kar raha tha. Main blindly copy-paste kar raha tha.</em></strong></h4><p>Adam best hai — yeh myth nahi hai. Lekin <strong>hamesha</strong> best nahi hai. Aur jab tak aapko pata nahi ki Adam ke andar kya chal raha hai, aap kabhi debug nahi kar paayenge ki kyun aapka model seekh nahi raha.</p><blockquote>SGD ne seedha chalna sikhaaya,<em> </em>Momentum ne bhaagna, NAG ne sochna.<em> </em>AdaGrad ne har weight ko apna raasta diya,<em> </em>RMSProp ne usse marne se bachaaya.<em> </em>Adam aaya, sab jod ke champion bana,<em> </em>Lekin kab kaunsa lagana — yahi asli jaanna.</blockquote><h3>Pehle 3 Zaroori Foundations</h3><p>Optimizer samajhne se pehle teen cheezein jaanni padegi. Skip mat kariyega — kyunki bina inke optimizer ke formulas sirf formulas lagenge, <strong>intuition kabhi nahi banega.</strong></p><h3>Foundation 1: Weight Initialization — Agar Neev Tedi, Toh Ghar Kabhi Seedha Nahi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*x1R7KTIn21JX6EB2" /></figure><p>Sawal simple hai: neural network ki training <strong>shuru</strong> hoti kahan se?</p><p>Random weights se. Lekin yahan <strong><em>random</em></strong> ka matlab <strong><em>kuch bhi </em></strong>nahi hai.</p><p><strong>Ek thought experiment kariye.</strong> 10 layers ka network hai. Har layer ka output agle layer ka input banta hai. Agar har layer ke weights <em>thode</em> bade hain — maan lijiye 1.5:</p><p><strong><em>1.5 × 1.5 × 1.5 × … (10 baar) = 57.67</em></strong></p><p>Values <strong>explode</strong> ho jayengi. Loss = NaN. Training khatam before it even started.</p><p>Agar weights chhote hain — maan lijiye 0.5:</p><p><strong><em>0.5 × 0.5 × 0.5 × … (10 baar) = 0.00097</em></strong></p><p>Values <strong>vanish</strong> ho jayengi. Signal pehli layer se aakhri layer tak pahunchega hi nahi. Model kuch seekhega hi nahi.</p><p><strong>Toh sahi initial weights kaise choose karein?</strong></p><h4>Xavier/Glorot Initialization — Sigmoid aur Tanh Ke Liye</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJTov5RzFXuo-gfA1h4-Zw.png" /></figure><p>Idea simple hai: weights ko aise set karo ki har layer ka output variance <strong>roughly same</strong> rahe — na badhta jaaye, na ghatata jaaye.</p><pre># Internally: variance = 2 / (fan_in + fan_out)<br>keras.layers.Dense(128, kernel_initializer=&#39;glorot_uniform&#39;)</pre><h4>He Initialization — ReLU Ka Saathi</h4><p>ReLU negative values ko zero kar deta hai — matlab <strong>aadhe neurons effectively dead</strong> hain har layer mein. Xavier ki math yahan tut jaati hai. He ne isko fix kiya:</p><pre># Internally: variance = 2 / fan_in (sirf input neurons count karte hain)<br>keras.layers.Dense(128, activation=&#39;relu&#39;, kernel_initializer=&#39;he_normal&#39;)</pre><p><strong>Cheat sheet jo yaad rakhiyega:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2Z10u4bArEwEdQN1TotkQ.png" /></figure><h3>Foundation 2: Batch Normalization — Har Layer Ko Line Mein Lagao</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TBAE60Wlp2GGujcl.jpg" /></figure><p>Aapne input data ko normalize kiya <strong><em>(StandardScaler)</em></strong>. Lekin kya hoga <strong>beech ki layers</strong> ke outputs ka?</p><p>Training ke dauran, jaise-jaise weights update hote hain, har layer ka output distribution <strong>shift hota rehta hai</strong>. Layer 3 ka output aaj 0–10 ke range mein hai, 50 epochs baad -5 to +20 mein. Layer 4 ko <strong>har baar naye distribution pe adapt</strong> karna pad raha hai.</p><p>Is problem ka naam hai — <strong>Internal Covariate Shift.</strong> Aur yeh training ko slow aur unstable banata hai.</p><p><strong>Fix?</strong> Har layer ke output ko <strong>normalize kar do</strong> — mean zero, variance one. Yahi karta hai Batch Normalization.</p><pre>from tensorflow.keras.layers import Dense, BatchNormalization<br><br>model = keras.Sequential([<br>    Dense(256, activation=&#39;relu&#39;, kernel_initializer=&#39;he_normal&#39;),<br>    BatchNormalization(),     # ← isko daal do, magic dekhiye<br>    Dense(128, activation=&#39;relu&#39;, kernel_initializer=&#39;he_normal&#39;),<br>    BatchNormalization(),<br>    Dense(1, activation=&#39;sigmoid&#39;)<br>])</pre><p><strong>Batch Norm lagane se kya milta hai?</strong></p><p>Pehla — <strong>training 2–3x fast</strong> hoti hai kyunki aap higher learning rate use kar sakte hain bina diverge kiye. Doosra — ek <strong>free regularization effect</strong> milta hai kyunki har mini-batch ka alag mean/variance hota hai, toh ek natural noise add hota hai. Teesra — <strong>vanishing gradient problem kam</strong> hoti hai kyunki normalized values kabhi extreme regions mein nahi jaati.</p><p>Ek line mein? <strong>Batch Norm Deep Learning ki ek aisi tablet hai jo lagbhag har model ko better banati hai.</strong> Lagao, dekho farak.</p><h3>Foundation 3: EWMA — Yeh Samjhe Bina Momentum Kabhi Nahi Samjhega</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HHVnI-iw9Dci_8ph1H0uRA.png" /></figure><p><strong>Exponentially Weighted Moving Average.</strong> Naam darawana hai, concept chhota hai.</p><p>Maan lo Delhi mein daily temperature track kar rahe hain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4GaJHaL_w3Oi_R9rdh0gg.png" /></figure><p>Agar simple average loge — sab ko equal importance. Lekin aapko chahiye ki <strong>aaj ka data zyada matter kare, purana kam.</strong> Kyunki trend recent mein hai, 10 din pehle ka temperature aaj relevant nahi.</p><p>EWMA yahi karta hai:</p><pre>V(t) = β × V(t-1) + (1-β) × θ(t)<br><br>β = 0.9 → roughly last 10 values ka weighted average<br>β = 0.99 → roughly last 100 values ka weighted average</pre><p><strong>Isko yaad rakhiye.</strong> Kyunki Momentum mein EWMA of gradients hota hai. RMSProp mein EWMA of squared gradients hota hai. Adam mein <strong>dono</strong> hote hain. Yahi woh thread hai jo sabko jodta hai.</p><h3>The Optimizer Family — Har Sequel Pichhli Galti Ka Fix Hai</h3><p>Sochiye ek Bollywood franchise ki tarah. Har optimizer pichhle ki limitation fix karta hai. Agar yeh evolution samajh gaye, toh aapko kabhi kuch ratna nahi padega.</p><h3>Chapter 1: Vanilla SGD — Seedha Saadha, Lekin Bahut Slow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*pLo8KaVSx_gzLESxnHJYIw.png" /></figure><p>Sabse pehla optimizer. Sabse simple. <strong>Ek sample lo, gradient nikalo, weights update karo:</strong></p><pre>W = W - η × ∇L(W)</pre><p>Bas. Itna hi. <strong><em>η</em></strong> learning rate hai — kitna bada step lena hai.</p><pre>optimizer = keras.optimizers.SGD(learning_rate=0.01)</pre><p><strong>SGD ko Rickshaw samjho.</strong> Point A se Point B le jaayega. Lekin dhire jaayega, raasta zigzag hoga, aur beech mein kahin atak bhi sakta hai.</p><p><strong>Kyun zigzag?</strong> Kyunki ek hi sample pe gradient calculate ho raha hai — wo noisy hota hai. Ek sample kehta hai left jao, agla kehta hai right jao. Model confused rehta hai.</p><p><strong>Kyun slow?</strong> Flat regions mein gradient almost zero hota hai. Chhote-chhote baby steps. Saddle points pe toh aur bura — gradient literally zero ho jaata hai, model sochta hai pahunch gaye jab ki actually nahi pahuncha.</p><p><strong>Aur sabse bada problem?</strong> Ek hi learning rate <strong>sab weights ke liye.</strong> Kuch weights ko bade steps chahiye, kuch ko chhote. SGD sabko same speed se chalata hai.</p><p><strong>Verdict:</strong> Foundation samajhne ke liye zaroori. Production ke liye? Akela kabhi nahi.</p><h3>Chapter 2: SGD + Momentum — Gend Ko Dhakka Diya</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/0*9wlVoDufNEcg1F6A" /></figure><p><strong>SGD ki galti:</strong> Sirf current gradient dekhta tha. Har step pe direction badal jaata tha. Koi <strong><em>memory </em></strong>nahi thi.</p><p><strong>Momentum ka idea:</strong> Agar pichle 10 steps mein consistently ek direction mein ja rahe ho, toh us direction mein <strong>speed build karo.</strong></p><p>Real life example — cricket ball ko imagine karo. Agar ramp pe chhod do, pehle dhire chalti hai, phir tezi se, phir aur tezi se. <strong>Past velocity add hoti jaati hai.</strong></p><p>Mathematically? Purane gradients ka <strong>EWMA</strong> maintain karo:</p><pre>V(t) = β × V(t-1) + (1-β) × ∇L(W)    ← yeh EWMA hai!<br>W = W - η × V(t)</pre><pre>optimizer = keras.optimizers.SGD(learning_rate=0.01, momentum=0.9)</pre><p><strong>Kya badla?</strong> Zigzag drastically kam hua. Flat regions tezi se cross ho rahe hain. Saddle points pe momentum push karta hai — model atakta nahi.</p><p><strong>Lekin ek naya problem aaya.</strong> Ball itni tez ho gayi ki <strong>minima ke paar nikal gayi.</strong> Jaise cycle mein brake na lage aur nilam ghar ke aage se guzar jaaye. Phir wapas aaye, phir guzar jaaye. <strong>Oscillation.</strong></p><p><em>Momentum ne speed di, lekin brake nahi diya.</em> <strong>Yahi galti thi jiski wajah se agla optimizer paida hua.</strong></p><h3>Chapter 3: NAG — Pehle Dekho, Phir Bhaago</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXf60OE1OVp8qgoThRrRCw.png" /></figure><p><em>Nesterov Accelerated Gradient.</em> Naam bada hai, idea chhota hai.</p><p><strong>Momentum ki galti:</strong> Pehle <strong>bhaagta hai</strong>, phir dekhta hai. Jab pata chalta hai ki minima ke paar nikal gaya — tab tak bahut late.</p><p><strong>NAG ka fix:</strong> Pehle dekho ki momentum tujhe <strong>kahan le jaayega</strong>. WAHAN ka gradient calculate karo. Phir bhaago.</p><pre>V(t) = β × V(t-1) + η × ∇L(W - β × V(t-1))<br>W = W - V(t)</pre><p>Woh <strong><em>W — β × V(t-1) </em></strong>— yeh <strong>anticipated future position</strong> hai. Model pehle <strong>future mein jhaank</strong> raha hai, phir decide kar raha hai ki kitna bhaagna hai.</p><pre>optimizer = keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)</pre><p><strong>Real life analogy:</strong> Gaadi chalate waqt aap 200 meter aage dekh ke brake lagate hain — 2 meter pehle nahi. NAG exactly yeh karta hai.</p><p><strong>Kya badla?</strong> Overshoot bahut kam ho gaya. Minima ke paas jaake model <strong>slow ho jaata hai</strong> — kyunki future gradient already batata hai ki bhai, valley kareeb hai, speed kam kar.</p><p><strong>Lekin ek fundamental problem abhi bhi solve nahi hui thi.</strong> SGD, Momentum, NAG — teenon mein <strong>ek hi learning rate saare weights ke liye.</strong></p><p>Maan lo aapke model mein <strong><em>color </em></strong>wala feature hamesha update hota hai (har image mein color hai). Lekin <strong><em>edge case pattern </em></strong>wala feature rare hai — kabhi-kabhi dikhta hai. Dono ko same learning rate? <strong>Unfair.</strong> Rare feature ko bada step chahiye jab woh dikhe, frequent feature ko chhota.</p><p><em>Yeh woh samay tha jab game change hua — fixed learning rate se adaptive learning rate ki taraf.</em></p><h3>Chapter 4: AdaGrad — Har Weight Ko Apna Personal Tutor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EU5Ci0r6a_4Q91k6.jpeg" /></figure><p><strong>Pichle optimizers ki galti:</strong> Sab weights ko ek hi speed se padha rahe the. Class ke topper aur weakest student — dono ko same attention.</p><p><strong>AdaGrad ka idea:</strong> Har weight ke liye track karo ki uska gradient <strong>historically kitna bada raha hai.</strong> Jiska gradient hamesha bada hai — usko chhota step do (woh already seekh raha hai). Jiska gradient rare hai — usko bada step do (usse zyada push chahiye).</p><pre>G(t) = G(t-1) + [∇L(W)]²            ← squared gradients ka running total<br>W = W - (η / √(G(t) + ε)) × ∇L(W)   ← bade G ka chhota step, chhote G ka bada step</pre><pre>optimizer = keras.optimizers.Adagrad(learning_rate=0.01)</pre><p><strong>Kya badla?</strong> NLP aur recommender systems mein <strong>game changer</strong> tha. Sparse data — jahan kuch features rarely dikhte hain — wahan AdaGrad brilliant kaam karta hai. Har feature ko uski zaroorat ke hisaab se learning rate milta hai.</p><p><strong>Lekin AdaGrad ka ek fatal flaw tha — jo literally usse maar dalta tha.</strong></p><p><strong><em>G(t)</em></strong> ek <strong>cumulative sum</strong> hai. Yeh sirf badhta hai, <strong>kabhi ghatata nahi.</strong> Sochiye ek savings account jismein paisa sirf jaaye, nikle nahi.</p><p>100 epochs baad? G bada. 1000 epochs baad? G bahut bada. 10000 epochs baad? G itna bada ki:</p><p><strong><em>η / √(G(t))</em></strong> → <strong>practically zero.</strong></p><p>Learning rate <strong>itna chhota ho jaata hai ki model seekhna band kar deta hai.</strong> Weights freeze ho jaate hain. Training effectively <strong>mar jaati hai.</strong></p><p>AdaGrad ka problem yeh tha ki yeh <strong>kabhi bhoolata nahi.</strong> Epoch 1 ka gradient aur Epoch 10,000 ka gradient — dono ko equal importance deta hai. <em>Purane zamaane ke gradients aaj ki learning ko rok dete hain.</em></p><p><em>Ek optimizer tha jo apni hi success se mar gaya. Isi galti ne agla optimizer paida kiya.</em></p><h3>Chapter 5: RMSProp — AdaGrad Ka Doctor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*v1qkZZ70pyzbT8Xs" /></figure><p><strong>AdaGrad ki galti:</strong> Squared gradients ka cumulative sum sirf badhta tha, kabhi ghatata nahi. Learning rate monotonically zero ki taraf jaata tha.</p><p><strong>RMSProp ka fix:</strong> Ek genius level simple idea — cumulative sum ki jagah <strong>EWMA</strong> use karo.</p><p>Wahi EWMA jo humne Foundation 3 mein seekhi thi. Ab kaam aa rahi hai.</p><pre>V(t) = β × V(t-1) + (1-β) × [∇L(W)]²    ← EWMA, not cumulative sum!<br>W = W - (η / √(V(t) + ε)) × ∇L(W)</pre><p><strong>Farak sirf ek line ka hai.</strong> Lekin impact monumental hai. EWMA purani values ko <strong>gradually forget</strong> karta hai. Toh 10,000 epochs baad bhi V(t) ek reasonable number rehta hai — kyunki purane gradients ki importance automatically kam hoti jaati hai.</p><pre>optimizer = keras.optimizers.RMSprop(learning_rate=0.001, rho=0.99)</pre><p>Ek interesting baat — RMSProp ka koi formal paper nahi hai. Geoffrey Hinton ne isse <strong>Coursera ki ek lecture slide</strong> mein introduce kiya tha. Ek slide ne duniya badal di. Koi peer review nahi, koi arxiv paper nahi. Sirf ek idea jo itna achha tha ki community ne adopt kar liya.</p><p><strong>Kya badla?</strong> AdaGrad ke saare fayde — adaptive learning rate, sparse features handle — lekin ab <strong>learning rate marta nahi.</strong> Long training sessions bhi smooth.</p><p><strong>Lekin ek cheez missing thi.</strong> RMSProp mein <strong>momentum nahi hai.</strong> Yeh sirf learning rate adapt karta hai. Gradient ki direction mein speed build karna, flat regions tezi se cross karna — yeh capabilities nahi hain.</p><p><em>Ek taraf Momentum hai jiske paas direction ki samajh hai, lekin adaptive LR nahi. Doosri taraf RMSProp hai jiske paas adaptive LR hai, lekin momentum nahi.</em></p><p><em>Kash koi dono ko jod de…</em></p><h3>Chapter 6: Adam — Sabka Best, Ek Jagah</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/0*Az3lxnSLCe9HPlZK.png" /></figure><p>2014 .Diederik Kingma aur Jimmy Ba. Ek paper jo Deep Learning ko hamesha ke liye badal dega.</p><p><strong>Adam = Adaptive + Momentum.</strong> Literally Momentum aur RMSProp ka baccha.</p><h4>Adam Ke Andar Kya Chal Raha Hai?</h4><p>Do cheezein simultaneously track ho rahi hain:</p><p><strong>Pehla: Gradient ka EWMA (Momentum wala concept)</strong></p><pre>m(t) = β₁ × m(t-1) + (1-β₁) × ∇L(W)</pre><p>Yeh <strong>direction</strong> decide karta hai — kahan jaana hai, kitni speed se. Exactly Momentum jaisa.</p><p><strong>Doosra: Squared Gradient ka EWMA (RMSProp wala concept)</strong></p><pre>v(t) = β₂ × v(t-1) + (1-β₂) × [∇L(W)]²</pre><p>Yeh <strong>step size</strong> decide karta hai — har weight ko kitna bada step dena hai. Exactly RMSProp jaisa.</p><p><strong>Teesra: Bias Correction (Adam ka apna original contribution)</strong></p><p>Problem yeh hai ki shuru mein <strong><em>m(t)</em></strong> aur<strong><em> v(t)</em></strong> dono zero se start hote hain. Pehle kuch steps mein yeh <strong>biased</strong> hain — zero ki taraf. Bias correction isse fix karta hai:</p><pre>m̂(t) = m(t) / (1 - β₁ᵗ)<br>v̂(t) = v(t) / (1 - β₂ᵗ)</pre><p>Jaise-jaise <strong><em>t</em></strong> badhta hai, denominator 1 ke kareeb jaata hai, aur correction ka effect automatically kam ho jaata hai. <em>Self-correcting mechanism.</em></p><p><strong>Final Update:</strong></p><pre>W = W - η × m̂(t) / (√v̂(t) + ε)</pre><p><strong>Dekho kya ho raha hai:</strong> Numerator mein momentum hai (direction + speed), denominator mein adaptive scaling hai (per-weight step size). Dono milke <strong>smart updates</strong> de rahe hain.</p><pre>optimizer = keras.optimizers.Adam(<br>    learning_rate=0.001,   # default, rarely change karna padta hai<br>    beta_1=0.9,            # momentum ka β<br>    beta_2=0.999,          # RMSProp ka β<br>    epsilon=1e-7           # zero division protection<br>)</pre><h4>Adam Kyun Champion Hai?</h4><p><strong>Momentum</strong> se mila — fast convergence, saddle points escape, flat regions tezi se cross. <strong>RMSProp</strong> se mila — har weight ka personalized learning rate, sparse data handling. <strong>Bias correction</strong> se mila — initial training mein bhi stable behavior. Aur cherry on top — <strong>default hyperparameters almost hamesha kaam karte hain.</strong> Tune karna rare hai.</p><h4>Lekin Adam Ko Blindly God Mat Samjho</h4><p>Yeh woh section hai jo zyada-tar articles skip kar dete hain:</p><p><strong>Tabular data pe?</strong> SGD + Momentum + learning rate scheduler kabhi-kabhi Adam se <strong>better generalize</strong> karta hai. Some research suggest karti hai ki SGD sharper minima dhundhta hai — jo test data pe better perform karte hain.</p><p><strong>CNNs (Image Classification) mein?</strong> Industry standard <strong>SGD + Nesterov + cosine annealing scheduler</strong> hai — Adam nahi. ResNet, EfficientNet — sab isi pe train hue hain.</p><p><strong>Transformers mein?</strong> Adam nahi, <strong>AdamW</strong> use hota hai — jismein weight decay ko learning rate se decouple kiya gaya hai. GPT, BERT, LLaMA — sab AdamW pe trained hain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*ozdlMB2eIajibWslwSJa9Q.png" /></figure><h3>Hyperparameter Tuning — Sahi Settings Kaise Dhundhein?</h3><p>Optimizer choose kar liya. Architecture set hai. Ab sawaal hai — <strong>learning rate 0.01 rakhein ya 0.001? Batch size 32 ya 128? Dropout 0.3 ya 0.5?</strong></p><p>Agar aapke paas 5 hyperparameters hain aur har ek ke 4 options — toh 4⁵<strong>= 1024 combinations.</strong> Manually try karna? Please. Humari life itni lambi nahi.</p><h4>Keras Tuner — Machine Ko Kaam Karne Do</h4><pre>import keras_tuner as kt<br><br>def build_model(hp):<br>    model = keras.Sequential()<br>    <br>    # Neurons kitne? Machine decide karega<br>    model.add(Dense(<br>        units=hp.Int(&#39;units&#39;, min_value=32, max_value=256, step=32),<br>        activation=&#39;relu&#39;, kernel_initializer=&#39;he_normal&#39;<br>    ))<br>    model.add(BatchNormalization())<br>    model.add(Dropout(hp.Float(&#39;dropout&#39;, 0.1, 0.5, step=0.1)))<br>    <br>    model.add(Dense(1, activation=&#39;sigmoid&#39;))<br>    <br>    # Learning rate kitna? Machine decide karega<br>    model.compile(<br>        optimizer=keras.optimizers.Adam(<br>            learning_rate=hp.Choice(&#39;lr&#39;, [1e-2, 1e-3, 1e-4])<br>        ),<br>        loss=&#39;binary_crossentropy&#39;,<br>        metrics=[&#39;accuracy&#39;]<br>    )<br>    return model<br><br># RandomSearch - 20 random combos try karega<br>tuner = kt.RandomSearch(<br>    build_model,<br>    objective=&#39;val_accuracy&#39;,<br>    max_trials=20,<br>    directory=&#39;tuner_results&#39;<br>)<br><br>tuner.search(X_train, y_train, epochs=50, validation_split=0.2)<br><br># Winner kaun?<br>best = tuner.get_best_hyperparameters()[0]<br>print(f&quot;Best neurons: {best.get(&#39;units&#39;)}&quot;)<br>print(f&quot;Best dropout: {best.get(&#39;dropout&#39;)}&quot;)<br>print(f&quot;Best LR: {best.get(&#39;lr&#39;)}&quot;)</pre><h4>Kaunsi Search Strategy Kab?</h4><p><strong>RandomSearch</strong> — shuru mein yahi lagao. 20–30 trials mein surprisingly achha result deta hai. Research ne dikhaaya hai ki random search grid search se better hai zyada-tar cases mein.</p><p><strong>BayesianOptimization</strong> — past results se seekh ke smarter guesses lagata hai. Fewer trials, better results. Jab RandomSearch ke baad fine-tuning chahiye.</p><p><strong>Hyperband</strong> — jaldi failing combinations ko early terminate karta hai, resources achhe candidates pe focus karta hai. Best for large search spaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0MC3cJK6HrgGyrQJHscCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxTTe6BIqxTrVQg_2Q2LcA.png" /></figure><blockquote><em>SGD ne bola — main seedha chalunga, dhire hi sahi,</em> <em>Momentum bola — mujhe toh raftar chahiye bhai.</em> <em>NAG ne kaha — bhaagne se pehle dekh toh lo,</em> <em>AdaGrad ne har weight ko apna raasta diya — phir khud thak ke baith gaya.</em> <em>RMSProp ne usse uthaaya — bola bhoolna seekh, sab yaad mat rakh.</em> <em>Adam aaya, sab jod diya — bola ab ek saath chalte hain.</em> <em>Lekin yaad rakhna — champion woh nahi jo sab jaanta hai,</em> <em>Champion woh hai jo jaanta hai — kab kaunsa lagana hai</em></blockquote><p>Optimizers Deep Learning ka <strong>steering wheel</strong> hain. Model architecture body hai, data fuel hai, loss function GPS hai — lekin <strong>direction optimizer decide karta hai.</strong> Galat optimizer lagaya, toh ya toh destination pe pahunchenge nahi, ya galat destination pe pahunch jayenge.</p><p><strong>5 cheezein jo aaj se change kariye:</strong></p><p><strong>Pehla</strong> — Adam se shuru kariye, lekin samajh ke. Ab aapko pata hai ki andar Momentum + RMSProp + Bias Correction chal raha hai.</p><p><strong>Doosra</strong> — Plateau aaye toh pehle learning rate chhota kariye. Architecture change karna <strong>last resort</strong> hai, pehla nahi.</p><p><strong>Teesra</strong> — CNNs train kar rahe ho? SGD + Nesterov + Cosine Annealing try kariye. Industry yahi use karti hai.</p><p><strong>Chautha</strong> — Har optimizer ke peeche ki <strong>kyun</strong> yaad rakhiye, formula nahi. Formula Google pe milega. Kyun sirf samajhne se aayega.</p><p><strong>Paanchwa</strong> — Keras Tuner use kariye. Manual trial-error se aapka time aur sanity dono bachegi.</p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*Z2-XQhelN9kpd9FzBatr-w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78710b08a6be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Automated My Entire Excel Workflow In One Afternoon — VBA Did What 3 Hours Of Manual Work…]]></title>
            <link>https://medium.com/@ojas.arora14/i-automated-my-entire-excel-workflow-in-one-afternoon-vba-did-what-3-hours-of-manual-work-79e714420523?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/79e714420523</guid>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[vba]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Sat, 22 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-22T02:31:01.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Automated My Entire Excel Workflow In One Afternoon — VBA Did What 3 Hours Of Manual Work Couldn’t</h3><h4>Copy-paste, formatting, reporting — I was doing it all by hand like a fool. One afternoon with VBA and now my spreadsheet runs itself. From what even is a macro to writing real code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*RPveiiJmnmelIIcKxM-oZA.png" /></figure><h3>The Confession That Started It All</h3><p>Every Monday morning, I had the same ritual at 3Deality.</p><p>Open the orders spreadsheet. Copy data from Sheet1 to Sheet2. Format the headers. Apply formulas to 15 columns. Highlight overdue orders in red. Generate a summary. Email it.</p><p><strong>3 hours. Every. Single. Monday.</strong></p><p>I wasn’t doing anything creative. I wasn’t making decisions. I was a human copy-paste machine. A very expensive one.</p><p>Then one Monday, my laptop froze mid-copy. I lost 2 hours of work. No autosave. No backup. I sat there staring at a blank spreadsheet thinking — <em>There has to be a better way.</em></p><p>That afternoon, I Googled how to automate Excel. Every result said the same thing — <strong>VBA.</strong></p><p>I opened something called Visual Basic Editor, typed 5 lines I didn’t fully understand, hit Run — and <strong>Excel did in 3 seconds what took me 3 hours.</strong></p><p>I literally said out loud — <em>Where have you been all my life?</em></p><blockquote><em>That Monday, I lost 2 hours to a crash. That afternoon, I gained back every Monday for the rest of my life.</em></blockquote><p>This article is everything I learned that afternoon — and everything I wish someone had told me before I wasted months doing things by hand.</p><h3>What Even Is VBA? — The 60-Second Version</h3><p><strong>VBA = Visual Basic for Applications.</strong></p><p>It’s a programming language that lives <strong>inside</strong> Microsoft Excel (and Word, PowerPoint, Access too). You don’t install anything. You don’t download anything. It’s already there — hiding behind your spreadsheet, waiting for you to discover it.</p><p><strong>What can it do?</strong></p><p>Anything you do manually in Excel — VBA can do it automatically:</p><ul><li>Select cells, ranges, entire sheets</li><li>Copy-paste data between sheets or workbooks</li><li>Apply formulas to thousands of rows</li><li>Format cells (colors, fonts, borders)</li><li>Show message boxes and input prompts</li><li>Make decisions with IF statements</li><li>Loop through hundreds of rows in seconds</li><li>Create buttons that run your code with one click</li></ul><p><strong>The key insight:</strong> VBA is an <strong>object-oriented language</strong>. Everything in Excel is an object — a cell is an object, a sheet is an object, a workbook is an object. Each object has <strong>properties</strong> (what it is) and <strong>methods</strong> (what it can do).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m73wELVwt8JZtO6hAzQ7_g.png" /></figure><p>Once you get this — objects, properties, methods — <strong>you get VBA.</strong> Everything else is just learning which objects have which methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIbBz6nilBTsbahAo5QRUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZYN9hGAJwRfk52DlJcs5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vf-39YyNE_orBVyrZCIxyg.png" /></figure><p><strong>Cell A1 now says “Hello, VBA!” — bold, blue text, yellow background.</strong> You didn’t touch the cell. Code did it.</p><p>Let’s break it down:</p><ul><li><strong><em>Sub MyFirstMacro()</em></strong> —<strong> Sub</strong> means subroutine (a block of code). <strong>MyFirstMacro</strong> is the name you gave it. Parentheses are required.</li><li><strong><em>Range(“A1”).Value = “Hello, VBA!”</em></strong> — Object is<strong><em> Range(“A1”)</em></strong> , property is <strong><em>.Value </em></strong>, you&#39;re setting it to &quot;Hello, VBA!&quot;</li><li><strong><em>End Sub</em></strong> — marks the end of the subroutine.</li></ul><p><strong>That’s it.</strong> Every VBA macro follows this pattern: <strong>Sub Name() </strong>→ do stuff → <strong><em>End Sub</em></strong> . The &quot;do stuff&quot; part is where it gets fun.</p><h3>Enable Macros — Or Nothing Works</h3><p>You wrote the code. You hit Run. But when you reopen the file tomorrow — <strong>nothing works.</strong> Excel says macros are disabled.</p><p><strong>Why?</strong> Security. Macros can do anything — including harmful things. Microsoft disables them by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u537qtU0mQK_ELdkKd2HEQ.png" /></figure><p><strong>Important:</strong> Save your file as <strong><em>.xlsm (macro-enabled workbook)</em></strong>, NOT<strong><em> .xlsx</em></strong>. Regular <strong><em>.xlsx </em></strong>files strip out all VBA code when saved. I learned this the hard way — wrote 200 lines of code, saved as <strong><em>.xlsx</em></strong>, reopened, <strong>everything gone.</strong></p><h3>Understanding Objects — VBA’s Core Philosophy</h3><p>VBA revolves around <strong>objects.</strong> Think of Excel as a Russian nesting doll:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3avyp_WyCeKPonZAB8mxw.png" /></figure><p><strong>The mental model:</strong> You’re giving instructions to objects. <em>Hey Range A1, make your value ‘Hello’. Hey Sheet1, copy yourself. Hey Workbook, save yourself.</em></p><p>Once this clicks, VBA stops feeling like coding and starts feeling like <strong>talking to Excel.</strong></p><h3>Copy-Paste Using VBA — Your First Practical Win</h3><p>This is probably why you’re here. The thing you do 47 times a day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SbKUVf6L4nl3xUWPvRAqDg.png" /></figure><p><strong>That last one?</strong> It copies a template sheet, renames it with today’s date, and puts it at the end. I use this every Monday for 3Deality’s weekly reports. <strong>One click. Done.</strong></p><p>Remember when I said I spent 3 hours on Monday mornings? The copy-paste part alone was 45 minutes. Now it’s <strong>literally one click.</strong></p><h3>Using Excel Functions In VBA — Best Of Both Worlds</h3><p>You already know Excel functions — SUM, VLOOKUP, COUNTIF. Why learn new ones in VBA? <strong>You don’t have to.</strong> VBA gives you access to ALL of them through <strong><em>WorksheetFunction</em></strong> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*frbnrHXnqLmabztbVpiRyw.png" /></figure><p><strong><em>WorksheetFunction.Sum()</em></strong> — same as<strong><em> =SUM() </em></strong>in a cell, but now you can use it inside your code, assign it to variables, put it in IF statements, use it in loops.</p><p><strong>Pro tip:</strong> If a function exists in Excel, try <strong><em>WorksheetFunction.FunctionName() </em></strong>first before writing custom logic. No need to reinvent VLOOKUP.</p><h3>Message Boxes — Talk To Your Users</h3><p>One of my favorite VBA features. You can create popup messages that inform, warn, or ask the user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEitZtjGSSo91egGF2YiXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgzn5nCWCqPup8ncZiojJw.png" /></figure><p>I use these everywhere in 3Deality’s spreadsheets. Before deleting data, before sending reports, before overwriting files. <strong>It’s a 2-line safety net</strong> that has saved me from accidental deletions more times than I can count.</p><h3>Input Boxes — Get Data From Users</h3><p>Want the user to type something? InputBox is your friend:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muRfTvL2rGnf6vr7ukR_ig.png" /></figure><p><strong>Combine MsgBox + InputBox</strong> and you’ve got a basic user interface — no forms, no UserForms, no complexity. For small automation tasks, this is often all you need.</p><h3>Testing Your Code — Don’t Skip This</h3><p>You wrote a macro. Before you let it loose on your actual data — <strong>test it.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dY-Htwb9OQvA-nf2zRILA.png" /></figure><p><strong>Use this constantly.</strong> Before writing a full macro, test individual lines in the Immediate Window. It’s like having a scratch pad inside the editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOYGhuKPQ4xCoEQgR0Up_A.png" /></figure><p><strong><em>On Error GoTo ErrorHandler </em></strong>— if anything goes wrong, jump to the error handler instead of crashing. In production macros, <strong>always add this.</strong> Without it, one bad cell reference and your entire macro dies mid-execution.</p><h3>Comments — Future You Will Thank Present You</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgBkyPj_i-t4PFLOidZT2A.png" /></figure><p>Any line starting with <strong><em>‘</em></strong> (apostrophe) is a <strong>comment</strong>. VBA completely ignores it. It&#39;s just for humans.</p><h3>Variables &amp; Constants — Your Storage Boxes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efCmKtoax-DJt9UwiWDung.png" /></figure><h3>IF Statements — Teaching Excel To Think</h3><p>This is where VBA goes from automation to intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_SB5PYLAgbwbtj8D2s7UQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shTkA_nBlH5rF8C1Wg3M2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Fg0kJSLqQBURxibgCYGQ9Q.png" /></figure><p>Here’s the thing about VBA — it’s not trendy. Nobody’s posting VBA reels on Instagram. It doesn’t have a sleek logo or a developer conference. It’s the boring uncle at the family gathering who quietly runs half the world’s business operations.</p><p><strong>But that’s exactly why it’s powerful.</strong> Every company uses Excel. Every. Single. One. And 90% of them have someone spending hours doing things that a 10-line macro could do in seconds.</p><p>That Monday morning crash was the worst thing that happened to my week. But it was the best thing that happened to every Monday after.</p><p><strong>Your spreadsheet is waiting. Go automate it.</strong></p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*n9jBxKOQSQzaxgz572HVIg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79e714420523" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Hand Literally Left the Mouse After Discovering These Excel Shortcuts]]></title>
            <link>https://medium.com/@ojas.arora14/my-hand-literally-left-the-mouse-after-discovering-these-excel-shortcuts-076f8e2a683f?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/076f8e2a683f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-20T02:31:01.955Z</atom:updated>
            <content:encoded><![CDATA[<h4>I used to waste time scrolling, dragging, and fixing the same Excel mistakes again and again — until these shortcuts completely changed the way I work with spreadsheets.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*XN1U0I7rDlY_moCdlTZsxA.png" /></figure><blockquote>EAT , CODE , TRAIN ,REPEAT</blockquote><blockquote>EAT , SLEEP , EXCEL , REPEAT</blockquote><h3>Excel Ne Confidence Tod Diya Tha</h3><p>There was a time when I used to think Excel is just about typing numbers in boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LzEuf0ab8xxdikbPFclbSw.png" /></figure><p>I was doing everything manually:<br>Dragging with mouse, clicking menus again and again, wasting minutes on tasks that should take seconds.</p><p>That’s when I started learning keyboard shortcuts while actually working on real sheets.<br>Not theory. Not boring Top 100 Excel Tricks videos.</p><p>Just practical shortcuts that solved real problems I faced daily.</p><p>And honestly?<br>After learning these shortcuts, using Excel feels less like office work and more like using cheat codes in a game.</p><p>So if you also:</p><ul><li>hate wasting time in Excel,</li><li>work with huge datasets,</li><li>do repetitive tasks,</li><li>or just want to look like the smartest person in the room…</li></ul><p>These shortcuts will save your life.</p><h3>20+ Excel Shortcuts That Made Me 10x Faster</h3><h3>1. Freeze the Top Row Instantly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9yT-yFQqdaqtrMxtot_DYA.png" /></figure><h4><strong>Shortcut: <em>Alt + W + F + R</em></strong></h4><p>Ever scrolled down and forgot what each column means?<br>Yeah… same pain. This shortcut freezes the top row so headers always stay visible.</p><blockquote>Perfect for attendance sheets , sales data , marksheets and huge datasets</blockquote><h3>2. Jump to the Bottom of Data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TvR8ZvS190lYl0d75rF0kg.png" /></figure><h4><strong>Shortcut: <em>Ctrl + ↓</em></strong></h4><p>Instead of scrolling for eternity…<br>this jumps directly to the last filled cell.</p><blockquote>Feels illegal the first time you use it.</blockquote><h3>3. Jump Back to the Top</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5Ly_XTNrcj9g92PIc0mjw.png" /></figure><h4><strong>Shortcut:<em> Ctrl + ↑</em></strong></h4><p>Because scrolling back manually is medieval behavior.</p><h3>4. Select Cells Faster</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfAxOWf9aIPFTHsDEd0-Zg.png" /></figure><h4><strong>Shortcut: <em>Shift + Arrow Keys</em></strong></h4><blockquote>Need to select data quickly without touching the mouse?<br>This is the GOAT shortcut.</blockquote><p><em>You can select rows , columns , ranges and random sections within seconds.</em></p><h3>5. Copy Formula Across Cells</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZ6ZYvvHuHtZL2eMV8tH0g.png" /></figure><h4><strong>Shortcut:<em> Ctrl + R</em></strong></h4><p>Copies left cell data/formula to the right.</p><p>Useful when formulas need repeating , formatting should stay same and deadlines are attacking you.</p><h3>6. Drag Data Down Without Dragging</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6olEyKY7U6QkVYtXP3dYA.png" /></figure><h4><strong>Shortcut: <em>Ctrl + D</em></strong></h4><blockquote><em>Copies above cell content downward instantly. No mouse. No dragging.No suffering.</em></blockquote><h3>7. Select Entire Row or Column</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2HVHKXc6hqoyJkPyNVlgRw.png" /></figure><h4><strong>Shortcuts:</strong></h4><h4><strong><em>Shift + Space → Select Row</em></strong></h4><h4><strong><em>Ctrl + Space → Select Column</em></strong></h4><p>This shortcut genuinely feels overpowered.</p><h3>8. Insert New Row or Column Fast</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5w-hqkoPIaSFc3wR1CPuw.png" /></figure><h4><strong>Shortcut: <em>Ctrl + Shift + Plus(+)</em></strong></h4><blockquote>You know that annoying right-click → insert process?</blockquote><blockquote>Yeah… destroy it.</blockquote><h3>9. Delete Row or Column</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMRgHh35C0kFEYun-9mHRA.png" /></figure><h4><strong>Shortcut: <em>Ctrl + Shift + Minus(-)</em></strong></h4><blockquote>One clean shortcut.<br>One clean delete.</blockquote><h3>10. Move Rows &amp; Columns Like Magic</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3G3Xpo0Lf98Z2O0pm5U0Sw.png" /></figure><h4><strong><em>Select row/column → Hold Shift → Drag</em></strong></h4><p>This trick feels like hacking Excel.</p><blockquote>Perfect when data order gets messed up , rows need rearranging and client changes everything last minute .</blockquote><h3>11. Write in Multiple Lines Inside One Cell</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzL2AQI0S1xupoz7V_liDA.png" /></figure><h4><strong>Shortcut: <em>Alt + Enter</em></strong></h4><blockquote>This saved my formatting life.</blockquote><blockquote>Especially for addresses , long text , notes and product descriptions</blockquote><h3>12. Add Comments Quickly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51pOq2s5uwEr2-dMnMdlTw.png" /></figure><h4><strong>Shortcut: <em>Shift + F2</em></strong></h4><p>Perfect when working in teams and silently judging data mistakes.</p><h3>13. Jump to Any Cell Instantly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fcmQ9id9x691erIMoTEng.png" /></figure><h4><strong>Shortcut: <em>Ctrl + G</em></strong></h4><blockquote>Huge sheet?<br>Lost somewhere in cell universe?</blockquote><blockquote>This shortcut teleports you directly to any cell.</blockquote><h3>14. Switch Between Sheets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhZNY9DiKM2QdJwrubvwPw.png" /></figure><h4><strong>Shortcut:</strong> <strong><em>Ctrl + Page Up / Page Down</em></strong></h4><p>Fastest way to move across tabs without clicking.</p><h3>15. Auto Sum Like a Pro</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FK74v-fsCSjcd37Q9gRWgQ.png" /></figure><h4><strong>Shortcut: <em>Alt + Equal to(=)</em></strong></h4><blockquote>Excel instantly detects numbers and calculates total.</blockquote><blockquote>This shortcut alone probably saves hours every month.</blockquote><h3>16. Find &amp; Replace Everything</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hx3WuW7xvrVoisqhJUOTvg.png" /></figure><h4><strong><em>Shortcut:</em></strong> <strong><em>Ctrl + H</em></strong></h4><blockquote>One typo repeated 500 times?</blockquote><blockquote>Not anymore.</blockquote><h3>17. Replicate Previous Step</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*As4Dtni9bR7TFIvyd_BUbQ.png" /></figure><h4><strong>Shortcut: <em>F4</em></strong></h4><p>This shortcut saved me from formula disasters.</p><h3>18. Wrap Text Automatically</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJMsgRd5h8_jgsAvpX2R-g.png" /></figure><h4><strong>Shortcut:</strong> <strong><em>Alt + H + W</em></strong></h4><p>Makes long text readable without destroying column size.</p><h3>19. Select Everything Instantly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0gd-t1OFpoX_59TsPGF19A.png" /></figure><h4><strong>Shortcut:<em> Ctrl + A</em></strong></h4><blockquote>Press once:<br> → selects data range</blockquote><blockquote>Press twice:<br> → selects entire sheet</blockquote><p>Excel be like: Fine… take everything.</p><h3>20. Paste Only Values</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltXVKUttvzir7fCCDNJCUA.png" /></figure><h4><strong><em>Shortcut: Alt + H + V</em></strong></h4><blockquote>Because normal paste sometimes brings weird formattin , broken formulas and emotional damage</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLGY_A-FhSrTWtZW_v5GrQ.png" /></figure><h3>Funny Reality of Learning Excel</h3><p><strong><em>Before shortcuts:</em></strong></p><p><em>Where is that option again…?</em></p><p><strong><em>After shortcuts:</em></strong></p><p>Keyboard sounds intensify aggressively</p><p><strong><em>Before:</em></strong> 20 minutes task</p><p><strong><em>After:</em></strong> 2 minutes + confidence boost</p><h3>Ending — Excel Feels Different Now</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Fg0kJSLqQBURxibgCYGQ9Q.png" /></figure><p>I genuinely thought Excel experts were just built differently.</p><p><strong><em>But honestly?<br>Most of them simply know the right shortcuts.</em></strong></p><p><strong><em>And once you start using them daily…<br>you can never go back.</em></strong></p><p>Your mouse starts feeling unnecessary.</p><p>So next time you open Excel, try using even 4–5 shortcuts from this list.</p><p><strong>Trust me:<br>your future self will thank you.</strong></p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*n9jBxKOQSQzaxgz572HVIg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=076f8e2a683f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Learned to Run Powerful AI Models on My Own Laptop with Ollama]]></title>
            <link>https://medium.com/@ojas.arora14/how-i-learned-to-run-powerful-ai-models-on-my-own-laptop-with-ollama-d9c791f14f18?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c791f14f18</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-18T02:31:01.374Z</atom:updated>
            <content:encoded><![CDATA[<h4>From installing Ollama to running Llama, DeepSeek, and creating your own private AI assistant — a complete guide to local AI, smart workflows, and real-world automation.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ns0Tvz7Kyn6wUrd9SbyyKw.png" /></figure><blockquote>Jahan sapne bade hote hain, wahan internet slow bhi rukawat nahi banta…<br>Bas ek laptop aur sahi tools mil jaayein, toh AI bhi ghar baith kar chal padta hai.</blockquote><p>Artificial Intelligence ka naam aate hi zyadatar logon ke dimaag mein cloud tools, paid subscriptions, aur internet-based chatbots aate hain. Lekin kya ho agar main kahun ki aap <strong>powerful AI models apne khud ke laptop par run kar sakte ho</strong>, bina monthly fees ke, <em>bina privacy concern ke, aur bina internet dependency ke ?</em></p><p>Exactly yahi concept mujhe samajh aaya jab maine Ollama ke baare mein deeply seekha.</p><p><strong>Ollama </strong>ek aisa tool hai jo aapko local machine par Large Language Models (LLMs) run karne deta hai. Matlab aapke prompts, files, aur data aapke system ke andar hi rehte hain.</p><h3>Open Source Models VS Proprietary Models</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stoQNWuAXptA28h7cRFJ7g.png" /></figure><h3>Why Ollama is Getting So Popular</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*Agp31f6biORXIMkPWgC7Wg.png" /></figure><p>Aaj kal har koi AI use karna chahta hai, lekin sabke paas expensive subscriptions ya enterprise APIs ka budget nahi hota.</p><p><strong><em>Ollama isliye popular ho raha hai kyunki:</em></strong></p><ul><li>Local machine par models run karta hai</li><li>Privacy maintained rehti hai</li><li>Fast response milta hai</li><li>Open-source ecosystem support karta hai</li><li>Developers ke liye APIs available hain</li><li>Python aur automation tools ke saath kaam karta hai</li></ul><h3>What Exactly is Ollama?</h3><p>Simple words mein:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2l8CVx4JDfgC43fCKRprVA.png" /></figure><p>Yani aap kuch bhi pucho, Ollama us request ko local installed model tak bhejta hai aur answer return karta hai.</p><h3>How the Complete Workflow Looks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qU4e6Z-ZkUaxupRlm3yIJA.png" /></figure><h3>1. System Requirements</h3><ul><li>Visit <a href="https://ollama.com/">ollama.com</a></li><li>A modern computer (Mac, Windows, Linux)</li><li>Internet connection for the initial download</li><li>5–10GB free disk space (depending on the model)</li><li>~15 minutes of setup time</li><li><strong>RAM:</strong> 8GB minimum<br><strong>16GB+:</strong> Better<br><strong>GPU:</strong> Optional but useful<br><strong>SSD:</strong> Recommended</li></ul><h3>2. Installing Ollama</h3><p><strong>The easy way:</strong></p><ul><li>Visit <a href="https://ollama.com/">ollama.com</a></li><li>Download the installer for your system</li><li>Install it like any app (double-click and follow prompts)</li></ul><p><strong>Check it’s working:</strong></p><pre>ollama --version<br>ollama ps</pre><h3>3. Which Models You Can Run</h3><p><strong>Download your choice:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqqrPzDa56ODiuARIqJ7hQ.png" /></figure><pre>ollama pull llama3</pre><h3>4. Running a Model</h3><p>Start chatting instantly:</p><pre>ollama run llama3</pre><h3>5. Why Local AI Feels Different</h3><p>Cloud AI tools mein Internet required , Data external servers par jata hai , Rate limits ho sakte hain and Monthly cost lag sakti hai .</p><p>Lekin Local AI mein Full privacy , Offline use possible , One-time setup , Better control and Custom workflows lagte hai .</p><h3>6. Running First Prompt</h3><p>Example:</p><pre>ollama run llama3</pre><p>Then ask:</p><pre>Write a Python program for calculator</pre><p>Model instantly answer dega.</p><h3>7. Behind the Scenes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*QbQ2foKvuZW29nL0YojbcA.png" /></figure><p>Yahi process har AI model ke andar hota hai.</p><h3>8. Python Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*5cR_yj97msldLlwgK8wgYA.png" /></figure><p>Ye part sabse interesting tha.</p><p>Aap Python se Ollama models ko connect kar sakte ho</p><pre>import ollama<br><br>response = ollama.chat(<br>    model=&#39;llama3&#39;,<br>    messages=[<br>        {&#39;role&#39;:&#39;user&#39;,&#39;content&#39;:&#39;Write motivation quote&#39;}<br>    ]<br>)<br>print(response[&#39;message&#39;][&#39;content&#39;])</pre><h3>9. Tool Calling &amp; Automation</h3><p>Advanced level par models tools bhi use kar sakte hain.</p><h4>Example:</h4><pre>User: Weather batao<br>AI → Weather API call<br>AI → Final answer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N6wv4udxTid8v_7DZYm8QA.png" /><figcaption>Flow</figcaption></figure><h3>Mastering AI’s Behaviour</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w10xYYbiJcBWa_RPHi1e5Q.png" /></figure><h3>My Biggest Learning</h3><p>AI ka future sirf cloud mein nahi hai.</p><h4>AI ka future:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdzx0QSXWUMzo9ME_pqkJw.png" /></figure><p>Aur Ollama is movement ka important part hai.</p><p>Agar aap student ho, developer ho, creator ho, ya bas AI explore karna chahte ho — toh Ollama try karna banta hai.</p><p>Ek baar jab aap dekhoge ki <strong>powerful AI model aapke khud ke laptop par run ho raha hai</strong>, toh feeling hi alag hoti hai.</p><blockquote><strong><em>Jo kal sirf companies ke paas tha, aaj woh ek student ke laptop par chal raha hai…</em></strong></blockquote><blockquote><strong><em>Technology ka asli magic tab hota hai jab power sabke haath mein aa jaaye.</em></strong></blockquote><h4>Aur haan…</h4><p>Pehle log bolte the laptop gaming ke liye lete hain…<br>Ab lagta hai AI chalane ke liye lena padega</p><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-sm7SbuBGZbTAX4hZkwGIQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c791f14f18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Systems, One Internship: Building at the Intersection of Real-Time Infrastructure and Applied…]]></title>
            <link>https://medium.com/@ojas.arora14/two-systems-one-internship-building-at-the-intersection-of-real-time-infrastructure-and-applied-a7c5475909a8?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7c5475909a8</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 02:31:02 GMT</pubDate>
            <atom:updated>2026-08-15T02:31:02.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>Two Systems, One Internship: Building at the Intersection of Real-Time Infrastructure and Applied AI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYl3uL-5pNhSwaKsxJXKuw.png" /></figure><p>From January to June 2026, I completed my industrial training at <strong>Ultimez Technology Pvt. Ltd.</strong>, a technology-driven software product company headquartered in Hubballi, Karnataka, with an international presence in Dubai. Ultimez builds enterprise software, AI-integrated platforms, and cloud-native applications across FinTech, HealthTech, AgriTech, the creator economy, and news/media — operating with an agile, product-oriented engineering culture.</p><p>When I started this internship in January 2026, I had a rough idea of what I wanted to work on: something involving real-time systems, and something involving LLMs. By June, I had shipped two very different products that, together, covered almost the entire modern engineering stack — from WebSockets and MongoDB to LangChain and RabbitMQ.</p><p><a href="https://drive.google.com/file/d/1EXPrVcso0O_IpLdCDPWNXrsrxeXaZLVR/view?usp=sharing">Ultimez Internship.mp4</a></p><h3>Project I: AI-Enabled Collaboration System</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*-you6oPSK9uzar7TiWPLlw.png" /></figure><h4>The Problem</h4><p>Modern collaborative platforms — think Figma, Miro, Notion — solve real-time collaboration well, but most commercial solutions come with high licensing costs, limited extensibility, restricted infrastructure control, and minimal AI-native capability. With remote and hybrid work reshaping how engineering teams, enterprises, and educational institutions operate, there was a clear opening for an intelligent collaboration platform that combines real-time distributed interaction with AI-assisted workflows baked into the core architecture — not bolted on as an afterthought.</p><p>The engineering objective was to build a scalable, production-oriented collaborative platform supporting low-latency multi-user interaction, intelligent diagram generation, multimodal content analysis, and persistent session management within a cloud-ready architecture. Specific targets included:</p><ul><li>Sub-100 millisecond synchronization latency across distributed clients via persistent WebSocket connections</li><li>Frictionless, anonymous session initialization — no lengthy authentication flows</li><li>AI-assisted diagram generation from natural language</li><li>Multimodal analysis capable of semantically interpreting board content</li><li>Full auditability through persistent event tracking and session replay</li><li>A modular, microservices-ready architecture built for future scalability</li></ul><h4>System Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*p7yZwgTMnUm68jrCImPoBA.png" /></figure><p>The platform is built on <strong>React 18 and TypeScript</strong> for the client, <strong>Node.js and Express</strong> for backend services, <strong>Socket.io</strong> for real-time bidirectional communication, and <strong>MongoDB</strong> for persistent storage. Architecturally, it’s a structured monolith with clean microservices-ready boundaries across five layers: the client layer, a communication layer (WebSocket server + REST API gateway), a backend services layer, a data/AI layer, and an infrastructure layer — each with distinct responsibilities and interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*OMZQoo6WFmUuS0ffNJDAvg.png" /></figure><p>The core engineering challenge was distributed state synchronization: every drawing event, annotation, and interaction had to propagate across all connected clients in near real-time, persist to MongoDB for session recovery, and stay consistent under concurrent multi-user load. The WebSocket event lifecycle — from a user’s pointer event, through canvas serialization, payload validation, MongoDB persistence, and broadcast to every other connected client — was engineered to keep round-trip latency under 100ms at the 99th percentile.</p><h4>AI microservices</h4><p>Rather than treating AI as a bolt-on feature, the platform’s intelligence is implemented as a set of loosely coupled AI microservices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*V7lRCtxx2DDLl9B1muIXgg.png" /></figure><ul><li><strong>Prompt-to-Diagram Generator</strong> — converts natural language descriptions into valid Mermaid.js syntax via the Google Gemini Pro API, which is then parsed and rendered directly onto the collaborative canvas.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*Tkmfkn3C5JIJtwNleOlyqA.png" /></figure><ul><li><strong>Vision-Based Reverse Engineering</strong> — captures the canvas as a PNG, builds a multimodal payload, and sends it to the Gemini Pro Vision API, which returns a structured natural-language description identifying the components and relationships present on the board.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*fvqrORX7Zr_zvqlV5w9LBg.png" /></figure><ul><li><strong>Voice-to-Board System</strong> — a speech-driven interaction layer where verbal drawing instructions are transcribed, classified by an ML model, and executed as canvas operations in real time — removing dependency on manual input devices.</li><li><strong>Real-Time Thinking Trails</strong> — analyzes cursor movement and interaction patterns to generate live intent previews, improving awareness during simultaneous editing.</li><li><strong>Template Library Framework</strong> — reusable workflow templates and architecture layouts for rapid deployment inside active sessions.</li></ul><h4>Security and reliability</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*Kw1Ua_fVKyvPFnefFtZT9A.png" /></figure><p>APIs and WebSocket channels are protected through a multi-layer traffic protection setup:<strong><em> express-rate-limit </em></strong>on REST endpoints (100 requests/15 min), a sliding-window counter on Socket.io events (50 events/10 sec), an origin whitelist for CORS, and Helmet.js-based HTTP security headers aligned with OWASP standards. All collaborative interactions are persisted to MongoDB, enabling full version history and session replay — the platform can sequentially reconstruct a session for auditability and review.</p><h4>Deployment</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*qPS-mNRpfxccXRoCVPk1kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*0W9lgfnQVY_leO0gGnqtGw.png" /></figure><p>The platform is containerized with <strong>Docker</strong> and deployed on <strong>AWS EC2</strong>, with a production pipeline focused on container orchestration, runtime consistency, and service isolation. This project was completed in full — architecture, features, security hardening, testing, and production deployment all shipped within the training period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpE-DbKxnk88qRNvOjUuAQ.png" /></figure><h3>Project II: RAG-Based Document Intelligence Platform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*75lusAJwojQKjehpe-daWQ.png" /></figure><h4>The Problem</h4><p>Organizations sit on enormous volumes of unstructured documents — contracts, research papers, technical manuals, financial records, regulatory filings. That knowledge is valuable, but hard to extract efficiently: keyword search lacks contextual understanding, and generic AI chat tools often hallucinate when handling domain-specific information.</p><p>The engineering objective was to build an enterprise-grade document intelligence platform combining semantic retrieval with large language models through a <strong>Retrieval-Augmented Generation (RAG)</strong> architecture — delivering context-aware, source-grounded answers directly from uploaded documents, with production-level scalability and reliability.</p><h4>System Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*T-Yjb-KYirSG7gUeWtl9lg.png" /></figure><p>The platform integrates <strong>LangChain</strong> for orchestration, a <strong>Meta Llama-3.1–8B-Instruct</strong> model served through a HuggingFace Inference Endpoint for answer generation, <strong>sentence-transformers/all-MiniLM-L6-v2</strong> for embeddings, and <strong>FAISS</strong> for high-speed vector similarity search, with a <strong>Streamlit</strong> frontend. The architecture is organized into four layers: a user interface layer (file upload, chat interface, citation display), a message queue layer built on RabbitMQ, a core RAG module layer (document processing, vector database, retrieval chain), and an external API services layer for LLM inference — with Prometheus and Grafana handling observability on top.</p><h4>Asynchronous processing with RabbitMQ</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*_OA0WZLUII_0fxH_Jc28GQ.png" /></figure><p>The most significant architectural decision in this project was moving all long-running work off the main request path. Rather than blocking users while documents are chunked, embedded, and indexed, the pipeline runs through three independent RabbitMQ-backed worker queues:</p><ul><li><strong>doc_ocr (OCR Worker)</strong> — normalizes uploaded PDFs, DOCX, and TXT files into clean text; falls back to OCR via <strong><em>pytesseract/pdf2image</em></strong> for scanned documents where no text layer exists.</li><li><strong>doc_ingestion (Ingestion Worker)</strong> — chunks the normalized text, generates embeddings, and updates the persistent FAISS index.</li><li><strong>doc_reports (Report Worker)</strong> — generates markdown executive summaries from the indexed document chunks.</li></ul><h4>Engineering details</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*n0-0ZXEqWaj4J6UlYGVopQ.png" /></figure><p>A few production-oriented decisions stand out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qB2PfrbobMn26LST1eJKUQ.png" /></figure><ul><li><strong>Fail-fast configuration validation</strong> — missing environment variables or invalid API configs are caught immediately at startup rather than failing mid-request.</li><li><strong>Persistent vector storage</strong> — FAISS indexes are written to disk, so embeddings aren’t recomputed on every restart.</li><li><strong>Source-grounded responses</strong> — every answer is tied back to retrieved document context and cited sources, directly targeting hallucination reduction.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFMheFckPzL1vIF9DPJAIA.png" /></figure><ul><li><strong>Structured, rotating logs and Grafana-based monitoring</strong> — used to track ingestion pipelines, worker activity, queue status, and runtime failures across the distributed processing layer. A Grafana evaluation dashboard provides real-time visibility into retrieval accuracy, response quality, and worker execution status.</li></ul><h3>What This Experience Actually Taught Me</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NiDfGol_G4YJbBnDqgIoRQ.png" /></figure><p><strong>Real-time systems and AI systems fail in fundamentally different ways.</strong> In the collaboration platform, the risk is state desynchronization — clients drifting out of sync. In the document intelligence platform, the risk is hallucination — confident, ungrounded answers. Designing against each demanded a different engineering mindset, from WebSocket event design in one to retrieval-grounding strategy in the other.</p><p><strong>Deployment topology shapes architecture, not the other way around.</strong> Docker and AWS EC2 for the collaboration system, RabbitMQ-based async workers with HuggingFace inference endpoints for the document platform — in both cases, understanding where and how the system would actually run drove real design decisions, not just implementation details tacked on at the end.</p><p><strong>Treating AI as infrastructure, not a feature, changes how you build.</strong> Both projects avoided bolting AI on as a single API call. The collaboration system split its intelligence into distinct microservices (diagram generation, vision analysis, voice interaction); the document platform separated OCR, ingestion, and reporting into independent asynchronous stages. That separation made both systems easier to debug, scale, and reason about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xc2WGS6_x00tU2dxJrLHMA.png" /></figure><p><strong>Six months, two full-stack AI-integrated platforms</strong>, and a genuine bridge between academic learning and enterprise engineering practice — this internship gave me hands-on exposure to distributed real-time systems, retrieval-augmented AI architecture, and the production discipline (security, observability, fail-fast validation, containerized deployment) that separates a working prototype from a system built to last.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRY0vuY5w-S_2EKcZM20JA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7c5475909a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DLS Part 2 : Neural Network Beemar Hai — Chaliye Doctor Ki Tarah Ilaaj Karte Hain]]></title>
            <link>https://medium.com/@ojas.arora14/dls-part-2-neural-network-beemar-hai-chaliye-doctor-ki-tarah-ilaaj-karte-hain-9e7ad0542007?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e7ad0542007</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-08T02:31:01.551Z</atom:updated>
            <content:encoded><![CDATA[<h4>Overfitting ka bukhaar hai, vanishing gradient ka dard hai, unscaled features ka infection hai. Har bimari ka ek ilaaj hai — Dropout, Early Stopping, L2 Regularization, Feature Scaling. Deep Learning ki poori first-aid kit ek jagah</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*fu5sQ9yxXVGai1EHw2-49A.png" /></figure><blockquote><em>Seekha to bahut kuch tha maine duniya ke dastoor,</em></blockquote><blockquote><em>Par Neural Network ki bimari ne kar diya majboor.</em></blockquote><blockquote><em>Overfitting ka bukhaar, gradient ka dard tha gehra,</em></blockquote><blockquote><em>Tab doctor Deep Learning ne bataya — har dard ka hai ilaaj mehra.</em></blockquote><p>Socho ek patient aaya clinic mein. Naam hai <strong>Neural Network</strong>. Complaint yeh hai ki yeh training data par toh zabardast perform karta hai — lekin jab real duniya ka data aata hai, toh ghabraa jaata hai. Doctor ne poochha:</p><p>Bhai, teri training pe kitna zor tha? Kuch ziada toh nahi padha? Aur khana (data) scale karke khaya ya seedha khaaya?</p><h3>Loss Function kya hai?</h3><p>Jab doctor patient ko dekhta hai toh pehle temperature leta hai — kitna bukhaar hai? Isi tarah, <strong>Loss Function</strong> model ki galtiyon ko measure karta hai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*6573C_EDNlTM3dzo.png" /></figure><p>In machine learning, loss functions help models determine how wrong it is and improve itself based on that wrongness. They are mathematical functions that quantify the difference between predicted and actual values in a machine learning model, but this isn’t all they do.</p><p>A L<strong>oss function</strong> is a mathematical way to measure how good or bad a model’s predictions are compared to the actual results. It gives a single number that tells us how far off the predictions are. The smaller the number, the better the model is doing. Loss functions are used to train models.</p><p>The loss function estimates how well a particular algorithm models the provided data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*76reQLW3otNTrA7vuZnVqg.png" /></figure><h3>1. Regression Loss Functions</h3><p>These are used when your model needs to <strong>predict a continuous number</strong> such as predicting the price of a product or age of a person. Popular regression loss functions are:</p><h4>A. Mean Squared Error (MSE) Loss</h4><p>Mean Squared Error (MSE) Loss is one of the most widely used loss functions for regression tasks. It calculates the average of the squared differences between the predicted values and the actual values. It is simple to understand and sensitive to outliers because the errors are squared which can affect the loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*RczY_KsmL-isFO8PSExz7A.png" /></figure><pre>import numpy as np<br><br># Mean Squared Error<br>def mse(y, y_pred):<br>    return np.sum((y - y_pred) ** 2) / np.size(y)<br><br># Example usage<br>y_true = np.array([3, -0.5, 2, 7])<br>y_pred = np.array([2.5, 0.0, 2, 8])<br><br>mse_value = mse(y_true, y_pred)<br>print(&quot;Mean Squared Error:&quot;, mse_value)</pre><p><strong><em>Output:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/0*MN_W7AQU3J7rsFAh.png" /></figure><h4>B. Mean Absolute Error (MAE) Loss</h4><p>Mean Absolute Error (MAE) Loss is another commonly used loss function for regression. It calculates the average of the absolute differences between the predicted values and the actual values. It is less sensitive to outliers compared to MSE. But it is not differentiable at zero which can cause issues for some optimization algorithms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*KabKL3Y3QRsOv4-0g1N-4w.png" /></figure><pre>import numpy as np<br><br># Mean Absolute Error<br>def mae(y, y_pred):<br>    return np.mean(np.abs(y - y_pred))<br><br># Example usage<br>y_true = np.array([3, -0.5, 2, 7])<br>y_pred = np.array([2.5, 0.0, 2, 8])<br><br>mae_value = mae(y_true, y_pred)<br>print(&quot;Mean Absolute Error:&quot;, mae_value)</pre><p><strong><em>Output:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/0*TYKwYvbVDqwPrVZ7.png" /></figure><h4>C. Huber Loss</h4><p>Huber Loss combines the advantages of MSE and MAE. It is less sensitive to outliers than MSE and differentiable everywhere unlike MAE. It requires tuning of the parameter δ. Huber Loss is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*u5JiBV7AR1N3IJPuEFHXTg.png" /></figure><h3>2. Classification Loss Functions</h3><p>Classification loss functions are used to evaluate how well a classification model’s predictions match the actual class labels. There are different types of classification Loss functions:</p><h4>A. Binary Cross-Entropy Loss (Log Loss)</h4><p>Binary Cross-Entropy Loss is also known as Log Loss and is used for binary classification problems. It measures the performance of a classification model whose output is a probability value between 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*B2-dDYKdX8VffyHKeXD3-g.png" /></figure><p>where:</p><ul><li>n is the number of data points</li><li>yi is the actual binary label (0 or 1)</li><li>y^i is the predicted probability.</li></ul><pre>import numpy as np<br><br>def log_loss(y_true, y_predicted, epsilon=1e-15):<br>    y_predicted_new = np.maximum(np.minimum(y_predicted, 1-epsilon), epsilon)<br>    return -np.mean(y_true*np.log(y_predicted_new) + (1 - y_true) * np.log(1-y_predicted_new))<br><br># Example usage<br>y_true = np.array([1, 1, 0, 0, 1])<br>y_predicted = np.array([1, 1, 0, 0, 1])<br><br>loss_value = log_loss(y_true, y_predicted)<br>print(&quot;Log Loss:&quot;, loss_value)</pre><p><strong><em>Output:</em></strong> Log Loss: 9.992007221626415e-16</p><h4>B. Categorical Cross-Entropy Loss</h4><p>Categorical Cross-Entropy Loss is used for multiclass classification problems. It measures the performance of a classification model whose output is a probability distribution over multiple classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*zApjWeAExbF2316Ug6GkEA.png" /></figure><p>where:</p><ul><li>n is the number of data points</li><li>k is the number of classes,</li><li>yij​​ is the binary indicator (0 or 1) if class label j is the correct classification for data point i</li><li>y^ij is the predicted probability for class j.</li></ul><h4>C. Hinge Loss</h4><p>Hinge Loss is used for training classifiers especially for support vector machines (SVMs). It is suitable for binary classification tasks as it is not differentiable at zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*SNqfoO1fYoPkYyF2RZcWgw.png" /></figure><p>where:</p><ul><li>yi is the actual label (-1 or 1)</li><li>y^i​​ is the predicted value.</li></ul><blockquote>Doctor ki zuban mein: <strong>Loss = 0 matlab patient bilkul theek. Loss = high matlab abhi bahut kaam baaki hai!</strong></blockquote><h3>Gradient Descent — Pahaad se utarne ka raasta</h3><p>Ab diagnosis ho gayi — loss pata hai. Ab ilaaj chahiye. Yahaan aata hai <strong>Gradient Descent</strong>.</p><p><strong><em>Ek analogy:</em></strong> Socho tum pahaad ke upar ho — bilkul andhera hai, kuch dikh nahi raha. Tumhe neeche utarna hai (loss minimize karna hai). Tum kya karoge? Paon se feel karoge kaunsi taraf dhaalu hai, aur usi taraf ek kadam chaloge. Yahi hai Gradient Descent!</p><p>It is essential to use the right optimization method for a certain case in order to guarantee that the model is optimized successfully and reaches optimal performance.</p><p>It could be beneficial to go over a few linear regression topics before we get started with gradient descent. As you may remember, the formula for calculating a line’s slope is y = mx + b, where m stands for the slope and b for the y-intercept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*ljLBzHgArzwRHBhR.png" /></figure><p>Algorithms starts by defining initial weights and uses gradients to iteratively adjusts their values using <strong>update rule</strong> so that the Loss function is minimized.</p><h4>Gradient Descent Update rule</h4><p>The essence of <strong>Gradient Descent rule</strong> is that the direction that we intent to move-in should be at 18⁰⁰ with respect to the gradient i.e. <em>move in the direction opposite to the gradient</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*c-6NQUWPgQgnCEsp.png" /></figure><p>Gradient descent update rule is such that when the curve is steep, the gradient is large and when the curve is gentle, the gradient is small.</p><h4>Gradient Descent algorithm (Intuition)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*vQ6yOjLZXH5jE8dg.png" /></figure><p>Intuitively, gradient descent algorithm can be compared to the process of a blind folded man climbing the top of a hill with minimum steps along the way. He starts climbing the hill with large steps in the direction of steepest incline. Once he is close to the top, he takes smaller and smaller steps to avoid overshooting. In case of gradient descent, it is going down (minimizing loss) instead of climbing up and hence the word <strong>descent</strong> in algorithm.</p><blockquote><strong>Gradient Descent algorithm can be extended to a network of neurons with backpropagation, we need gradients of Loss function with respect to all weights and biases, which can be used to update gradient descent update rule.</strong></blockquote><p><strong>Learning rate</strong> is used to determine how fast or slow we should move to optimize weights. To reach the local minimum, learning rate should be set to an appropriate value, which is neither too low nor too high.</p><ul><li><strong><em>Too high learning rate</em></strong> — convergence may not happen as it keeps bouncing back and forth (see left image).</li><li><strong><em>Too small learning rate</em></strong> — convergence will take longer time (see right image).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*jM79bhy_BwDOK7hM.png" /></figure><h4>1. Batch gradient descent</h4><p>Batch gradient descent sums the error for each point in a training set, updating the model only after all training examples have been evaluated. This process referred to as a training epoch.</p><p>While this batching provides computation efficiency, it can still have a long processing time for large training datasets as it still needs to store all of the data into memory. Batch gradient descent also usually produces a stable error gradient and convergence, but sometimes that convergence point isn’t the most ideal, finding the local minimum versus the global one.</p><h4>2. Stochastic Gradient Descent</h4><p>SGD (Stochastic Gradient Descent) is a well-known machine learning optimization technique.</p><p>In this variation of gradient descent, the model parameters are adjusted for each iteration depending on the gradient of the cost function relative to a single training sample. Each iteration of this approach selects a single training sample at random. Gradient Descent modifies the model parameters less often than SGD, leading to faster convergence.</p><p>Yet, using a single training sample at random might lead to noisy updates and a very variable cost function. SGD, despite its noise, is commonly preferred over Gradient Descent because it converges more quickly and requires less memory to store the cost function gradients.</p><h4>3. Mini-batch Gradient Descent</h4><p>Mini-batch Gradient Descent is a Gradient Descent version that falls in between Stochastic Gradient Descent and Gradient Descent.</p><p>The model parameters are updated based on the average gradient of the cost function with respect to the model parameters across each mini-batch, which are smaller subsets of the training dataset of equal sizes. <strong><em>When compared to Gradient Descent and Stochastic Gradient Descent</em></strong>, Mini-batch Gradient Descent changes the model parameters more often. The noise of stochastic updates and the computing cost of full-batch updates are traded off, and mini-batch gradient descent strikes a compromise between the two.</p><p>It is the deep learning optimization method that is most frequently employed and provides a fair balance between speed and accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pFjFv71NeOuyTfd_.png" /></figure><h3>How to improve performance — model ki fitness training</h3><p>Neural Network train ho gaya — lekin accuracy kam hai, model weak hai. Jaise ek patient theek toh hua lekin abhi bhi kamzor hai. Doctor ki advice: <em>lifestyle improve karo!</em></p><h4>Bimari No 1 — Overfitting (zyada padhne ki bimari)</h4><p><strong><em>Symptom: </em></strong>Training accuracy 99%, Test accuracy 60%. Model ne training data rath liya — generalize nahi kar sakta.</p><p><strong><em>Ilaaj:</em></strong> Dropout, Regularization, Early Stopping, zyada data do.</p><h4>Bimari No 2— Underfitting (kam padhne ki bimari)</h4><p><strong><em>Symptom:</em></strong> Training accuracy bhi kam, Test accuracy bhi kam. Model ne kuch seekha hi nahi!</p><p><strong><em>Ilaaj:</em></strong><em> </em>Zyada neurons, zyada layers, zyada epochs, learning rate adjust karo.</p><p>Performance improve karne ke 6 golden tarike:</p><ol><li><strong><em>Feature Scaling (Data Normalization):</em></strong> Saare features ko same scale par laao (0 to 1 ya mean=0). Bina scaling ke, bade numbers wale features chhote walo ko dominate karte hain. Gradient sahi direction mein nahi jaata.</li><li><strong><em>Better Weight Initialization: </em></strong>Weights randomly initialize karo — lekin sahi range mein. Xavier ya He initialization use karo. Galat initialization se vanishing gradient problem aa jaati hai.</li><li><strong><em>Better Activation Functions:</em></strong> Sigmoid ki jagah ReLU use karo. ReLU fast hai, vanishing gradient se bachata hai. Output layer ke liye Softmax (classification) ya Linear (regression).</li><li><strong><em>Batch Normalization:</em></strong> Har layer ke baad data ko normalize karo. Training fast hoti hai, model stable rehta hai, aur higher learning rate use kar sakte ho.</li><li><strong>Early Stopping:</strong> Validation loss dekhte raho. Jab validation loss badhne lage aur training loss ghatta rahe — RUK JAO! Overfitting shuru ho gayi. Checkpoint save karo aur wahan se wapas aao.</li><li><strong><em>Zyada aur Behtar Data: </em></strong>Model ki accuracy ka sabse bada factor — data quality. Data augmentation karo (images rotate/flip karo), missing values handle karo, outliers hatao.</li></ol><blockquote><strong>Doctor ki tip:</strong> Pehle Feature Scaling karo — yeh akela hi kaafi baar 10–15% accuracy improve kar deta hai. Yeh sabse pehla aur sabse important step hai!</blockquote><h3>Dropout Layers — Kuch neurons ko chhuti do!</h3><p>Socho ek team hai jisme kuch log hamesha kaam karte hain aur baaki log unpe depend ho jaate hain. Agar woh log ek din aayein hi nahi — toh poori team fail ho jaayegi. Yahi problem hai neural network mein — neurons ek doosre pe zyada depend ho jaate hain. Iska naam hai <strong>Co-adaptation</strong>.</p><p><strong><em>Ilaaj?</em></strong> <strong>Dropout</strong> — training ke dauran randomly kuch neurons ko band kar do. Ek din yeh neurons nahi, ek din woh neurons nahi. Is tarah har neuron independent sochna seekhta hai!</p><p><strong><em>Dropout Rate (p): —</em></strong> Kitne neurons band karne hain. p = 0.5 matlab 50% neurons randomly band. p = 0.2 matlab sirf 20% band — chhote networks ke liye better.</p><p><strong><em>Testing mein: —</em></strong> Testing ke waqt KISI bhi neuron ko band mat karo. Lekin sab neurons ki weights ko (1-p) se multiply karo — taaki average output same rahe.</p><p><strong><em>Kahan lagayein? —</em></strong> Dense (fully connected) layers ke baad. Convolutional layers mein zyada zaroorat nahi, lekin chhote dropout (0.1–0.2) wahan bhi kaam karta hai.</p><p><strong>Analogy:</strong> Dropout waise hi kaam karta hai jaise army training mein har soldier ko alag alag survival skills sikhate hain — taaki agar kuch log na hon toh bhi team kaam kare. Har neuron apne baare mein sochna seekhta hai!</p><h3>Regularization — overfitting ka permanent ilaaj</h3><p>Dropout ek <strong><em>behavioral therapy</em></strong> thi. Regularization ek <strong>mathematical ilaaj</strong> hai — seedha loss function mein ek penalty add kar do agar weights bahut bade ho jaayein.</p><p>Sochlo ek student jo exam mein sab kuch rath leta hai — har chhoti baat yaad hai, lekin naya question aaya toh ghabraa jaata hai. Hum chahte hain ki model <em>simple patterns</em> seekhe, na ki training data ko word-for-word yaad kare. Regularization isi ko enforce karta hai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtXdFJXLyuhBchG4lCcb3A.png" /></figure><p><strong>λ (Lambda) — Doctor ka dose</strong></p><p><strong><em>Lambda bahut zyada:</em></strong> — Penalty itni zyada ki model underfitting karne lage. Weights itne chhote ho gaye ki model kuch seekh hi nahi sakta.</p><p><strong><em>Lambda bahut kam:</em></strong> — Penalty ka koi asar hi nahi. Overfitting waise hi hogi.</p><p><strong><em>Sahi Lambda (0.001 se shuru karo):</em></strong> — Cross-validation se tune karo. L2 ke liye 0.001–0.01 ek achha starting point hai.</p><blockquote><strong>Dropout vs Regularization — dono sath mein:</strong> Dropout behavioral hai (neurons band karo), Regularization mathematical hai (weights penalize karo). Dono milake lagao — double protection! Typically: Regularization pehle, phir Dropout upar se.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QxTTe6BIqxTrVQg_2Q2LcA.png" /></figure><blockquote><em>Dropout ne kaha — Main band ho jaata hoon taaki tum strong bano,</em></blockquote><blockquote><em>Regularization ne kaha — Main danda lagata hoon taaki tum humble raho.</em></blockquote><blockquote><em>Early Stopping ne kaha — Jab kaho main ruk jaata hoon,</em></blockquote><blockquote><em>Model ne kaha — Yaar, itni therapy ke baad bhi main overfit kyun ho jaata hoon!?</em></blockquote><blockquote>Aur doctor ne kaha — <em>Beta, asli duniya ka data aur lao. Code karte raho, theek ho jaoge!</em></blockquote><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Z2-XQhelN9kpd9FzBatr-w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e7ad0542007" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DLS Part 1 : Forget AI Hype.]]></title>
            <link>https://medium.com/@ojas.arora14/dls-part-1-forget-ai-hype-e7a4f9731022?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7a4f9731022</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-06T02:31:01.731Z</atom:updated>
            <content:encoded><![CDATA[<h3>DLS Part 1 : Forget AI Hype. Here’s What Deep Learning Actually Does (And Why It’s Weirder Than You Think)</h3><h4>From a single neuron to systems that see, speak, and predict — a no-nonsense deep dive into the architecture reshaping the world</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*kto5KlUwfPlhDyKYZD-7Ag.png" /></figure><blockquote><em>Dil ne kaha seekhna hai kuch naya,</em> <em>Dimag ne kaha — Neural Network bana.</em> <em>Pehle ek neuron se shuru kiya safar,</em> <em>Aaj machines khud bolti hain — Shukriya!</em></blockquote><h3>Introduction — Sab Bol Rahe Hain AI, AI — Par Hai Kya Yeh Cheez?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*XWMSTNnO8eUxUnVw.jpg" /></figure><p>Aap roz sunte hain — <em>AI ne yeh kiya, AI ne woh kiya.</em> ChatGPT poems likh raha hai. DALL-E paintings bana raha hai. Self-driving cars roads pe chal rahi hain. Par ek second ruko.</p><p>Kya aapne kabhi socha — <strong>yeh sab hota kaise hai?</strong> Andar se? Under the hood?</p><p>Agar aapka jawab hai <em>bhai, kuch code hoga</em>— toh technically sahi ho. Par woh code itna interesting hai ki ek baar samajh gaye, toh aap kabhi AI ko waise nahi dekhoge.</p><h3>Machine Learning vs Deep Learning — Farak Samjho Pehle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*inL-yXr0HzmmuvXE" /></figure><h4>Machine Learning — Jab Machine Rules se nahi, Examples se Seekhe</h4><p>Pehle zamaane ka programming simple tha —</p><blockquote><strong><em>Programmer:</em></strong><em> </em>Agar baarish ho, toh umbrella lo.</blockquote><blockquote><strong><em>Computer:</em></strong><em> </em>Ji huzoor.</blockquote><p>Yeh tha <strong>rule-based programming</strong>. Aap rules likhte, computer follow karta.</p><p>Par problem tab aayi jab hum chahte the ki computer <strong>spam emails</strong> pakde.</p><p>Sochо — kya rules likhoge?</p><ul><li><em>FREE likha ho — spam</em></li><li><em>WIN likha ho — spam</em></li><li><em>Aapki lottery lagi hai, uncle ne property di hai — spam</em></li></ul><p>Rules likhte likhte thak jaate. Spammers smarter ho jaate.</p><p><strong>Machine Learning ne kaha:</strong></p><blockquote>Bhai, rules mat likho. Mujhe 10,000 spam emails aur 10,000 normal emails dikhao. Main khud pattern dhundhlunga.</blockquote><p><strong>Formally:</strong></p><blockquote><em>Machine Learning = A computer program is said to </em><strong><em>learn</em></strong><em> from experience E, with respect to task T, and performance measure P, if its performance on T improves with E. — Tom Mitchell, 1997</em></blockquote><h3>Deep Learning — ML ka GPU-Powered Bhai</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PDnmSVPjvViyrGTUtBCWpA.png" /></figure><p>ML kaafi kaam ka tha. Par yeh cheezein nahi kar sakta tha —</p><ul><li>Photo mein cat identify karna</li><li>Hindi voice sun ke text likhna</li><li>Shakespeare jaisi poetry likhna</li></ul><p><strong>Kyun?</strong> Kyunki in tasks ke patterns bahut deep aur layered hain.</p><p><strong>Deep Learning</strong> = Machine Learning + <strong>Multi-layer Neural Networks</strong></p><p>Jitni zyada layers → Utne zyada complex patterns → Utna better performance</p><h3>History of Deep Learning — Yeh Journey Badi Interesting Hai</h3><blockquote>Yeh part log skip karte hain — mat karo. Context samjhoge toh sab clear ho jaayega.</blockquote><h4>1943 — Pehla Artificial Neuron</h4><p><strong>McCulloch &amp; Pitts</strong> ne pehla mathematical model of a neuron banaya. Simple binary model — 0 ya 1. Koi learning nahi thi, par idea revolutionary tha.</p><h4>1958 — Perceptron ka Janm</h4><p><strong>Frank Rosenblatt</strong> ne <strong>Perceptron</strong> banaya — pehla trainable neural network unit. US Navy ne fund kiya. New York Times ne likha — <em>Machine that can learn.</em> Excitement bahut zyada tha.</p><h4>1969 — Pehli AI Winter</h4><p><strong>Minsky &amp; Papert</strong> ne prove kiya ki Perceptron <strong>XOR problem</strong> solve nahi kar sakta. Funding band. Research ruk gayi. Yeh tha <strong>First AI Winter</strong>.</p><h4>1986 — Backpropagation Aaya</h4><p><strong>Rumelhart, Hinton &amp; Williams</strong> ne <strong>Backpropagation</strong> algorithm publish kiya. Multi-layer networks train ho sakti thi ab! Research phir shuru.</p><h4>1989–1998 — CNN ka Janm</h4><p><strong>Yann LeCun</strong> ne <strong>Convolutional Neural Networks (CNN)</strong> develop kiye. MNIST dataset pe handwritten digits recognize karne ke liye. Banks cheque recognition mein use karne lage.</p><h4>1990s–2000s — Second AI Winter</h4><p>Hardware slow tha. Data kam tha. Networks train hone mein bahut time lagta tha. SVMs (Support Vector Machines) ne Neural Networks ko replace kar diya temporarily.</p><h4>2006 — Hinton ka Comeback</h4><p><strong>Geoffrey Hinton</strong> ne <strong>Deep Belief Networks</strong> introduce kiye. “Deep Learning” term popular hua. Layer-by-layer pre-training se problem solve ki.</p><h4>2012 — AlexNet — Game Changer</h4><p><strong>ImageNet Competition</strong> — 1000 categories mein images classify karo. <strong>AlexNet</strong> (Hinton’s lab) ne 26% error rate se jeet — baaki sab ke 40%+ se bahut better. GPUs + Deep CNN = Revolution. Yahan se Deep Learning era shuru hua.</p><h4>2014–Present — Explosion</h4><ul><li><strong>2014</strong> — GANs (Generative Adversarial Networks) — Ian Goodfellow</li><li><strong>2015</strong> — ResNet — 152 layers deep network, human-level image recognition</li><li><strong>2017</strong> — Transformer architecture — “Attention is All You Need” paper</li><li><strong>2020</strong> — GPT-3, DALL-E</li><li><strong>2022</strong> — ChatGPT — mainstream AI</li><li><strong>2024</strong> — Multimodal models, AGI discussions</li></ul><h3>Neural Networks — Andar Se Samjho</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f41_J5687Bt5HfMjsu5grg.png" /></figure><p><strong>Kaam:</strong> Input lo → Process karo → Agar threshold cross ho → Fire karo (output do)</p><h4>Artificial Neuron (Perceptron) — Digital Copy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRIPbybq8w06XZz9BpM9JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*fTeFlQb5HzivrLFujuYpzQ.png" /></figure><h3>Perceptron — Deep Dive</h3><h4>Perceptron Kya Hai?</h4><p><strong>Perceptron = Sabse simple Neural Network unit</strong></p><p>Yeh ek <strong>binary classifier</strong> hai — do classes mein separate karta hai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*NyCNofXAVhTJNP7j.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIPmlELFrC2uq4vPGXpZxg.png" /></figure><h3>Perceptron ka Step-by-Step Kaam</h3><p><strong>Example:</strong> Spam Detection</p><ul><li>x₁ = “FREE” word count</li><li>x₂ = “WIN” word count</li><li>x₃ = Number of exclamation marks</li><li>y = 1 (spam) ya 0 (not spam)</li></ul><p><strong>Step 1 — Initialize:</strong></p><pre>import numpy as np<br><br># Random weights initially<br>w = np.array([0.1, -0.2, 0.3])<br>b = 0.0</pre><p><strong>Step 2 — Forward Pass:</strong></p><pre>def perceptron_forward(x, w, b):<br>    z = np.dot(w, x) + b      # Weighted sum<br>    y_hat = step_function(z)   # Activation<br>    return y_hat<br><br>def step_function(z):<br>    return 1 if z &gt;= 0 else 0</pre><p><strong>Step 3 — Calculate Error:</strong></p><pre>error = y_true - y_hat   # actual - predicted</pre><p><strong>Step 4 — Update Weights (Perceptron Learning Rule):</strong></p><pre>wᵢ_new = wᵢ_old + η · (y - ŷ) · xᵢ<br>b_new  = b_old  + η · (y - ŷ)</pre><p>Jahan <strong>η (eta)</strong> = Learning Rate (kitna bada step lena hai)</p><pre>def perceptron_update(w, b, x, y_true, y_hat, lr=0.1):<br>    error = y_true - y_hat<br>    w = w + lr * error * x<br>    b = b + lr * error<br>    return w, b</pre><h3>Perceptron Training — Complete Code</h3><pre>import numpy as np<br><br>class Perceptron:<br>    def __init__(self, learning_rate=0.1, epochs=100):<br>        self.lr = learning_rate<br>        self.epochs = epochs<br>        self.weights = None<br>        self.bias = None<br>    <br>    def fit(self, X, y):<br>        n_features = X.shape[1]<br>        <br>        # Initialize weights to zero<br>        self.weights = np.zeros(n_features)<br>        self.bias = 0<br>        <br>        # Training loop<br>        for epoch in range(self.epochs):<br>            for x_i, y_i in zip(X, y):<br>                # Forward pass<br>                z = np.dot(x_i, self.weights) + self.bias<br>                y_hat = 1 if z &gt;= 0 else 0<br>                <br>                # Update<br>                error = y_i - y_hat<br>                self.weights += self.lr * error * x_i<br>                self.bias    += self.lr * error<br>    <br>    def predict(self, X):<br>        z = np.dot(X, self.weights) + self.bias<br>        <br>return np.where(z &gt;= 0, 1, 0)<br># --- Test karo ---<br># AND Gate<br>X = np.array([[0,0],[0,1],[1,0],[1,1]])<br>y = np.array([0, 0, 0, 1])   # AND output<br>model = Perceptron(learning_rate=0.1, epochs=10)<br>model.fit(X, y)<br>print(model.predict(X))   # Output: [0 0 0 1] </pre><h3>Perceptron Convergence Theorem</h3><blockquote><strong><em>Theorem:</em></strong><em> Agar data </em><strong><em>linearly separable</em></strong><em> hai, toh Perceptron </em><strong><em>guaranteed</em></strong><em> converge karega — finite steps mein.</em></blockquote><p><strong>Par agar data linearly separable nahi hai?</strong> Perceptron kabhi converge nahi karega. Yahi hai uski biggest weakness.</p><h3>Types of Neural Networks</h3><h4>1. Feedforward Neural Network (FNN) / MLP</h4><p>Sabse basic type. Data ek direction mein flow karta hai — input se output tak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*Jn1QD83ebPbSJ_6bMl-thw.png" /></figure><p><strong>Use cases:</strong> Tabular data, classification, regression</p><pre>import torch<br>import torch.nn as nn<br><br>class FeedForward(nn.Module):<br>    def __init__(self):<br>        super().__init__()<br>        self.network = nn.Sequential(<br>            nn.Linear(784, 256),   # Input → Hidden<br>            nn.ReLU(),<br>            nn.Linear(256, 128),   # Hidden → Hidden<br>            nn.ReLU(),<br>            nn.Linear(128, 10)     # Hidden → Output (10 classes)<br>        )<br>    <br>    def forward(self, x):<br>        return self.network(x)</pre><h4>2. Convolutional Neural Network (CNN)</h4><p>Images ke liye designed. <strong>Spatial patterns</strong> detect karta hai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssTHcP2A79x5bWL8Bi_-hQ.png" /></figure><p><strong>Key Idea:</strong> Ek filter (kernel) poori image pe slide karta hai — edges, curves, textures detect karta hai.</p><pre>class CNN(nn.Module):<br>    def __init__(self):<br>        super().__init__()<br>        self.features = nn.Sequential(<br>            nn.Conv2d(1, 32, kernel_size=3),   # 32 filters of 3×3<br>            nn.ReLU(),<br>            nn.MaxPool2d(2),                    # Downscale by 2<br>            nn.Conv2d(32, 64, kernel_size=3),<br>            nn.ReLU(),<br>            nn.MaxPool2d(2)<br>        )<br>        self.classifier = nn.Linear(64*5*5, 10)<br>    <br>    def forward(self, x):<br>        x = self.features(x)<br>        x = x.view(x.size(0), -1)  # Flatten<br>        return self.classifier(x)</pre><p><strong>Use cases:</strong> Image classification, Object detection, Medical imaging</p><h4>3. Recurrent Neural Network (RNN)</h4><p>Sequential data ke liye. <strong>Memory</strong> hoti hai previous inputs ki.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wTBQZIL4Uid3zG6nzFSnQ.png" /></figure><p><strong>Problem:</strong> Long sequences mein <strong>vanishing gradient</strong> — purani memory <strong><em>bhool</em></strong> jaati hai.</p><p><strong>Solution:</strong> LSTM (Long Short-Term Memory) — memory gates se control karta hai.</p><p><strong>Use cases:</strong> Text generation, Speech recognition, Time series</p><h4>4. Transformer</h4><p><strong>2017 ka game-changer.</strong> Attention is All You Need paper. Sequences mein <strong>kisi bhi position ka kisi bhi position se direct connection</strong> — no sequential processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3sjdiThLskZ7sH7YQYekmA.png" /></figure><p><strong>Use cases:</strong> GPT, BERT, ChatGPT, Machine Translation, Everything modern</p><h4>5. Generative Adversarial Network (GAN)</h4><p>Do networks ek saath train hote hain — ek <strong>Generator</strong>, ek <strong>Discriminator</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_-d0Q2zQ7Q2wO-2QxltpQ.png" /></figure><p>Generator try karta hai Discriminator ko fool karne ki. Discriminator try karta hai pakadne ki. Dono improve hote rehte hain.</p><p><strong>Use cases:</strong> Deepfakes, Image generation, Data augmentation</p><h3>Activation Functions — Network ki Soul</h3><p>Activation functions non-linearity add karte hain. Inke bina network sirf ek linear transformation hoga — chahe kitni bhi layers lao.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nryyjmJWFu1Pt5co1IRHSw.jpeg" /></figure><h3>Perceptron Loss Function — Hinge Loss vs Binary Cross Entropy</h3><p>Loss Function batata hai — <em>Teri prediction kitni galat thi?</em></p><h4>Binary Cross Entropy (BCE) — Log Loss</h4><p>Classification problems ke liye sabse common.</p><p><strong>Formula:</strong></p><pre>L = -[y·log(ŷ) + (1-y)·log(1-ŷ)]</pre><p>Jahan:</p><ul><li>y = actual label (0 ya 1)</li><li>ŷ = predicted probability (0 to 1)</li></ul><p><strong>Intuition:</strong></p><pre>Agar y=1 (actual positive):<br>  L = -log(ŷ)<br>  <br>  ŷ = 0.99 → L = -log(0.99) ≈ 0.01   (Low loss)<br>  ŷ = 0.01 → L = -log(0.01) ≈ 4.6    (High loss)<br>  <br>Agar y=0 (actual negative):<br>  L = -log(1-ŷ)<br>  <br>  ŷ = 0.01 → L = -log(0.99) ≈ 0.01   (Low loss)<br>  ŷ = 0.99 → L = -log(0.01) ≈ 4.6    (High loss)</pre><pre>def binary_cross_entropy(y_true, y_pred):<br>    eps = 1e-15  # Avoid log(0)<br>    y_pred = np.clip(y_pred, eps, 1 - eps)<br>    return -np.mean(y_true * np.log(y_pred) + <br>                    (1 - y_true) * np.log(1 - y_pred))</pre><h4>Hinge Loss — SVM wali Loss</h4><p>SVMs aur kuch neural networks mein use hoti hai.</p><p><strong>Formula:</strong></p><pre>L = max(0, 1 - y · ŷ)</pre><p>Jahan y ∈ {-1, +1} (classes)</p><p><strong>Intuition:</strong></p><pre>Agar sahi side pe ho aur confident bhi:<br>  y=1, ŷ=2 → L = max(0, 1-2) = max(0,-1) = 0 <br><br>Agar galat side pe ho:<br>  y=1, ŷ=-1 → L = max(0, 1-(-1)) = max(0,2) = 2 <br>Agar sahi side par ho par barely:<br>  y=1, ŷ=0.5 → L = max(0, 1-0.5) = 0.5</pre><pre>def hinge_loss(y_true, y_pred):<br>    # y_true should be -1 or +1<br>    return np.mean(np.maximum(0, 1 - y_true * y_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kMz8hwZ47HifG0Jabi1hYA.png" /></figure><h3>Backpropagation in Neural Network</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*T3XZWgJYrcubYHnmZ4EexA.jpeg" /></figure><p>Backpropagation, short for Backward Propagation of Errors, is a key algorithm used to train neural networks by minimizing the difference between predicted and actual outputs. It works by propagating errors backward through the network, using the chain rule of calculus to compute gradients and then iteratively updating the weights and biases. Combined with optimization techniques like gradient descent, backpropagation enables the model to reduce loss across epochs and effectively learn complex patterns from data.</p><h4>Working of Back Propagation Algorithm</h4><p>The Back Propagation algorithm involves two main steps: the Forward Pass and the Backward Pass.</p><h4>1. Forward Pass Work</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*IxxhFTRi8X6hqh0Ax0Kh3Q.jpeg" /></figure><p>In forward pass the input data is fed into the input layer. These inputs combined with their respective weights are passed to hidden layers. For example in a network with two hidden layers (h1 and h2) the output from h1 serves as the input to h2. Before applying an activation function, a bias is added to the weighted inputs.</p><p>Each hidden layer computes the weighted sum (`a`) of the inputs then applies an activation function like ReLU (Rectified Linear Unit) to obtain the output (`o`). The output is passed to the next layer where an activation function such as softmax converts the weighted outputs into probabilities for classification.</p><h4>2. Backward Pass</h4><p>In the backward pass the error (the difference between the predicted and actual output) is propagated back through the network to adjust the weights and biases. One common method for error calculation is the Mean Squared Error (MSE) given by:</p><blockquote><strong><em>MSE=(Predicted Output−Actual Output)²</em></strong></blockquote><p>Once the error is calculated the network adjusts weights using gradients which are computed with the chain rule. These gradients indicate how much each weight and bias should be adjusted to minimize the error in the next iteration. The backward pass continues layer by layer ensuring that the network learns and improves its performance. The activation function through its derivative plays a crucial role in computing these gradients during Back Propagation.</p><h3>Problem With Perceptron — Kyun Single Layer Fail Karta Hai?</h3><h4>XOR Problem — Perceptron ki Achilles Heel</h4><p><strong>AND Gate</strong> — Perceptron solve kar leta hai:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJ410SVG1N0HeG-hCRrZGA.png" /></figure><p><strong>XOR Gate</strong> — Perceptron fail ho jaata hai:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hkAwJnnqyNFCuzcHcs8LEg.png" /></figure><p>Yeh <strong>linearly non-separable</strong> problem hai.</p><h4>Why Does This Matter?</h4><p>Real-world problems almost never linearly separable hote hain.</p><ul><li>Faces aur non-faces — linear nahi</li><li>Spam aur non-spam — complex boundaries</li><li>Cancer cells — highly non-linear</li></ul><p><strong>Single Perceptron = Sirf linear boundary = Real world ke liye inadequate</strong></p><h3>Solution — Multi-Layer Perceptron (MLP)</h3><p>XOR ko solve karne ke liye ek hidden layer add karo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oSwH2lJpCZO03YUfLor8A.png" /></figure><pre># XOR with MLP — PyTorch<br>import torch<br>import torch.nn as nn<br><br>model = nn.Sequential(<br>    nn.Linear(2, 4),    # 2 inputs → 4 hidden neurons<br>    nn.ReLU(),<br>    nn.Linear(4, 1),    # 4 hidden → 1 output<br>    nn.Sigmoid()<br>)<br>X = torch.tensor([[0,0],[0,1],[1,0],[1,1]], dtype=torch.float32)<br>y = torch.tensor([[0],[1],[1],[0]], dtype=torch.float32)<br>optimizer = torch.optim.Adam(model.parameters(), lr=0.1)<br>loss_fn = nn.BCELoss()<br>for epoch in range(1000):<br>    y_hat = model(X)<br>    loss = loss_fn(y_hat, y)<br>    optimizer.zero_grad()<br>    loss.backward()<br>    optimizer.step()<br>print(model(X).detach().round())<br># Output: [[0.],[1.],[1.],[0.]] </pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QxTTe6BIqxTrVQg_2Q2LcA.png" /></figure><blockquote><em>Ek neuron ne kaha dusre neuron se,</em> <em>Bhai, mujhe kuch samajh nahi aata.</em> <em>Dusre ne kaha — Chill kar,</em> <em>hazaar epochs ke baad sab clear ho jaayega.</em></blockquote><blockquote><em>Tum bhi same ho abhi — confused, overwhelmed.</em> <em>Par yahi confusion hai jo seekhne ki nishani hai.</em> <em>Ek baar aur padho. Code chalao. Experiment karo.</em> <em>Deep Learning seekhna ek gradient descent hai — dheere dheere, step by step, loss kam hoti jaayegi.</em></blockquote><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Z2-XQhelN9kpd9FzBatr-w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7a4f9731022" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GenAI Ka Skyline : LLM Ne Socha, Tool Ne Kiya — LangChain Mein Tool Calling Ka Poora Raaz]]></title>
            <link>https://medium.com/@ojas.arora14/genai-ka-skyline-llm-ne-socha-tool-ne-kiya-langchain-mein-tool-calling-ka-poora-raaz-6f32e10eee75?source=rss-08e512e965cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f32e10eee75</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-04T02:31:01.388Z</atom:updated>
            <content:encoded><![CDATA[<h4>Jab LLM sirf sochna band kare aur asli kaam shuru ho — Tool Binding se Tool Execution tak, step by step</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZjq_ZXtaqfaB-jUDrNRnQ.png" /></figure><blockquote><em>Sochna LLM ka kaam hai, karna Tool ka — Dono milke bante hain ek poora fool-proof formula.</em></blockquote><h3>Pehle Samjho — Teen Alag Cheezein Hain Yahan</h3><p>Bahut log <strong>Tool Calling</strong> ko ek hi cheez samajh lete hain. Lekin actually yahan <strong>teen alag steps</strong> hote hain — aur teeno ka kaam alag hai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q5QkBknRwHZ5EOBSSqBTeA.png" /></figure><p>Inhe ek ek karke samjhte hain.</p><h3>Step 1 — Tool Binding: LLM Ko Menu Dikhaao</h3><p>Tool Binding matlab — apne tools ko LLM ke saath <strong>register</strong> karna. Iske baad LLM jaanta hai:</p><ul><li>Kaunse tools available hain</li><li>Har tool kya karta hai (description se)</li><li>Har tool ka input format kya hai (schema se)</li></ul><p><strong>Ek important baat</strong> — har LLM tool binding support nahi karta. GPT-4, Gemini, Claude jaisi modern models karte hain. Purane ya simple models nahi.</p><pre>from langchain_google_genai import ChatGoogleGenerativeAI<br>from langchain_core.tools import tool<br>from langchain_core.messages import HumanMessage<br><br># Pehle tool banao<br>@tool<br>def multiply(a: int, b: int) -&gt; int:<br>    &quot;&quot;&quot;Given 2 numbers a and b this tool returns their product&quot;&quot;&quot;<br>    return a * b<br><br># LLM banao<br>llm = ChatGoogleGenerativeAI(model=&quot;gemini-2.5-flash&quot;, google_api_key=&quot;API_KEY&quot;)<br><br># Tool bind karo - bas yahi hai Tool Binding<br>llm_with_tools = llm.bind_tools([multiply])</pre><p><strong><em>bind_tools()</em></strong> ke baad LLM ek naya version ban jaata hai — ab use pata hai ki <strong><em>multiply </em></strong>tool exist karta hai aur kab use karna hai.</p><h3>Step 2 — Tool Calling: LLM Sirf Suggest Karta Hai, Run Nahi Karta</h3><p>Tool Calling is the process where the LLM decides, during a conversation or task, that it needs to use a specific tool (function) — and generates a structured output with:</p><ul><li>The name of the tool</li><li>And the arguments to call it with</li></ul><p>Yeh sabse important point hai — <strong>LLM tool ko actually run nahi karta.</strong> Woh sirf yeh bolta hai:</p><blockquote><em>Yaar, is query ke liye </em><strong>multiply</strong> <em>tool use karna chahiye, aur input yeh hoga: </em><strong>{a: 3, b: 1000}</strong></blockquote><p>Dekho practically:</p><pre># Ek normal query — tool ki zaroorat nahi<br>llm_with_tools.invoke(&#39;Hi how are you&#39;)<br># content=&quot;I&#39;m doing well, thank you!&quot;<br># tool_calls=[]  ← koi tool suggest nahi kiy</pre><pre># Yeh query tool maangti hai<br>llm_with_tools.invoke(&#39;can you multiply 3 with 1000&#39;)<br># content=&#39;&#39;       ← koi text answer nahi diya<br># tool_calls=[{&#39;name&#39;: &#39;multiply&#39;, &#39;args&#39;: {&#39;a&#39;: 3, &#39;b&#39;: 1000}, &#39;id&#39;: &#39;...&#39;, &#39;type&#39;: &#39;tool_call&#39;}]</pre><p><strong>Notice karo</strong> — jab tool use karna hota hai, LLM ka <strong><em>content</em></strong> empty ho jaata hai aur <strong><em>tool_calls</em></strong> mein suggestion aa jaata hai.</p><p>Tool call ke andar yeh hota hai:</p><pre>result = llm_with_tools.invoke(&#39;can you multiply 3 with 1000&#39;)<br><br>result.tool_calls[0]<br># {&#39;name&#39;: &#39;multiply&#39;, &#39;args&#39;: {&#39;a&#39;: 3, &#39;b&#39;: 1000}, &#39;id&#39;: &#39;unique-id&#39;, &#39;type&#39;: &#39;tool_call&#39;}<br><br>result.tool_calls[0][&#39;args&#39;]<br># {&#39;a&#39;: 3, &#39;b&#39;: 1000}  ← yahi input tool mein jaayega</pre><h3>Step 3 — Tool Execution: Ab Asli Kaam Hoga</h3><p>Tool Execution is the step where the actual python function(tool) is run using the input arguments that the LLM suggested during tool calling .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0amzrsDsoXJp-bUhiMJmSQ.png" /></figure><p>Yahan actual Python function chalega. Do tarike se kar sakte ho:</p><p><strong>Tarika 1 — Sirf args bhejo (sirf result milega):</strong></p><pre>multiply.invoke(result.tool_calls[0][&#39;args&#39;])<br># 3000</pre><p><strong>Tarika 2 — Poora tool_call bhejo (ToolMessage milega):</strong></p><pre>multiply.invoke(result.tool_calls[0])<br># ToolMessage(content=&#39;3000&#39;, name=&#39;multiply&#39;, tool_call_id=&#39;...&#39;)</pre><p><strong>ToolMessage kyun better hai?</strong> Kyunki is ToolMessage ko wapas LLM ko bhej sakte ho — aur LLM is result ko dekh ke final human-readable answer deta hai.</p><h3>Poora Flow — Conversation History Ke Saath</h3><p>Yeh hai complete picture — kaise saari cheezein ek conversation mein milti hain:</p><pre># Step 1 — Human query<br>query = HumanMessage(&#39;can you multiply 3 with 1000&#39;)<br>messages = [query]<br><br># Step 2 - LLM se invoke karo (Tool Calling hogi)<br>result = llm_with_tools.invoke(messages)<br>messages.append(result)  # AIMessage add karo history mein<br><br># Step 3 - Tool execute karo (Tool Execution)<br>tool_result = multiply.invoke(result.tool_calls[0])<br>messages.append(tool_result)  # ToolMessage add karo history mein<br><br># Step 4 - Ab poora context de ke final answer maango<br>llm_with_tools.invoke(messages).content<br># &#39;3 multiplied by 1000 is 3000.&#39;</pre><p>Ab <strong><em>messages</em></strong> list mein teen cheezein hain:</p><ul><li><strong><em>HumanMessage </em></strong>— user ki query</li><li><strong><em>AIMessage</em></strong> — LLM ka tool suggestion</li><li><strong><em>ToolMessage </em></strong>— tool ka actual result</li></ul><p>Yahi <strong>conversation history</strong> hai. LLM teeno ko dekh ke final answer deta hai.</p><h3>Real Project — Currency Converter Banao</h3><p>Ab in sab concepts ko ek real problem pe lagate hain — <strong>INR to USD converter.</strong></p><p>Do tools banenge:</p><ul><li><strong><em>get_conversion_factor </em></strong>— live conversion rate fetch karega API se</li><li><strong><em>convert</em></strong> — rate aur value multiply karega</li></ul><pre>import requests<br>from langchain_core.tools import tool<br>from langchain_core.messages import HumanMessage<br><br>@tool<br>def get_conversion_factor(base_currency: str, target_currency: str) -&gt; float:<br>    &quot;&quot;&quot;<br>    This function fetches the currency conversion factor<br>    between a given base currency and a target currency<br>    &quot;&quot;&quot;<br>    url = f&#39;https://v6.exchangerate-api.com/v6/YOUR_API_KEY/pair/{base_currency}/{target_currency}&#39;<br>    response = requests.get(url)<br>    return response.json()<br><br>@tool<br>def convert(base_currency_value: int, conversion_rate: float) -&gt; float:<br>    &quot;&quot;&quot;<br>    Given a currency conversion rate this function calculates<br>    the target currency value from a given base currency value<br>    &quot;&quot;&quot;<br>    return base_currency_value * conversion_rate</pre><p>Tools test karte hain:</p><pre>get_conversion_factor.invoke({&#39;base_currency&#39;: &#39;USD&#39;, &#39;target_currency&#39;: &#39;INR&#39;})<br># {&#39;conversion_rate&#39;: 85.47, &#39;base_code&#39;: &#39;USD&#39;, &#39;target_code&#39;: &#39;INR&#39;, ...}<br><br>convert.invoke({&#39;base_currency_value&#39;: 10, &#39;conversion_rate&#39;: 85.47})<br># 854.7</pre><h3>Problem — Parallel Tool Calling Ka Chakkar</h3><p>Jab hum yeh query karte hain:</p><blockquote>What is the conversion factor between INR and USD, and convert 10 INR to USD?</blockquote><p>LLM <strong>dono tools ek saath (parallel)</strong> call karta hai. Problem yeh hai — <strong><em>convert</em></strong> tool ko<strong><em> conversion_rate</em></strong> chahiye, jo <strong><em>get_conversion_factor</em></strong> ke run hone ke baad milega. Lekin parallel mein run hone ki wajah se LLM apni training data se <strong>ek purana galat rate</strong> daal deta hai.</p><pre>ai_message.tool_calls<br># [<br>#   {&#39;name&#39;: &#39;get_conversion_factor&#39;, &#39;args&#39;: {&#39;base_currency&#39;: &#39;INR&#39;, &#39;target_currency&#39;: &#39;USD&#39;}},<br>#   {&#39;name&#39;: &#39;convert&#39;, &#39;args&#39;: {&#39;base_currency_value&#39;: 10, &#39;conversion_rate&#39;: 73.73}}<br>#                                                                         ↑ GALAT! Purana value<br># ]</pre><h3>Solution — InjectedToolArg</h3><p><strong><em>InjectedToolArg</em></strong> ek tarika hai jisse LLM ko bolta hoon — <strong>yeh argument tum mat bharo, main (developer) inject karunga.</strong></p><pre>from langchain_core.tools import InjectedToolArg<br>from typing import Annotated<br><br>@tool<br>def get_conversion_factor(base_currency: str, target_currency: str) -&gt; float:<br>    &quot;&quot;&quot;<br>    This function fetches the currency conversion factor<br>    between a given base currency and a target currency<br>    &quot;&quot;&quot;<br>    url = f&#39;https://v6.exchangerate-api.com/v6/YOUR_API_KEY/pair/{base_currency}/{target_currency}&#39;<br>    response = requests.get(url)<br>    return response.json()<br><br>@tool<br>def convert(base_currency_value: int, conversion_rate: Annotated[float, InjectedToolArg]) -&gt; float:<br>    &quot;&quot;&quot;<br>    Given a currency conversion rate this function calculates<br>    the target currency value from a given base currency value<br>    &quot;&quot;&quot;<br>    return base_currency_value * conversion_rate</pre><p>Ab LLM <strong><em>convert </em></strong>ke liye<strong><em> conversion_rate </em></strong>nahi bharta:</p><pre>ai_message.tool_calls<br># [<br>#   {&#39;name&#39;: &#39;get_conversion_factor&#39;, &#39;args&#39;: {&#39;base_currency&#39;: &#39;INR&#39;, &#39;target_currency&#39;: &#39;USD&#39;}},<br>#   {&#39;name&#39;: &#39;convert&#39;, &#39;args&#39;: {&#39;base_currency_value&#39;: 10}}<br>#                               ↑ conversion_rate nahi hai — sahi hai!<br># ]</pre><h3>Orchestrator Code — Hum Khud Bridge Banate Hain</h3><p>Ab hum developer khud donon tools ke beech coordinator ka role nibhate hain:</p><pre>import json<br><br>for tool_call in ai_message.tool_calls:<br>    # Pehle tool run karo - conversion rate fetch karo<br>    if tool_call[&#39;name&#39;] == &#39;get_conversion_factor&#39;:<br>        tool_message1 = get_conversion_factor.invoke(tool_call)<br>        conversion_rate = json.loads(tool_message1.content)[&#39;conversion_rate&#39;]<br>        messages.append(tool_message1)<br>    # Doosra tool run karo - pehle tool ka result inject karo<br>    if tool_call[&#39;name&#39;] == &#39;convert&#39;:<br>        tool_call[&#39;args&#39;][&#39;conversion_rate&#39;] = conversion_rate  # Inject!<br>        tool_message2 = convert.invoke(tool_call)<br>        messages.append(tool_message2)<br># Final answer maango<br>llm_with_tools.invoke(messages).content<br># &quot;The conversion factor between INR and USD is 0.0117.<br>#  Based on this, 10 INR equals 0.117 USD.&quot;</pre><p>Hum <strong>Orchestrator</strong> ban gaye — dono tools ke beech ki missing link humne complete ki.</p><h3>Yeh AI Agent Hai Kya?</h3><p><strong>Nahi.</strong></p><p>Yeh ek manually orchestrated pipeline hai. Humne khud decide kiya ki pehle kaunsa tool chalega, phir kaunsa.</p><p>Ek <strong>AI Agent</strong> woh hota jab LLM khud autonomously yeh decide karta — problem tod ke, sequentially tools use karta, aur bina hamari help ke final answer deta. Woh next part mein aayega!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZ0jgwB3X3MU2NheiUemWg.png" /></figure><blockquote><em>LLM ne socha, tool ne kiya — Dono ne milke kaam tamaam kiya.</em> <em>Akela LLM tha bas ek bright idea,</em> <em>Tools ke saath bana ek poora machinery.</em></blockquote><p>Agar yeh article kaam ka laga toh clap maar do, share kar do. Aur agar koi cheez galat lagi ya confusing lagi — comment karo, fix karenge.</p><p><strong>Happy Learning &amp; Happy Coding!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-sm7SbuBGZbTAX4hZkwGIQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f32e10eee75" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>