<?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 Kirthan Kaverappa ck on Medium]]></title>
        <description><![CDATA[Stories by Kirthan Kaverappa ck on Medium]]></description>
        <link>https://medium.com/@timeflagtbots?source=rss-a40f57dfd0cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qoucBHv4IW-wPehM</url>
            <title>Stories by Kirthan Kaverappa ck on Medium</title>
            <link>https://medium.com/@timeflagtbots?source=rss-a40f57dfd0cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 09:14:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@timeflagtbots/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[Bit Reader & Bit Writer (Using an Egg Carton Analogy)]]></title>
            <link>https://medium.com/@timeflagtbots/bit-reader-bit-writer-using-an-egg-carton-analogy-93a0c011694d?source=rss-a40f57dfd0cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/93a0c011694d</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Kirthan Kaverappa ck]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 16:37:06 GMT</pubDate>
            <atom:updated>2026-07-05T16:37:06.079Z</atom:updated>
            <content:encoded><![CDATA[<p>Refer to the linked simulation to get the overall idea…</p><p><em>‎‎</em><a href="https://gemini.google.com/share/20e710d9dee3?skid=f27865cb-31af-49a7-a141-0307937a8aa6"><em>Click Here to Proceed to the Simulation</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*R4H5kHMDRHzIL3Mc6KvF1w.png" /></figure><p>Imagine you’re shipping eggs from a shop to customers.</p><p>An egg carton can hold <strong>8 eggs</strong> (just like a <strong>byte holds 8 bits</strong>).</p><h3>Scenario</h3><ul><li><strong>Person 1</strong> orders <strong>1 egg</strong>.</li><li><strong>Person 2</strong> orders <strong>4 eggs</strong>.</li></ul><p>What would you do?</p><p>Would you place Person 1’s single egg into a brand-new 8-slot carton, leaving the other 7 slots empty?</p><p>Then take another new carton for Person 2’s 4 eggs, leaving 4 empty slots?</p><p>That would waste a lot of space.</p><p>Instead, you would pack them efficiently into the same carton.</p><ul><li>Person 1 uses <strong>1 slot</strong></li><li>Person 2 uses <strong>4 slots</strong></li><li><strong>3 slots remain free</strong> for future orders</li></ul><p>Once all 8 slots are occupied, you start filling the next carton.</p><p>This is exactly what a <strong>Bit Writer</strong> does.</p><p>Instead of wasting an entire byte for every small value, it packs multiple small values together into bytes.</p><h3>What does a Bit Writer do?</h3><p>A <strong>Bit Writer</strong> writes values using only the number of bits they actually need.</p><p>For example:</p><ul><li>Boolean (true/false) → <strong>1 bit</strong></li><li>Weapon ID (0–7) → <strong>3 bits</strong></li><li>Direction (0–15) → <strong>4 bits</strong></li></ul><p>Instead of storing each value in its own byte, the Bit Writer packs them tightly together.</p><p>This reduces the amount of data that needs to be stored or transmitted.</p><h3>How does the Bit Reader know what belongs to whom?</h3><p>When the customer opens the carton, every egg looks identical.</p><p>So how does the customer know:</p><ul><li>the first egg belongs to Person 1,</li><li>the next four belong to Person 2,</li><li>and the remaining spaces are empty?</li></ul><p>They can only know if they have the <strong>same packing instructions</strong> used by the person who packed the carton.</p><p>In computing, these instructions are called a <strong>protocol</strong> or <strong>data format</strong>.</p><p>For example, the reader is told:</p><pre>Read the first 1 bit  -&gt; Player is jumping<br>Read the next 3 bits  -&gt; Weapon ID<br>Read the next 4 bits  -&gt; Player direction</pre><p>The Bit Reader must read the bits in exactly the same order that the Bit Writer wrote them.</p><p>If the reader mistakenly reads <strong>2 bits</strong> instead of <strong>1</strong> for the first value, everything after that becomes misaligned.</p><pre>Correct reading:</pre><pre>1 | 101 | 0110<br>^   ^      ^<br>|   |      |<br>|   |      Direction<br>|   Weapon<br>Jumping</pre><pre>Incorrect reading:</pre><pre>11 | 010 | 110...</pre><pre>Every value after the mistake is decoded incorrectly.</pre><h3>Why is this useful?</h3><p>Packing bits tightly saves memory, bandwidth, and storage.</p><p>It is commonly used in:</p><h3>1. Network Game Engines</h3><p>Games send many tiny pieces of information every frame.</p><p>For example:</p><ul><li>Is the player jumping? → <strong>1 bit</strong></li><li>Weapon ID → <strong>3 bits</strong></li><li>Team → <strong>2 bits</strong></li><li>Is crouching? → <strong>1 bit</strong></li></ul><p>Instead of sending four separate bytes, all these values can be packed into a single byte or a few bytes.</p><p>This reduces network traffic.</p><h3>2. Data Compression</h3><p>Compression formats such as:</p><ul><li>ZIP</li><li>JPEG</li><li>MP3</li><li>PNG</li></ul><p>use bit-level writing to pack compressed data as tightly as possible.</p><p>This is one of the reasons compressed files are much smaller than their original versions.</p><h3>Key Idea</h3><p>Think of a byte as an <strong>8-slot egg carton</strong>.</p><ul><li><strong>Bit Writer</strong> = Packs small values efficiently into the carton.</li><li><strong>Bit Reader</strong> = Unpacks those values using the exact same packing instructions (protocol).</li></ul><p>ThankYou…….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93a0c011694d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Algebra -matrices transformation with visual and code implementation]]></title>
            <link>https://medium.com/@timeflagtbots/linear-algebra-matrices-transformation-with-visual-and-code-implementation-fca1ac1ddc74?source=rss-a40f57dfd0cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fca1ac1ddc74</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[transformation]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Kirthan Kaverappa ck]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 05:29:58 GMT</pubDate>
            <atom:updated>2025-08-12T05:29:58.630Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Intuition behind the fundamental core math in practical application</blockquote><h4>Matrices</h4><p><strong>Intuition</strong>: A matrix is a <strong>transformation machine</strong> — it rotates, scales, or skews vectors in space.</p><h4>2. Python Coding Exercises</h4><h4>2.1 Matrices — Basic Transformations</h4><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>A=np.array([[2,1],[1,3]])<br>V=np.array([1,2])<br><br>v_Transformed = A@V<br>print(v_Transformed)</pre><h4>code explanation :</h4><p>its just an basic <strong>vector</strong> transformation.</p><p><strong>A-&gt;</strong> is an transformation matrices.</p><p>In geometry, this kind of matrix <strong>transforms</strong> 2D vectors (changes their direction, length, and possibly skews them).</p><p><strong>V-&gt;</strong> is an original vector</p><p><strong>A@V</strong> -&gt; here <strong>@</strong> is used for multiplication, from this one more question arises, instead of using <strong>@ can we use *, </strong>yes<strong> </strong>u can but the thing is that: <strong>Why not </strong><strong>*?</strong></p><p>Because in <strong>NumPy</strong>, the * operator is <strong>element-wise multiplication</strong> (Hadamard product), not matrix multiplication.</p><pre>A * V:<br>[[2 2]<br> [1 6]]<br>A @ V:<br>[4 7]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*Joc3GIf0IB7UuZC2Gm-1ug.png" /></figure><p>If you think about it:</p><ul><li>* is for “multiply each slot individually.</li><li>@ is for “multiply whole rows by whole columns” (matrix math).</li></ul><h4>2.2 Visualization</h4><pre>plt.figure(figsize(6,6))<br>origin=np.array([0,0])   # starting point for both vectors<br><br># Plot original vector (blue)<br>plt.quiver(*origin,v[0],v[1],angles=&quot;xy&quot;,scale_units=&quot;xy&quot;,scale=1,color=&quot;blue&quot;,label=&quot;original vector&quot;)<br><br># plot transformed vector(red)<br>plt.quiver(*origin,v_Transformed[0],v_Transformed[1],angles=&quot;xy&quot;,scale_units=&quot;xy&quot;,scale=1,color=&quot;green&quot;,label=&quot;Transformed vector&quot;)<br><br># Set limits and grid<br>plt.xlim(-1, 6)<br>plt.ylim(-1, 9)<br>plt.axhline(0, color=&#39;black&#39;, linewidth=1)<br>plt.axvline(0, color=&#39;black&#39;, linewidth=1)<br>plt.grid(True)<br>plt.gca().set_aspect(&#39;equal&#39;, adjustable=&#39;box&#39;)<br><br># Labels<br>plt.legend()<br>plt.title(&quot;Vector Transformation by Matrix A&quot;)<br>plt.show()</pre><p>*origin -&gt; part is Python’s <strong>unpacking operator</strong>, and here it’s used so that <strong>plt.quiver()</strong> gets <strong>two separate numbers</strong> instead of a single tuple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*yAuHBxyu66sxbi0MbpF05A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fca1ac1ddc74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker: docker architecture-2]]></title>
            <link>https://medium.com/@timeflagtbots/docker-docker-architecture-2-23893ab291cc?source=rss-a40f57dfd0cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/23893ab291cc</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[basic-docker-command]]></category>
            <category><![CDATA[container-orchestration]]></category>
            <dc:creator><![CDATA[Kirthan Kaverappa ck]]></dc:creator>
            <pubDate>Thu, 07 Aug 2025 03:48:02 GMT</pubDate>
            <atom:updated>2025-08-07T03:48:02.109Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Docker engine</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*B-n9QHBooISzvOmIn6fmPg.png" /></figure><h4>Docker</h4><p>Docker is the whole platform or toolset used to build,ship,and run containers. think of it like a “T<strong>oolbox” </strong>which contains different tools in it for a specific use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*3hbkmESpRexRlLCp0p1y7A.png" /></figure><h4><strong>1.Docker Engine</strong></h4><ul><li><strong>Docker Engine</strong> is the <strong>core part</strong> of Docker</li><li>It’s the <strong>technology</strong> that actually runs containers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*CtAMrh0frRhHK5tc-04NQQ.png" /><figcaption>Like the <strong>engine</strong> inside the car — it makes the car actually move</figcaption></figure><blockquote><strong>Docker Engine = Docker Daemon + Docker CLI + REST API</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*-ikGPF3B_6gGr3HDWKtkSg.png" /><figcaption>Docker Engine Architecture</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*y_OwSWVXf68zT3WcabVFIw.png" /></figure><h3>1.1. Docker CLI (Command Line Interface)</h3><p><strong><em>“Where users type commands”</em></strong></p><ul><li>This is what <strong>you interact with</strong>.</li><li>You open a terminal or command prompt and type commands like:</li></ul><pre>docker build<br>docker run<br>docker ps</pre><ul><li>Behind the scenes, when you run a command using the CLI, it <strong>talks to the Docker Daemon</strong> (via REST API).</li><li>You can think of it like a <strong>remote control</strong> for Docker.</li></ul><p><strong>Example: Typing </strong><strong>docker run nginx in the CLI sends a message to the daemon to start a container using the Nginx image.</strong></p><h3>1.2. Docker REST API</h3><p><strong><em>“Acts like a messenger”</em></strong></p><ul><li>The <strong>communication layer</strong> between the Docker CLI (or other tools) and the Docker Daemon.</li><li>It listens for HTTP requests and passes them to the Docker Daemon to take action.</li><li>It can also be used by <strong>developers or programs</strong> to manage Docker (not just CLI).</li></ul><p><strong>Example:<em><br> </em>When you run </strong><strong>docker ps, the CLI sends a REST API call like:<br> </strong><strong>GET /containers/json<br> This API call is received by the Docker Daemon to return a list of running containers.</strong></p><h3>1.3. Docker Daemon (dockerd)</h3><p><strong><em>“The brain that does the real work”</em></strong></p><ul><li>This is the <strong>core service</strong> running in the background.</li><li>It does all the actual jobs like:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*E63kCjPW_cVik9FyDbTsVQ.png" /></figure><p><strong>Example:<br> You ask to create a container using the CLI — the Docker Daemon pulls the image, sets up the container, and starts it.</strong></p><h3>1.4. Images and Containers</h3><p><strong><em>“Managed by the daemon”</em></strong></p><h4>1.4.1 Docker Image:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*240-01BK2muJOlJ3uZ-YmQ.png" /></figure><ul><li>A <strong>blueprint/template</strong> for containers.</li><li>It’s like a <strong>package (blueprint)</strong> that contains everything needed to run an app:</li><li>✅ Code</li><li>✅ Libraries</li><li>✅ Tools</li><li>✅ OS dependencies</li><li>✅ Config files</li><li>Once built, it can be stored <strong>locally</strong> or pushed to <strong>Docker Hub or private registries</strong> for reuse.</li></ul><h4>1.4.2 Docker Container:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*dGMFUMACVxRW-DTYPmN9iA.png" /></figure><p><strong><em>Description of Each Part:</em></strong></p><p><strong>Lightweight: </strong>Uses fewer resources than virtual machines</p><p><strong>Isolated: </strong>Runs separately from other containers and the host system</p><p><strong>Easy to Start: </strong>Starts in seconds from a Docker image</p><p><strong>Easy to Stop/Delete: </strong>You can stop or remove it with simple commands</p><p><strong>Can Restart Anytime: </strong>Containers can be paused and restarted as needed</p><p>will be continued ….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23893ab291cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker]]></title>
            <link>https://medium.com/@timeflagtbots/docker-f3dc27db6455?source=rss-a40f57dfd0cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3dc27db6455</guid>
            <dc:creator><![CDATA[Kirthan Kaverappa ck]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 13:38:07 GMT</pubDate>
            <atom:updated>2025-07-19T13:38:07.328Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>introduction to docker</li><li>docker architecture</li><li>installing docker</li><li>docker images</li><li>docker containers</li><li>docker networking</li><li>docker volumes and storage</li><li>docker compose</li><li>docker registry</li><li>multi stage docker builds</li><li>monitoring and logging in docker</li><li>orchestrating docker with kubernetes(introduction)</li></ol><h4><strong>1. Introduction to docker</strong></h4><p>Docker is a containerization tool that simplifies the process of accessing and running projects or builds without the need to manually configure the environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*OIEpXxPq2L1Cwmi_eWUFyw.png" /><figcaption>docker containerization similar to maggie</figcaption></figure><p>It packages everything — code, dependencies, libraries, and settings — into a container, which can be pulled from Docker Hub and run directly. Think of it like a Maggie noodles pack: when you buy it from the store, it already comes with pre-mixed masala and noodles. You just need to cook it for a few minutes, and it’s ready to eat. Docker works the same way — it provides a pre-packaged, ready-to-run environment for your applications</p><h4>1.1 . Virtualization vs Containerization</h4><p>Summary Table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*cbpXJSwJcY3QXLdC8wkjvQ.png" /></figure><p>Analogy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*-gHuRzV-fs3IRuNUt0R3Pw.png" /></figure><ul><li><strong>Virtualization</strong> is like owning multiple houses (each with its own kitchen, bathroom, etc.).</li><li><strong>Containerization</strong> is like renting apartments in the same building (shared foundation but individual space).</li></ul><h4>1.11 Virtualization</h4><figure><img alt="🧠 What the Diagram Shows
 It’s a visualization of how virtualization works — specifically how a Windows operating system can run on a Linux machine using something called a hypervisor." src="https://cdn-images-1.medium.com/max/361/1*_sOiZbLk4aM2a270Xn3Rwg.png" /><figcaption>🧠 What the Diagram Shows</figcaption></figure><p>It’s a visualization of how <strong>virtualization</strong> works — specifically how a Windows operating system can run on a Linux machine using something called a <strong>hypervisor</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*EKBlz4NnUfDUjW7T0Ihx9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*Wdh6EkAMoUnUdbH3ztcu0w.png" /></figure><h4>1.12 Containerization</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*ZlWgBQwYG30vTcB__RE8PQ.png" /><figcaption>🧱 What’s in the Diagram?</figcaption></figure><p>It shows <strong>three main layers</strong>:</p><ol><li><strong>Containers</strong> — Small, isolated packages of software</li><li><strong>Docker Engine</strong> — The tool that runs containers</li><li><strong>Operating System (Linux)</strong> — The base system everything runs on</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*hUTwwDF0aHThnvygEMwHlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*D4ZsvafvtDZcN5d5ocg0zA.png" /></figure><h4>2. Introduction to docker</h4><blockquote>— <em>Docker engine</em></blockquote><blockquote><em>— Docker Daemon</em></blockquote><blockquote><em>— Docker CLI</em></blockquote><p>will be continued …..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3dc27db6455" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradient Descent (ML engine)]]></title>
            <link>https://medium.com/@timeflagtbots/gradient-descent-ml-engine-1110c63e5d6e?source=rss-a40f57dfd0cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/1110c63e5d6e</guid>
            <category><![CDATA[neural-network-algorithm]]></category>
            <category><![CDATA[algebra]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kirthan Kaverappa ck]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 16:47:23 GMT</pubDate>
            <atom:updated>2025-07-10T16:47:23.590Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re getting into machine learning, one of the first (and most powerful) tools you’ll hear about is <strong>gradient descent</strong>. It’s the <strong>engine</strong> that trains models by reducing error step by step.</p><p>In this blog, we’ll understand:</p><ul><li>What gradient descent is</li><li>Why we need it</li><li>Different types of gradient descent</li><li>Implementations from scratch using <strong>NumPy only</strong></li></ul><h3>🎯 What is Gradient Descent?</h3><p>Gradient descent is an <strong>optimization algorithm</strong>. It’s how machines <strong>learn</strong> the best weights for models like <strong>linear regression</strong> or <strong>neural networks</strong>.</p><p>Imagine you’re standing on a hill in the fog and want to reach the lowest point. You look at your feet, feel which way is sloping down, and take a small step. Do this over and over — eventually, you reach the bottom.</p><p>That’s <strong>gradient descent</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*g4R6mUw9pmnBz-t64ix4Mw.png" /></figure><h3>🔢 The Math Behind It</h3><p>We have a model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*x3l3ScqU9dIOU1wHTVesRA.png" /></figure><p>We want to find w and b that make \hat{y} as close as possible to the real y.</p><p>We measure the error using <strong>Mean Squared Error (MSE)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*kiVHtNRFXEk2AlrRD2lpGQ.png" /></figure><p>Our goal is to <strong>minimize</strong> this loss.</p><h3>🧮 Gradient Formulas</h3><p>To minimize the loss, we compute how much each parameter (w, b) contributes to the error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*CMuvf_7vgDppxWpjggEE-w.png" /></figure><h3>🧭 Types of Gradient Descent (Made Easy)</h3><p>Gradient Descent can be done in <strong>three different ways</strong>, depending on <strong>how much data</strong> we use to update the model at each step:</p><h3>✅ 1. Batch Gradient Descent</h3><p>📦 <strong>What it is:</strong><br> Uses <strong>all the training data at once</strong> to calculate the error and update the weights.</p><p>🔁 <strong>Steps:</strong></p><ul><li>Look at the <strong>entire dataset</strong></li><li>Calculate total error</li><li>Update weights once</li></ul><p>👍 <strong>Good:</strong></p><ul><li>Very <strong>stable and accurate</strong></li><li>Works well for <strong>small datasets</strong></li></ul><p>👎 <strong>Bad:</strong></p><ul><li><strong>Slow</strong> if the dataset is very large</li></ul><h3>✅ 2. Stochastic Gradient Descent (SGD)</h3><p>🎯 <strong>What it is:</strong><br> Uses <strong>only one training sample at a time</strong> to update the weights.</p><p>🔁 <strong>Steps:</strong></p><ul><li>Pick <strong>one data point</strong></li><li>Calculate its error</li><li>Update weights <strong>immediately</strong></li></ul><p>👍 <strong>Good:</strong></p><ul><li><strong>Fast</strong> for large datasets</li><li>Can <strong>escape local minima</strong></li></ul><p>👎 <strong>Bad:</strong></p><ul><li>Very <strong>noisy</strong> (loss keeps jumping up and down)</li></ul><h3>✅ 3. Mini-Batch Gradient Descent</h3><p>🍰 <strong>What it is:</strong><br> A mix of both. Uses <strong>a small group of samples</strong> (e.g., 32 or 64) to update weights.</p><p>🔁 <strong>Steps:</strong></p><ul><li>Divide data into <strong>mini-batches</strong></li><li>For each mini-batch:</li><li>Calculate average error</li><li>Update weights</li></ul><p>👍 <strong>Good:</strong></p><ul><li><strong>Fast + stable</strong></li><li>Works well for most real-world problems</li></ul><p>👎 <strong>Bad:</strong></p><ul><li>Needs <strong>batch size tuning</strong></li></ul><h3>💻 Code: Batch Gradient Descent (From Scratch)</h3><pre>import numpy as np<br># Step 1: Sample data (3 samples, 2 features)<br>X = np.array([<br>    [1, 2],<br>    [2, 3],<br>    [4, 5]<br>])<br>y = np.array([5, 8, 14])<br># Step 2: Initialize weights and bias<br>w = np.zeros(2)<br>b = 0.0<br># Step 3: Hyperparameters<br>lr = 0.01<br>epochs = 100<br># Step 4: Training Loop<br>n = len(X)<br>for epoch in range(epochs):<br>    # Predictions<br>    y_pred = np.dot(X, w) + b<br>    <br>    # Compute error<br>    error = y_pred - y<br>    <br>    # Compute gradients<br>    dw = (1/n) * np.dot(X.T, error)<br>    db = (1/n) * np.sum(error)<br>    <br>    # Update weights<br>    w -= lr * dw<br>    b -= lr * db<br>    # Optional: print loss<br>    if epoch % 10 == 0:<br>        loss = (1/(2*n)) * np.sum(error ** 2)<br>        print(f&quot;Epoch {epoch}: Loss = {loss:.4f}&quot;)<br>print(&quot;\nFinal Weights:&quot;, w)<br>print(&quot;Final Bias:&quot;, b)</pre><h3>💻 Code: Stochastic Gradient Descent (SGD)</h3><pre># Reset weights and bias<br>w = np.zeros(2)<br>b = 0.0<br># Training loop (SGD)<br>for epoch in range(epochs):<br>    for i in range(n):<br>        xi = X[i]<br>        yi = y[i]<br>        y_pred_i = np.dot(xi, w) + b<br>        error_i = y_pred_i - yi<br>        # Gradients for one sample<br>        dw = error_i * xi<br>        db = error_i<br>        # Update<br>        w -= lr * dw<br>        b -= lr * db<br>    if epoch % 10 == 0:<br>        # Optional: compute full loss<br>        y_all = np.dot(X, w) + b<br>        full_loss = (1/(2*n)) * np.sum((y_all - y) ** 2)<br>        print(f&quot;Epoch {epoch}: Loss = {full_loss:.4f}&quot;)<br>print(&quot;\nFinal Weights (SGD):&quot;, w)<br>print(&quot;Final Bias (SGD):&quot;, b)</pre><h3>🔁 Summary</h3><ul><li><strong>MSE</strong> is used to <strong>measure error</strong> (loss)</li><li><strong>Gradient Descent</strong> is used to <strong>reduce that error</strong></li><li><strong>Batch</strong>, <strong>SGD</strong>, and <strong>Mini-batch</strong> are just different ways to apply it</li><li>You don’t need any library — <strong>just NumPy</strong>!</li></ul><h3>✅ Takeaway</h3><p>Whether you’re training a simple linear model or a deep neural network, <strong>gradient descent is always at the heart</strong> of learning.</p><p>If you understand it well, you’ve unlocked one of the <strong>core engines of machine learning.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1110c63e5d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>