<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aanand</title>
    <description>The latest articles on Forem by Aanand (@aanand_4d81b59bb2a50beb70).</description>
    <link>https://forem.com/aanand_4d81b59bb2a50beb70</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3538852%2F9486fe8d-b7ef-40db-8c99-7ebbaf3e6d6b.jpg</url>
      <title>Forem: Aanand</title>
      <link>https://forem.com/aanand_4d81b59bb2a50beb70</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aanand_4d81b59bb2a50beb70"/>
    <language>en</language>
    <item>
      <title>Why y=mx+b is the heart of AI</title>
      <dc:creator>Aanand</dc:creator>
      <pubDate>Fri, 22 May 2026 14:00:43 +0000</pubDate>
      <link>https://forem.com/aanand_4d81b59bb2a50beb70/why-ymxb-is-the-heart-of-ai-2ibn</link>
      <guid>https://forem.com/aanand_4d81b59bb2a50beb70/why-ymxb-is-the-heart-of-ai-2ibn</guid>
      <description>&lt;p&gt;&lt;strong&gt;We hear words like:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Artificial Intelligence&lt;/li&gt;
&lt;li&gt;Machine Learning&lt;/li&gt;
&lt;li&gt;Neural Networks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;then imagine something mysterious.&lt;/p&gt;

&lt;p&gt;Something extremely advanced.&lt;/p&gt;

&lt;p&gt;But surprisingly, one of the core ideas behind neural networks starts from a concept many of us studied in school.&lt;/p&gt;

&lt;h2&gt;
  
  
  y = mx + b
&lt;/h2&gt;

&lt;p&gt;This is called the slope-intercept form of a line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;x&lt;/strong&gt;   Input — the number we feed in&lt;br&gt;
&lt;strong&gt;y&lt;/strong&gt;   Output — the result we get out&lt;br&gt;
&lt;strong&gt;m&lt;/strong&gt;   Slope — how much y changes per unit of x&lt;br&gt;
&lt;strong&gt;b&lt;/strong&gt;   Y-intercept — the output when &lt;strong&gt;x&lt;/strong&gt;(input) is zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; take y = 2x + 1 and Plug in different input:&lt;br&gt;
x = 1 → y = 3&lt;br&gt;
x = 2 → y = 5&lt;br&gt;
x = 3 → y = 7&lt;/p&gt;
&lt;h2&gt;
  
  
  Neural networks use the same idea
&lt;/h2&gt;

&lt;p&gt;Inside a neural network, a single neuron does this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;w&lt;/strong&gt; Weight — behaves exactly like slope (m)&lt;br&gt;
&lt;strong&gt;b&lt;/strong&gt; Bias — behaves exactly like the y-intercept&lt;/p&gt;

&lt;p&gt;The only difference: the variable names changed. The math is the same.&lt;/p&gt;
&lt;h2&gt;
  
  
  What does weight actually do?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Suppose&lt;/strong&gt; an AI is predicting a student's exam score. It has three inputs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Study hours&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Hours of sleep&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Hours of phone usage&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do all three affect the score equally? &lt;strong&gt;No&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Study hours matter the most &lt;/li&gt;
&lt;li&gt;Phone usage probably hurts&lt;/li&gt;
&lt;li&gt;Sleep helps a little.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;So the formula for this prediction might look like:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;score = 5(study) + 2(sleep) − 4(phone) + 10&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;interpretation:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Study hours have the highest positive weight (5) — they help the most&lt;/li&gt;
&lt;li&gt;Sleep has a smaller positive weight (2) — it helps a little&lt;/li&gt;
&lt;li&gt;Phone usage has a negative weight (−4) — it actively hurts the score&lt;/li&gt;
&lt;li&gt;10 is the bias — the model's default starting score before inputs are counted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But why say "weight" instead of "slope"?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;neural networks have many inputs at once. Each input needs its own slope. When there are many of them, we call them weights.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="err"&gt;₁&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt;₁&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="err"&gt;₂&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt;₂&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="err"&gt;₃&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt;₃&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each &lt;em&gt;input&lt;/em&gt; &lt;code&gt;(x₁, x₂, x₃)&lt;/code&gt; has its own &lt;em&gt;weight&lt;/em&gt;  &lt;code&gt;(w₁, w₂, w₃)&lt;/code&gt;. &lt;br&gt;
The name "weight" just means: the slope assigned to this particular input.&lt;/p&gt;

&lt;h2&gt;
  
  
  In model "training"
&lt;/h2&gt;

&lt;p&gt;At the start, a model does not know the right weights. They are set randomly. So predictions are terrible:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;random start — predictions are bad&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;y = 0.13x + 7.8&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Training is the process of adjusting the weights and bias, little by little, until predictions get better:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;getting closer&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;y = 2.4x + 1.1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;much better&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;y = 3.0x + 0.5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notice:&lt;/strong&gt; both &lt;strong&gt;w&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; are changing. Training adjusts both the weights and the bias to reduce prediction error. That is all training is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it all together: one neuron
&lt;/h2&gt;

&lt;p&gt;A single neuron in a neural network does four things in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiply each input by its weight&lt;/li&gt;
&lt;li&gt;Add all those results together&lt;/li&gt;
&lt;li&gt;Add the bias&lt;/li&gt;
&lt;li&gt;Pass the result through an activation function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="err"&gt;₁&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt;₁&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="err"&gt;₂&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt;₂&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is f(z) — the activation function?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
After a neuron computes &lt;code&gt;z = w₁x₁ + w₂x₂ + b&lt;/code&gt;, it passes z through a function called the activation function before outputting anything:&lt;/p&gt;

&lt;p&gt;To understand why this exists, we need to understand one hard problem first.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The linearity problem&lt;/em&gt;&lt;br&gt;
Every neuron computes a weighted sum — which is always a straight line. Stack many neurons together without an activation function, and we still get a straight line. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The real world is not made of straight lines: *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;recognizing faces&lt;/li&gt;
&lt;li&gt;understanding language&lt;/li&gt;
&lt;li&gt;diagnosing disease&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;none of these are linear&lt;/p&gt;

&lt;p&gt;The activation function breaks the linearity. It bends or squashes the output in a nonlinear way.&lt;/p&gt;

&lt;p&gt;So This is why activation functions exist. Without them, deep networks would have no advantage over a single straight line.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>useEffect hook Simple and accurate explanation</title>
      <dc:creator>Aanand</dc:creator>
      <pubDate>Mon, 27 Apr 2026 12:08:10 +0000</pubDate>
      <link>https://forem.com/aanand_4d81b59bb2a50beb70/useeffect-hook-simple-and-accurate-explanation-30bl</link>
      <guid>https://forem.com/aanand_4d81b59bb2a50beb70/useeffect-hook-simple-and-accurate-explanation-30bl</guid>
      <description>&lt;p&gt;React has one job:&lt;br&gt;
👉 Take &lt;strong&gt;data&lt;/strong&gt; → show &lt;strong&gt;UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But real apps need more than just &lt;strong&gt;showing UI&lt;/strong&gt;. You also need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fetch data from APIs&lt;/li&gt;
&lt;li&gt;set timers&lt;/li&gt;
&lt;li&gt;store data&lt;/li&gt;
&lt;li&gt;listen to events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These things are outside React’s job.&lt;/p&gt;

&lt;p&gt;So &lt;strong&gt;useEffect&lt;/strong&gt; lets you run code after React updates the screen, especially for things outside React.&lt;/p&gt;

&lt;p&gt;👉 React &lt;strong&gt;&lt;em&gt;renders UI&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
👉 Then useEffect runs &lt;strong&gt;&lt;em&gt;side work&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚠️ The part most people miss (important)
&lt;/h2&gt;

&lt;p&gt;useEffect is not just “run after render”&lt;/p&gt;

&lt;p&gt;It’s: “Run after render — but only when something changes (if you tell it what to watch)”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 3 real behaviors&lt;/strong&gt; (this is where clarity comes)&lt;/p&gt;

&lt;p&gt;1.Run every time (&lt;strong&gt;default&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Runs after every render&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;em&gt;No control → runs again and again&lt;/em&gt;&lt;br&gt;
👉 Usually a bad idea&lt;/p&gt;

&lt;p&gt;2.Run only once (&lt;strong&gt;on mount&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Runs only once&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Like: “Do this when the &lt;em&gt;page loads&lt;/em&gt;”&lt;/p&gt;

&lt;p&gt;3.Run when &lt;strong&gt;something changes&lt;/strong&gt; (MOST IMPORTANT)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Runs when count changes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 “Only run when count &lt;em&gt;changes&lt;/em&gt;”&lt;/p&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How your compiler finds the data that is stored inside the variable (Symbol table)</title>
      <dc:creator>Aanand</dc:creator>
      <pubDate>Mon, 27 Oct 2025 05:18:59 +0000</pubDate>
      <link>https://forem.com/aanand_4d81b59bb2a50beb70/how-your-compiler-finds-the-data-that-is-stored-inside-the-variable-symbol-table-48c6</link>
      <guid>https://forem.com/aanand_4d81b59bb2a50beb70/how-your-compiler-finds-the-data-that-is-stored-inside-the-variable-symbol-table-48c6</guid>
      <description>&lt;p&gt;Have you ever typed &lt;em&gt;print(variable_name)&lt;/em&gt; and wondered how your compiler actually finds the data by using variable name? It's like magic, but there's a fascinating process working behind the scenes!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables are like house Addresses&lt;/strong&gt;&lt;br&gt;
Think of computer memory like a giant apartment building with millions of rooms. Each room has a number address like "Room #0x1000.&lt;/p&gt;

&lt;p&gt;when you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = 37;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find an empty room:&lt;/strong&gt; The compiler finds an available memory location (say, room #0x1000)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Move in the value:&lt;/strong&gt; The number 37 moves into this room.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Put up a name tag:&lt;/strong&gt; The variable name "num" becomes the friendly name for this address.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Compiler's Secret Address Book&lt;/strong&gt;&lt;br&gt;
So when your program actually runs, all those name tags disappear! how does&lt;br&gt;
&lt;em&gt;&lt;strong&gt;cout &amp;lt;&amp;lt; num&lt;/strong&gt;&lt;/em&gt; still work?&lt;br&gt;
The compiler keeps a secret address book called a symbol table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────┬──────────────────┐
│ Variable   │ Memory Address   │
├────────────┼──────────────────┤
│ num        │ 0x1000           │
│ age        │ 0x1004           │
│ name       │ 0x2000           │
└────────────┴──────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you print a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cout &amp;lt;&amp;lt; num;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The compiler:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Looks up "num" in its address book&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finds it lives at memory address 0x1000&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sends instructions: "Go to address 0x1000 and print what's inside!"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Variable names are for humans — memory addresses are for compiler!&lt;/p&gt;

</description>
      <category>c</category>
      <category>cpp</category>
      <category>programming</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
