<?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 Vasist on Medium]]></title>
        <description><![CDATA[Stories by Vasist on Medium]]></description>
        <link>https://medium.com/@vasist-10?source=rss-0410948d5d94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*T7ao73m7IvYNCfbA</url>
            <title>Stories by Vasist on Medium</title>
            <link>https://medium.com/@vasist-10?source=rss-0410948d5d94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:44:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vasist-10/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[How Machines Learn: A Beginner’s Guide to Gradient Descent & Momentum (Part 1)]]></title>
            <link>https://vasist-10.medium.com/how-machines-learn-a-beginners-guide-to-gradient-descent-momentum-part-1-9b25c2406df6?source=rss-0410948d5d94------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b25c2406df6</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Vasist]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 18:20:07 GMT</pubDate>
            <atom:updated>2025-07-22T18:20:07.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Machines learn from their mistakes using a technique called <strong>optimization</strong>. No matter how well you design or train a model, without proper optimization, it won’t achieve good accuracy — and that makes it ineffective.</p><p>In this two-part blog series, we’ll explore what gradient descent is, walk through popular optimizers, and dive into a deep understanding of how these relate to dynamic programming.</p><p>In Part 1, we’ll cover the core optimizers — starting from classic gradient descent, moving through stochastic versions, and also the momentum-based methods</p><h3>Gradient Descent</h3><p>The most basic algorithm used for optimization in machine learning is <strong>Gradient Descent</strong>.<br> A common analogy to explain this is: imagine you’re standing on a mountain and want to reach the lowest point in the valley. As a human, you can visually observe the terrain and decide where to step next to go downhill. But a machine can’t see the landscape — so how does it find the lowest point?</p><p>The machine takes small steps in <strong>all directions</strong> and compares the new position to the previous one. Mathematically, this means it evaluates the loss function (if you know what loss functions are — if not, you can ignore this) at different points and moves in the direction where the loss decreases the most — which is the <strong>negative gradient</strong>.</p><p>This process repeats until it reaches a point where further movement no longer improves the result — technically, this is the global minimum of the loss function or the lowest point (according to our analogy).</p><h3>Mathematics Behind Gradient Descent</h3><p>Let’s say we’re trying to minimize some function L(θ)L(\theta)L(θ), where:</p><ul><li>L is the <strong>loss function</strong> (how bad our model is doing)</li><li>θ represents the model’s parameters (like weights in a neural network)</li></ul><p>Gradient Descent updates these parameters like this:</p><p>θ=θ-α⋅∇L(θ)</p><p>Now let’s break that down:</p><ul><li>∇L(θ) is the <strong>gradient</strong> — basically, the slope or direction where the function increases the most</li><li>α is the <strong>learning rate</strong> — the size of the steps are going to take</li><li>α⋅∇L(θ) moves you in the <strong>opposite direction of the gradient</strong>, which is downhill</li></ul><p>Think of it like this:<br> You’re standing somewhere on the slope (your current value ofθ θ). You look around, figure out the steepest upward direction, and say, <em>“ Yea, I’m going the other way.”</em> Then you take a step of size α in that direction.</p><p>And repeat. Again and again. Until the slope flattens out, and you’re hopefully at the bottom<strong>.</strong></p><h3><strong>Lets Visualize the Gradient Descent</strong></h3><p>As you can see below, the <strong>red dot/ball</strong> rolls down the graph and eventually reaches the <strong>lowest point</strong> — also known as the <strong>global minimum</strong>.</p><p>The <strong>second plot</strong> is the <strong>contour plot</strong> of that same 3D graph. It’s basically what the 3D surface looks like when you view it from the top (or bottom)</p><p>If the spaces between two consecutive circles are wide, that means the slope is gentle there. The closer the circles, the steeper the slope. And the <strong>innermost circle</strong> marks the <strong>lowest point</strong> of the graph.</p><p>So congrats — you just learned how to read a contour plot too!</p><figure><img alt="Gradient Descent visualized in 3D: the red ball moves downhill toward the lowest point" src="https://cdn-images-1.medium.com/max/600/1*tpgARHx9roOFkoSfyMUvlA.gif" /><figcaption>Gradient Descent 3D</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*4lzpTrwknkRjynkRlOgcQw.gif" /><figcaption>Gradient Descent 2D</figcaption></figure><p>This was the loss function used in the above plots:<br> L(x,y)=x^2+y^2</p><p>Now you might be wondering — what are the other two variables in this Function/3D plot?<br> The <strong>vertical axis</strong> shows the <strong>loss function</strong> — how bad the model is doing.<br> The <strong>other two axes</strong> represent two different <strong>parameters</strong> of the model, like weights or biases.<br>In real-world models, you’ll have way more parameters, but we are sticking to 2d and 3d plots because we can visualize it better.</p><h3>The Problems with the Basic Gradient Descent</h3><p>Now, as cool as gradient descent sounds, it isn’t perfect. It has some real issues in practice:</p><p><strong>1)Stuck in local minima</strong>: Sometimes, gradient descent thinks it has reached the lowest point — but it’s actually just a small dip, not the true bottom.<br> Here’s an analogy: you’re hiking down a mountain to reach the lowest point, but on the way, you step into a <strong>pit hole</strong>. You, as a human, know this isn’t the actual bottom — but the machine doesn’t.<br> It calculates the gradient at that point, finds that it’s zero (or very small), and assumes <em>“Cool, I’m done!”</em> — even though a much lower point exists nearby. This is called <strong>local minimum</strong>, not the global one.</p><p>In the GIF below, you can see the red ball/dot gets stuck in a local<strong> </strong>minimum — but it’s not the lowest point<strong> </strong>of the function.<br>This is a big problem because, if you remember from earlier, the two axes in the graph represent things like weights and biases in a model. If gradient descent settles in the wrong spot (a local dip), it means the model ends up with not the best weights and bias which leads to less accurate predictions.<br>So even if everything else in your model is set up perfectly, getting stuck in a local minimum can stop you from reaching the<strong> </strong>best possible accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*qQUrRQL41vTXFRGebKtHNg.gif" /></figure><p><strong>2)Slow in flat regions</strong>: In areas where the slope is tiny (like plateaus), gradient descent takes baby steps and converges painfully slow.</p><p>Sometimes, the loss surface has flat regions — like plateaus or shallow valleys — where the slope (gradient) is almost zero.<br>When gradient descent reaches one of these areas, it starts taking tiny steps<strong> </strong>— kind of like it’s tiptoeing. This makes convergence really slow and frustrating to watch.<br>So even if it’s technically going in the right direction, it might take a huge number of steps to get anywhere meaningful.<br>These problems become even worse when we deal with large datasets or complex models.</p><p><strong>3)Oscillations in steep areas</strong>: In narrow valleys or steep curves, it can keep overshooting and bouncing back and forth.</p><p>In narrow valleys or sharp curves, gradient descent can get <strong>t</strong>oo aggressive<strong>.</strong> Because the slope is steep, the updates are huge — so instead of smoothly reaching the minimum, it keeps overshooting and bouncing back and<strong> </strong>forth, never really settling.<br>Analogy : Imagine you’re running downhill too fast in a narrow trench — instead of slowing down, you keep ricocheting from one wall to the other. That’s what gradient descent does when the slope is too steep and the learning rate isn’t careful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*dqTyz225Hkbs9MWHcnSumQ.gif" /></figure><p>As seen in the above image the red dot/ball reaches the minimum but it oscillates. Here it might not create a problem but when the datasets are large it takes a lot of time to execute.</p><h3>Types of Gradient Descent</h3><p>Now that we have a basic idea of how <strong>Gradient Descent</strong> works, let’s dive into the versions that are actually used in the real world.<br> There are <strong>three main types</strong> of Gradient Descent, depending on <strong>how much data</strong> is used in each update:</p><ol><li><strong>Stochastic Gradient Descent (SGD)</strong><br> Updates the model using <strong>one data point at a time</strong>. Fast, but can be noisy.<br>Analogy : Like adjusting your direction after asking <strong>one random person</strong> for directions — quick, but risky.</li><li>Batch Gradient Descent<br> Uses the <strong>entire dataset</strong> to compute the gradient in each step. Stable, but slow for large datasets.<br>Analogy : Similar to surveying the <strong>entire city</strong> before making one move — accurate, but slow.</li><li><strong>Mini-Batch Gradient Descent</strong><br> The most commonly used one — it splits the data into <strong>small batches</strong> (like 32, 64, or 128 samples) and updates the model batch-by-batch. A perfect balance between speed and stability.<br>Analogy : Like asking a <strong>small group of locals</strong> before deciding your next step — balanced and reliable.</li></ol><p>In the next section we are going to explore the ways to fix the problem that gradient descent face.</p><h3>Momentum: Speeding Up Gradient Descent</h3><p>Gradient Descent is cool, but sometimes it’s… clumsy.<br> It can get<strong> stuck in flat areas</strong>, or <strong>oscillate in steep valleys</strong> like a toddler learning to walk.<br>So inorder to fix these issue we use Momentum</p><p><strong>What’s Momentum?<br></strong>Instead of updating weights purely based on the current gradient, momentum adds a bit of “memory” to it — it remembers the direction it was going, and keeps pushing that way.<br>So it doesn’t just look at where to go now, but also how fast and in which direction it was already moving — just like momentum in physics. If you’ve studied basic physics, this will make sense easily.</p><p>Analogy : Imagine pushing a ball down a hill. At first, it rolls slowly. But as it keeps moving, it builds speed — and even if the slope becomes shallow, it keeps rolling forward because of the momentum it gained.</p><h3>The Math:</h3><p>Let’s define:</p><ul><li>vt​: the velocity or momentum term</li><li>θt​: the parameters (weights)</li><li>∇L(θt​): the gradient at step ttt</li><li>γ: the momentum coefficient (like 0.9)</li></ul><h4>Update Rule:</h4><p>vt=γ⋅vt−1+η⋅∇L(θt)</p><p>θt+1​=θt​−vt​</p><ul><li>vₜ → the current <strong>velocity</strong> (i.e., how fast we&#39;re moving in parameter space)</li><li>γ → the <strong>momentum coefficient</strong> (typically 0.9), which controls how much of the previous velocity to retain</li><li>vₜ₋₁ → the previous velocity (from the last step)</li><li>η → the learning rate (same as in gradient descent)</li><li>∇L(θₜ) → the gradient of the loss function at the current parameters</li></ul><p><strong>New velocity</strong> = “a little bit of the old velocity” + “new push from the current gradient”</p><p>Visualization of momentum:</p><p>In this 3D visualization, the red dot slides down the bowl smoothly. Momentum helps it speed up in the right direction and settle without bouncing — making the optimization faster and more stable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*lm3Oo6NnTCteuT6Zy-6Bdg.gif" /><figcaption>Momentum descent</figcaption></figure><p>Issue with momentum:</p><p>You thought momentum was all good? Not quite. Momentum is definitely better than vanilla gradient descent, but it’s still not the most optimal solution. Why?</p><p>One big problem: <strong>Saddle Points.<br></strong>A saddle point is like a flat piece of land — it’s neither a peak nor a true valley, but somewhere in between. In some directions, the slope goes up; in others, it goes down.</p><p>Now here’s the thing: momentum helps fix the issue of getting stuck in local minima ,how? Because of the velocity term it carries from previous steps, even if the gradient is small (like at a flat spot or dip), it can still push the optimizer forward and escape that local trap.</p><p>But in the case of saddle points, the optimizer might just drift slowly or stop entirely because the gradients become nearly zero and the momentum fades out. So you end up wasting a lot of time circling or crawling through flat regions with no real progress. As shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OlLQ0Y-S1yvs9YJod5eEKg.gif" /><figcaption>Momentum during Saddle point</figcaption></figure><h3>Nesterov Accelerated Gradient (NAG)</h3><p>NAG is an <strong>improved version of Momentum</strong>.</p><p>With regular momentum, you take a step and then calculate the gradient at the new position.<br> But with NAG, you first <strong>look ahead</strong> using the velocity, estimate where you’re going to land, and then calculate the gradient <strong>at that future point</strong>.<br>That “peek into the future” helps avoid overshooting or wasting steps in the wrong direction.</p><p>Analogy : Imagine you’re running downhill with a blindfold (like gradient descent).<br> With momentum, you use your past speed to keep going — but you still can’t see what’s ahead.<br>Now imagine someone whispers in your ear: “There’s a sharp turn coming up!” That’s NAG. It <strong>looks ahead</strong>, realizes you’re going too fast, and <strong>adjusts your path</strong> before you overshoot.</p><h3>Math behind NAG:</h3><ol><li><strong>Lookahead step:</strong></li></ol><p>θ~t​=θt​−γvt−1​</p><ol><li><strong>Gradient at lookahead:</strong></li></ol><p>vt​=γvt−1​+η∇L(θ~t​)</p><ol><li><strong>Update parameters:</strong></li></ol><p>θt+1​=θt​−vt​</p><p>Where:</p><ul><li>γ is the momentum factor (usually 0.9)</li><li>η is the learning rate</li><li>vt​ is the velocity</li></ul><p>Visualization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*YA6OQqdrb-n5ntRwJV0WGA.gif" /><figcaption>nag</figcaption></figure><p>As seen above the speed of nag is in between the normal gradient descent and momentum. You can also observe that the overshooting is less compared to the momentum.</p><h3>Problems of NAG</h3><p>While NAG looks ahead and avoids overshooting better than momentum, it still has <strong>limitations</strong>:</p><p>1. Still struggles in flat regions or saddle points<br>Even though it looks ahead, if the gradients are close to zero (like on a saddle point or plateau), NAG still slows down or stops — just like normal GD or momentum.<br>2. Sensitive to learning rate<br>If the learning rate is high, NAG can still<strong> </strong>overshoot or oscillate, especially in highly curved surfaces.</p><p>Analogy : Imagine you’re driving fast downhill with good brakes (NAG). You see a turn coming and start slowing down — nice!<br> But if the road is flat and long, even if you look ahead, you just keep rolling slowly forever. That’s what happens near saddle points — you’re stuck tiptoeing with no slope to guide you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0Xpo6VtyUvvMe0lR2yEC8g.gif" /></figure><p>In the 3D surface below, you can see the optimizer moves back and forth or stalls out in a flat “saddle” region — this happens even with NAG, which is supposed to be smarter than momentum.</p><p>These saddle points confuse the optimizer because gradients cancel out in certain directions, and there’s no clear path to descend.</p><p>This is one of the reasons <strong>adaptive optimizers</strong> like Adam were developed — which we’ll explore in Part 2. Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b25c2406df6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Healthcare-Plus ,”Caring for Every Plus in Life”.]]></title>
            <link>https://vasist-10.medium.com/healthcare-plus-caring-for-every-plus-in-life-0dfcc1b5389f?source=rss-0410948d5d94------2</link>
            <guid isPermaLink="false">https://medium.com/p/0dfcc1b5389f</guid>
            <category><![CDATA[full-stack-development]]></category>
            <category><![CDATA[healthcare-management]]></category>
            <category><![CDATA[competition]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Vasist]]></dc:creator>
            <pubDate>Thu, 09 Jan 2025 09:45:44 GMT</pubDate>
            <atom:updated>2025-01-09T09:45:44.102Z</atom:updated>
            <content:encoded><![CDATA[<h3>Healthcare-Plus ,”Caring for Every Plus in Life”.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*eGPjVVfv2BAUhaTU7cg9gQ.png" /><figcaption>Healthcare-Plus logo</figcaption></figure><p>Building a Healthcare Management System is a Journey Through Frontend and JavaScript Challenges<br>Creating a healthcare management system using basic web technologies like HTML, CSS, JavaScript, and integrating useful APIs like OpenStreetMap (via Leaflet.js) and Geolocation was an exciting and challenging experience. My goal was to create an intuitive platform for users to find nearby hospitals, book appointments, track upcoming visits, and update their medical records. This journey was full of learning and problem-solving, but also some key challenges, particularly in JavaScript backend development and user authentication.<br><strong>Overview of the Healthcare Management System</strong><br>The healthcare management system I developed is a web application that provides the following functionalities:<br><strong>1)Nearby Hospitals Finder</strong>: Using OpenStreetMap (Leaflet.js) and the Geolocation API, users can find hospitals near their current location. This feature enables users to visualize hospitals on a map and get directions to them easily.<br><strong>2)Booking an Appointment</strong>: Appointments can be booked either directly from the available hospitals on the map or viewed as a separate list. The function is also tied to a very simple database which stores free slots of time.<br><strong>3)Future Appointments</strong>: After making a booking for an appointment, users can also see their upcoming appointments in the calendar view and so will never miss an appointment.<br><strong>4)Medical Records Management</strong>: Users can update and manage their medical records, storing relevant information for easy access when needed.<br>The application was designed with a focus on simplicity and usability. While the features may seem basic, they provide essential functionalities for managing healthcare appointments, finding healthcare providers, and keeping track of medical data.<br>Tools and Technologies Used<br><strong>Frontend</strong>: HTML, CSS, JavaScript<br><strong>Map Integration</strong>: Leaflet.js (OpenStreetMap)<br><strong>Geolocation</strong>: HTML5 Geolocation API<br><strong>Backend (Theoretical):</strong> JavaScript for simple backend operations, but more complex backend functionalities such as authentication and data storage were not implemented.<br><strong>Major Issues Encountered</strong><br>Although the project was very fulfilling, I faced several issues, especially since I had intermediate knowledge of JavaScript and backend development. Let’s discuss the issues I encountered and how I overcame them.<br>1. Backend Development with JavaScript: A Steep Learning Curve<br>As an intermediate-level JavaScript developer, I found the backend development using JavaScript to be a little more challenging. Initially, the goal was to create a simple backend system to manage appointments and store medical records. But when I worked on server-side JavaScript using Node.js and Express, it became much more complicated than I expected.<br>Some specific challenges included:<br><strong>Asynchronous Programming</strong>: Control of asynchronous operations through promises and callbacks became challenging. I needed to handle API calls, especially those that were interacting with the database, so data inconsistency would be avoided.<br><strong>Database Integration:</strong> First, I chose to use a simple JSON-based storage for appointments and records. Although it was enough for the initial implementation, the project had to scale to handle real-world data and users, so it would require a proper database like MongoDB .<br><strong>State Management</strong>: State management of the application was complex, especially to update medical records and appointments. I had to figure out how to update the user interface in real time without reloading the page.<br>I still faced several challenges, but the experience greatly enhanced my understanding of full-stack development. I could learn new concepts and apply them to build necessary backend components of the system.<br><strong>2. Authentication</strong>: The Missing Piece<br>One feature I had hoped to implement but could not fully integrate was user authentication. Although I explored various ways of adding authentication (like using JWT or integrating with OAuth providers), I ultimately ran out of time and couldn’t properly implement it into the project.<br> <br>JWT (JSON Web Tokens): I played with using JWT for authenticating users, though I did not incorporate it entirely into the project. JWT makes it possible to have a safer management of user sessions and even API calls. However, it was a little too involving on the backend side for me to include in this project.<br>Finally, I ran out of time to fully build secure authentication; however, it really taught me a lot about how authentication and authorization systems work. <strong>Going forward,</strong> I would make proper user authentication a high priority for my future projects and maybe use a library like Passport.js or Firebase Authentication for an even more secure implementation.<br><strong>What I Learned</strong><br>Although the project wasn’t easy, it was an amazing learning experience. Here is what I learned:<br><strong>Frontend-Backend Integration:</strong> The most difficult part was that of frontend-backend integration, which included making real-time updates and handling asynchronous requests, as well as data storage management.<br><strong>API Usage: </strong>The seamless integration of OpenStreetMap with Leaflet.js and the Geolocation API did not make it easy to avoid learning the importance of handling edge cases, such as users not allowing location access and errors in loading the map.<br><strong>User-Centric Design: </strong>The best part of this project was creating a system which may eventually help patients manage their health better. In the beginning, the focus has been on getting the system to be easy to use and visually clear.<br><strong>Future Improvements</strong><br>If I were to carry on with the development of this project, then the following changes would be carried out:<br>Integration into a Database I would replace this elementary JSON storage to store appointments and their respective medical record securely using the database solution in MongoDB or PostgreSQL.<br><strong>Full authentication </strong>Ensures proper user login using something as JWT or OAuth: Users’ medial data will have full security features. I should also consider an integration of services from third party for sign-in and log out.<br><strong>UI/UX Improvements:</strong> The basic interface is workable, but the user experience needs to be enhanced. Features like notifications for appointments, reminders, and a more developed calendar would enhance usability.<br><strong>Security:</strong> I would improve security features, especially for medical records and user authentication. Best practices in this regard would include encrypting sensitive data.<br><strong>Conclusion</strong><br>Building this healthcare management system was an incredibly enriching experience. It taught me valuable lessons in JavaScript, APIs, backend development, and UI/UX design. While I encountered several challenges, particularly with backend JavaScript and authentication, the project allowed me to push my limits and think critically about how to solve real-world problems.<br>If you have any suggestions or feedback, feel free to connect — I’d love to hear your thoughts!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0dfcc1b5389f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>