<?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"><channel><title><![CDATA[mycifarproject]]></title><description><![CDATA[mycifarproject]]></description><link>https://d1shasaini.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/69ee47ad3d6a492cdd29d8dd/cecf20cd-511d-4e45-a6cb-7e8ebffd74aa.jpg</url><title>mycifarproject</title><link>https://d1shasaini.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 11:22:27 GMT</lastBuildDate><atom:link href="https://d1shasaini.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[My Baseline Broke: What an 18% Accuracy Gap Taught Me About Deep Learning]]></title><description><![CDATA[Recently, I set out to reproduce a standard CNN baseline on CIFAR-10.
It was supposed to be a warm-up. A "hello world" for my semester project. I wrote the code, grabbed the dataset, and queued up fou]]></description><link>https://d1shasaini.hashnode.dev/my-baseline-broke-what-an-18-accuracy-gap-taught-me-about-deep-learning</link><guid isPermaLink="true">https://d1shasaini.hashnode.dev/my-baseline-broke-what-an-18-accuracy-gap-taught-me-about-deep-learning</guid><category><![CDATA[AI]]></category><category><![CDATA[Deep Learning]]></category><category><![CDATA[Machine Learning]]></category><dc:creator><![CDATA[disha]]></dc:creator><pubDate>Wed, 29 Apr 2026 11:55:24 GMT</pubDate><content:encoded><![CDATA[<img src="https://cdn.hashnode.com/uploads/covers/69ee47ad3d6a492cdd29d8dd/cb1ea6b8-216c-41ce-8e33-fd9e47fa3d37.png" alt="" style="display:block;margin:0 auto" />

<p>Recently, I set out to reproduce a standard CNN baseline on CIFAR-10.</p>
<p>It was supposed to be a warm-up. A "hello world" for my semester project. I wrote the code, grabbed the dataset, and queued up four different optimizers: SGD, Adam, AdamW, and RMSprop.</p>
<p>I expected Adam to win. Everyone says Adam is robust. Everyone says Adam is default.</p>
<p><strong>It didn't.</strong></p>
<p>In fact, SGD crushed it. By 18%.</p>
<p>While waiting for the epochs to finish on my CPU, I stared at the logs wondering if I’d coded the loss function wrong. I hadn’t.</p>
<p>This wasn’t a coding bug. It was a <strong>hyperparameter trap</strong>. And realizing it changed how I think about every model I’ll ever build again.</p>
<h2>The "Copy-Paste" Problem</h2>
<p>As students, we operate under a weird constraint: <strong>Time.</strong></p>
<p>We want to build cool things. We don’t want to spend three days debugging why our loss isn’t going down. So, we rely on templates. We copy config files from GitHub repositories. We use <code>learning_rate = 0.01</code> because it worked in a tutorial.</p>
<p>I fell into this exact trap.</p>
<p>I assumed the optimizer was a plug-in component. You import <code>torch.optim.Adam</code>, pass your parameters, and go. But optimizers aren’t utilities like libraries. They’re physics engines. They behave differently depending on the environment you put them in.</p>
<h3>The Setup (Fixed Variables)</h3>
<p>To see what actually mattered, I locked everything down:</p>
<ul>
<li><p><strong>Dataset:</strong> CIFAR-10</p>
</li>
<li><p><strong>Architecture:</strong> Standard CNN (3 Conv Layers)</p>
</li>
<li><p><strong>Batch Size:</strong> 128</p>
</li>
<li><p><strong>Epochs:</strong> 20</p>
</li>
<li><p><strong>Learning Rate:</strong> 0.01 (The Critical Variable)</p>
</li>
<li><p><strong>Seed:</strong> Fixed (for reproducibility)</p>
</li>
</ul>
<p>I ran them side-by-side. Here is what happened.</p>
<h2>The Shocking Results</h2>
<table>
<thead>
<tr>
<th>Rank</th>
<th>Optimizer</th>
<th>Val Acc</th>
<th>Train Acc</th>
<th>Generalization Gap</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td><strong>SGD</strong></td>
<td><strong>80.53%</strong></td>
<td>78.98%</td>
<td><strong>-1.55%</strong></td>
</tr>
<tr>
<td>2</td>
<td>AdamW</td>
<td>72.99%</td>
<td>66.39%</td>
<td>-6.60%</td>
</tr>
<tr>
<td>3</td>
<td>Adam</td>
<td>66.86%</td>
<td>63.37%</td>
<td>-3.49%</td>
</tr>
<tr>
<td>4</td>
<td>RMSprop</td>
<td>62.11%</td>
<td>62.02%</td>
<td>-0.09%</td>
</tr>
</tbody></table>
<p><strong>The Winner:</strong> SGD.<br /><strong>The Loser:</strong> RMSprop.<br /><strong>The Spread:</strong> 18.42% accuracy difference.</p>
<p>This number is huge. In research papers, squeezing out 0.5% is considered an improvement. I saw nearly 20% swing because I didn’t tweak one float.</p>
<p>But look at the <strong>Generalization Gap</strong>.</p>
<blockquote>
<p><strong>Val Acc &gt; Train Acc?</strong></p>
</blockquote>
<p>My SGD model performed <em>better</em> on the validation set than the training set. This usually signals overfitting issues, but here it meant SGD’s implicit regularization forced the model to learn features rather than memorizing noise.</p>
<p>Adam? It underfit both train and val. It got stuck.</p>
<h2>The Root Cause: Hyperparameter Coupling</h2>
<p>Here’s the part that clicked for me.</p>
<p>Optimizers and Learning Rates are <strong>coupled</strong>.</p>
<p>You cannot change one without changing how the other behaves.</p>
<ul>
<li><p><strong>SGD</strong> thrives at <code>lr = 0.01</code> on CIFAR-10. It takes stable steps.</p>
</li>
<li><p><strong>Adam</strong> adapts the step size based on gradient variance. If you feed it <code>lr = 0.01</code>, its internal adaptive mechanism amplifies that value. The effective step becomes too massive. It overshoots the minimum like a car drifting on ice.</p>
</li>
</ul>
<p>I treated the Learning Rate as a global constant. That was my design flaw.</p>
<p><strong>The Lesson:</strong> An optimizer isn't a setting. It's a contract. And I signed a contract with SGD using terms only applicable to SGD.</p>
<h2>Building a "Student-Proof" Pipeline</h2>
<p>I’m not going to build the next AutoML startup tomorrow. But I can improve my own workflow for the rest of my degree.</p>
<p>Here is how I’m designing my personal development environment to prevent this mistake.</p>
<h3>1. The "Sanity Check" Epoch</h3>
<p>Before running 100 epochs, I run 5.</p>
<ul>
<li><p>Run SGD, Adam, AdamW at <strong>their native defaults</strong> (SGD @ 0.01, Adam @ 0.001).</p>
</li>
<li><p>Look at the Loss curve immediately.</p>
</li>
<li><p>If Adam’s loss oscillates, kill it. Move on.</p>
</li>
</ul>
<h3>2. The Config Constraint</h3>
<p>I’m writing a wrapper around my training config (YAML/JSON).</p>
<ul>
<li><p>If <code>optimizer == 'adam'</code>, the search space for <code>lr</code> is constrained to <code>[1e-4, 1e-3]</code>.</p>
</li>
<li><p>If <code>optimizer == 'sgd'</code>, the search space is <code>[1e-3, 1e-2]</code>.</p>
</li>
<li><p><strong>Goal:</strong> Prevents accidental mismatch. Makes the error impossible.</p>
</li>
</ul>
<h3>3. Track the Gap, Not Just Loss</h3>
<p>I used to look at Validation Loss. Now I track <code>Train Acc - Val Acc</code>.</p>
<ul>
<li><p><strong>High Positive Gap:</strong> Overfitting (Need Dropout/Augmentation).</p>
</li>
<li><p><strong>Negative Gap:</strong> Underfitting / High Regularization (Maybe increase capacity?).</p>
</li>
<li><p><strong>Zero/Near Zero:</strong> Balanced.</p>
</li>
</ul>
<h2>Why This Actually Matters</h2>
<p>We spend so much time reading papers on new architectures (ResNet, ViT, Transformers) that we forget the basics.</p>
<p><strong>Optimization is the foundation.</strong></p>
<p>If your optimization strategy is flawed, your architecture is invisible. You could build the most beautiful Neural Network in the world, but if the gradients explode because you set <code>lr=0.1</code> on Adam, you’re wasting electricity.</p>
<p>For us as students, mastering this is more valuable than chasing state-of-the-art SOTA. Because in an internship, no one will ask "What was your FLOP count?" Someone will ask "Did you verify your hyperparameters?"</p>
<h2>Real Talk: The Limitations</h2>
<p>It’s easy to write this off as "just use SGD." But there’s nuance.</p>
<ol>
<li><p><strong>Transformers Love Adam.</strong> On LLMs, SGD diverges often. This experiment was on a CNN/Vision task. Context matters.</p>
</li>
<li><p><strong>Schedules Matter.</strong> I used a fixed LR. In production, you’d use Cosine Annealing. That changes the game again.</p>
</li>
<li><p><strong>Compute Budget.</strong> Running 4 optimizers x 3 LR schedules = 12 runs. For a GPU-heavy lab? Cheap. For a laptop student? Painful. There’s always a trade-off between rigor and resources.</p>
</li>
</ol>
<h2>The Bigger Picture</h2>
<p>We treat Machine Learning like magic. We throw data in, pull weights out, and expect wisdom.</p>
<p>But it’s engineering. It’s mechanical. It relies on tension, friction, and precise adjustments.</p>
<p>By obsessing over the details—the learning rate, the gap, the optimizer—I stopped treating my models like black boxes. I started seeing them as systems I control.</p>
<p>And that shift in mindset? That’s worth more than any single accuracy point.</p>
<p><strong>Question for you:</strong></p>
<p>Have you ever seen a model fail simply because you copied a learning rate from a GitHub repo? How did you fix it?</p>
]]></content:encoded></item></channel></rss>