<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>PyTorch From First Principles on Programmer.ie</title>
    <link>http://programmer.ie/books/pytorch-zero-to-hero/</link>
    <description>Recent content in PyTorch From First Principles on Programmer.ie</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 22 Aug 2026 11:58:00 +0100</lastBuildDate>
    <atom:link href="http://programmer.ie/books/pytorch-zero-to-hero/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>PyTorch Transforms: From Raw Data to the Tensor Your Model Actually Sees</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/05a-chapter/</link>
      <pubDate>Sat, 22 Aug 2026 11:58:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/05a-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-from-first-principles--interlude-05a&#34;&gt;PyTorch From First Principles — Interlude 05A&lt;/h2&gt;&#xA;&lt;p&gt;In the previous chapter we treated the &lt;code&gt;DataLoader&lt;/code&gt; as a production system.&lt;/p&gt;&#xA;&lt;p&gt;It reads samples, prepares batches, moves work through worker processes and tries to keep the accelerator fed.&lt;/p&gt;&#xA;&lt;p&gt;But there is a question hiding inside that pipeline:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;What exactly is a sample by the time the model receives it?&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;A file on disk is not usually the tensor the model trains on.&lt;/p&gt;</description>
    </item>
    <item>
      <title>10: Build a Small GPT-Style Language Model From Scratch</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/10-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 14:03:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/10-chapter/</guid>
      <description>&lt;h1 id=&#34;build-a-small-gpt-style-language-model-from-scratch-in-pytorch&#34;&gt;Build a Small GPT-Style Language Model From Scratch in PyTorch&lt;/h1&gt;&#xA;&lt;p&gt;This is the final post in the &lt;strong&gt;PyTorch: Zero to Hero&lt;/strong&gt; series.&lt;/p&gt;&#xA;&lt;p&gt;We have spent the previous posts learning the machinery underneath PyTorch:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tensors and shapes;&lt;/li&gt;&#xA;&lt;li&gt;autograd;&lt;/li&gt;&#xA;&lt;li&gt;manual neural networks;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nn.Module&lt;/code&gt; and parameter registration;&lt;/li&gt;&#xA;&lt;li&gt;DataLoader performance;&lt;/li&gt;&#xA;&lt;li&gt;convolutional networks;&lt;/li&gt;&#xA;&lt;li&gt;attention and masks;&lt;/li&gt;&#xA;&lt;li&gt;training failures;&lt;/li&gt;&#xA;&lt;li&gt;CUDA performance and &lt;code&gt;torch.compile&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now we put it together.&lt;/p&gt;&#xA;&lt;p&gt;The goal is not to download a pretrained model.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Training Regressions and Reproducible Experiments: When Nothing Crashes but the Model Gets Worse</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/09b-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 14:00:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/09b-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--advanced-step-09b&#34;&gt;PyTorch: Zero to Hero — Advanced Step 09B&lt;/h2&gt;&#xA;&lt;p&gt;Most bugs in this book have announced themselves loudly.&lt;/p&gt;&#xA;&lt;p&gt;A tensor had the wrong shape.&lt;/p&gt;&#xA;&lt;p&gt;A parameter had no gradient.&lt;/p&gt;&#xA;&lt;p&gt;A model refused to learn.&lt;/p&gt;&#xA;&lt;p&gt;CUDA ran out of memory.&lt;/p&gt;&#xA;&lt;p&gt;A compiled graph broke or recompiled.&lt;/p&gt;&#xA;&lt;p&gt;But some of the most expensive machine-learning bugs are quieter.&lt;/p&gt;&#xA;&lt;p&gt;The program still runs.&lt;/p&gt;&#xA;&lt;p&gt;The tests still pass.&lt;/p&gt;&#xA;&lt;p&gt;Training still finishes.&lt;/p&gt;&#xA;&lt;p&gt;And yet:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;validation loss is worse&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;training takes 12% longer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;peak VRAM is 20% higher&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gradients became less stable&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;compile count increased&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;throughput dropped&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;convergence needs twice as many steps&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nothing failed inside the run.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Compiler Debugging: Graph Breaks, Guards, Recompiles and torch.compile</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/09a-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:58:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/09a-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--advanced-step-09a&#34;&gt;PyTorch: Zero to Hero — Advanced Step 09A&lt;/h2&gt;&#xA;&lt;p&gt;In the previous chapter we treated &lt;code&gt;torch.compile&lt;/code&gt; as one tool inside a larger performance-debugging workflow.&lt;/p&gt;&#xA;&lt;p&gt;That is enough until compilation itself becomes the problem.&lt;/p&gt;&#xA;&lt;p&gt;Then the questions change.&lt;/p&gt;&#xA;&lt;p&gt;The model runs in eager mode.&lt;/p&gt;&#xA;&lt;p&gt;The model may even run when compiled.&lt;/p&gt;&#xA;&lt;p&gt;But perhaps:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;compile time is enormous&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;first call takes seconds&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;new shapes keep compiling again&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;graph breaks appear inside forward()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;compiled execution is slower than eager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;one backend works and another fails&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;small code changes produce very different compiler behavior&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At that point, &lt;code&gt;torch.compile(model)&lt;/code&gt; is not the end of the story.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Performance Debugging: CUDA OOM, Slow Training, GPU Utilization and torch.compile</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/09-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:56:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/09-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-09&#34;&gt;PyTorch: Zero to Hero — Step 09&lt;/h2&gt;&#xA;&lt;p&gt;At this point in the series, the model runs.&lt;/p&gt;&#xA;&lt;p&gt;That does not mean it runs well.&lt;/p&gt;&#xA;&lt;p&gt;A training loop can be correct and still waste most of the machine.&lt;/p&gt;&#xA;&lt;p&gt;A model can fit in memory and still spend half its time waiting on synchronization.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;code&gt;torch.compile&lt;/code&gt; call can make code faster, slower, or simply move the bottleneck somewhere else.&lt;/p&gt;&#xA;&lt;p&gt;A CUDA out-of-memory error can be caused by the model, the optimizer, activations, fragmentation, a leaked reference, a larger batch, a longer sequence, or an innocent-looking tensor that was kept alive by Python.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Model Not Learning? A Systematic Debugging Guide</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/08-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:51:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/08-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-08&#34;&gt;PyTorch: Zero to Hero — Step 08&lt;/h2&gt;&#xA;&lt;p&gt;Your model runs.&lt;/p&gt;&#xA;&lt;p&gt;The loss is finite.&lt;/p&gt;&#xA;&lt;p&gt;Nothing crashes.&lt;/p&gt;&#xA;&lt;p&gt;And it still does not learn.&lt;/p&gt;&#xA;&lt;p&gt;This is one of the most frustrating states in machine learning because there is no stack trace telling you what is wrong.&lt;/p&gt;&#xA;&lt;p&gt;The program is valid Python.&lt;/p&gt;&#xA;&lt;p&gt;The tensors have legal shapes.&lt;/p&gt;&#xA;&lt;p&gt;The GPU is busy.&lt;/p&gt;&#xA;&lt;p&gt;The optimizer is stepping.&lt;/p&gt;&#xA;&lt;p&gt;And the model is useless.&lt;/p&gt;&#xA;&lt;p&gt;This post is a systematic way to debug that situation.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Attention Shapes: Q, K, V, Multi-Head Attention Masks and Transformer Dimension Errors</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/07-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:30:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/07-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-07&#34;&gt;PyTorch: Zero to Hero — Step 07&lt;/h2&gt;&#xA;&lt;p&gt;Attention code is where tensor-shape mistakes stop being annoying and start becoming architectural.&lt;/p&gt;&#xA;&lt;p&gt;A CNN usually makes its dimensional assumptions fairly obvious. Attention does not.&lt;/p&gt;&#xA;&lt;p&gt;A tensor that starts as:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(batch, sequence, embedding)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;is projected into Q, K and V, split into heads, transposed, multiplied, masked, normalized, multiplied again, transposed again, concatenated and projected back to the embedding dimension.&lt;/p&gt;&#xA;&lt;p&gt;A single bad &lt;code&gt;view&lt;/code&gt;, &lt;code&gt;transpose&lt;/code&gt;, mask shape or head calculation can produce anything from an immediate runtime error to a model that trains while attending to the wrong tokens.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Beyond 3D: Tensors, 100 Dimensions and an SVM From Scratch</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/06a-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:28:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/06a-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--advanced-interlude-06a&#34;&gt;PyTorch: Zero to Hero — Advanced Interlude 06A&lt;/h2&gt;&#xA;&lt;p&gt;There is a point in machine learning where the numbers become difficult for a human being to picture.&lt;/p&gt;&#xA;&lt;p&gt;One dimension is easy.&lt;/p&gt;&#xA;&lt;p&gt;Two dimensions are easy.&lt;/p&gt;&#xA;&lt;p&gt;Three dimensions are still possible to draw.&lt;/p&gt;&#xA;&lt;p&gt;Then somebody hands you a tensor containing 100 features.&lt;/p&gt;&#xA;&lt;p&gt;Or 768.&lt;/p&gt;&#xA;&lt;p&gt;Or 4,096.&lt;/p&gt;&#xA;&lt;p&gt;And suddenly the language changes.&lt;/p&gt;&#xA;&lt;p&gt;People start talking about &lt;em&gt;embedding spaces&lt;/em&gt;, &lt;em&gt;feature directions&lt;/em&gt;, &lt;em&gt;hyperplanes&lt;/em&gt;, &lt;em&gt;high-dimensional geometry&lt;/em&gt; and &lt;em&gt;latent representations&lt;/em&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch CNN Shape Errors: Conv2d Output Sizes, Channels, Flatten Bugs and How to Debug Them</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/06-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:26:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/06-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-06&#34;&gt;PyTorch: Zero to Hero — Step 06&lt;/h2&gt;&#xA;&lt;p&gt;CNN code is usually easy to write.&lt;/p&gt;&#xA;&lt;p&gt;CNN shape bugs are usually easy to create.&lt;/p&gt;&#xA;&lt;p&gt;A typical failure looks like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RuntimeError: Given groups=1, weight of size [32, 3, 3, 3],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;expected input[64, 224, 224, 3] to have 3 channels,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;but got 224 channels instead&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RuntimeError: mat1 and mat2 shapes cannot be multiplied&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or worse: the model runs, but the dimensions are wrong in a way that silently damages the architecture.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch DataLoader Performance: num_workers, pin_memory, Prefetching and Why Your GPU Is Waiting</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/05-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:21:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/05-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-05&#34;&gt;PyTorch: Zero to Hero — Step 05&lt;/h2&gt;&#xA;&lt;p&gt;A fast model with a slow input pipeline is still a slow training system.&lt;/p&gt;&#xA;&lt;p&gt;One of the most common PyTorch performance failures looks like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;GPU utilization: 20% → 95% → 10% → 90% → 15%&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The model is not necessarily slow.&lt;/p&gt;&#xA;&lt;p&gt;The GPU may simply be waiting for the next batch.&lt;/p&gt;&#xA;&lt;p&gt;This article is about finding out &lt;strong&gt;where the wait is happening&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Most Important Idea in PyTorch: Recursive Composition</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/04-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 13:09:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/04-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-04&#34;&gt;PyTorch: Zero to Hero — Step 04&lt;/h2&gt;&#xA;&lt;p&gt;In the previous post we built a neural network using raw tensors and autograd.&lt;/p&gt;&#xA;&lt;p&gt;We had weights.&lt;/p&gt;&#xA;&lt;p&gt;We had biases.&lt;/p&gt;&#xA;&lt;p&gt;We had a forward calculation.&lt;/p&gt;&#xA;&lt;p&gt;We had a loss.&lt;/p&gt;&#xA;&lt;p&gt;We called &lt;code&gt;backward()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We updated the parameters.&lt;/p&gt;&#xA;&lt;p&gt;Nothing essential was missing from the mathematics of training.&lt;/p&gt;&#xA;&lt;p&gt;Now we are going to add &lt;code&gt;nn.Module&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But I do not want to introduce it as another PyTorch class whose methods you need to memorize.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Build a Neural Network From Scratch in PyTorch Without nn.Module</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/03-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 12:59:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/03-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-03&#34;&gt;PyTorch: Zero to Hero — Step 03&lt;/h2&gt;&#xA;&lt;p&gt;Most PyTorch tutorials begin with something like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; torch.nn &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; nn&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;model &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; nn&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Sequential(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    nn&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Linear(&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;16&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    nn&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;ReLU(),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    nn&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Linear(&lt;span style=&#34;color:#ae81ff&#34;&gt;16&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That is useful code.&lt;/p&gt;&#xA;&lt;p&gt;It is also hiding almost everything interesting.&lt;/p&gt;&#xA;&lt;p&gt;In this post we are going to build the same kind of neural network using ordinary PyTorch tensors.&lt;/p&gt;&#xA;&lt;p&gt;No &lt;code&gt;nn.Module&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;No &lt;code&gt;nn.Linear&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;No &lt;code&gt;torch.optim.Adam&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;No &lt;code&gt;optimizer.step()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;We will manually create the parameters, write the forward pass, calculate the loss, call autograd, update the weights, zero the gradients, batch the data, evaluate the model and then compare the result with the idiomatic PyTorch version.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Autograd Debugging: requires_grad, detach, backward() and NaN Gradients</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/02-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 12:55:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/02-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-02&#34;&gt;PyTorch: Zero to Hero — Step 02&lt;/h2&gt;&#xA;&lt;p&gt;In the previous post we treated tensor shapes as a debugging problem rather than a mathematical vocabulary exercise.&lt;/p&gt;&#xA;&lt;p&gt;We are going to do the same thing with autograd.&lt;/p&gt;&#xA;&lt;p&gt;If you use PyTorch for any serious amount of time, you eventually see errors like:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RuntimeError: Trying to backward through the graph a second time...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or worse:&lt;/p&gt;</description>
    </item>
    <item>
      <title>PyTorch Tensor Shapes: Broadcasting, Reshape, View, Permute and the Errors That Waste Your Time</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/01-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 12:45:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/01-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-zero-to-hero--step-01&#34;&gt;PyTorch: Zero to Hero — Step 01&lt;/h2&gt;&#xA;&lt;p&gt;Most PyTorch bugs are not really &amp;ldquo;AI bugs&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;They are shape bugs.&lt;/p&gt;&#xA;&lt;p&gt;You expected:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[batch, features]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;but actually had:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[batch, sequence, features]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You expected two tensors to line up.&lt;/p&gt;&#xA;&lt;p&gt;They broadcast instead.&lt;/p&gt;&#xA;&lt;p&gt;You called &lt;code&gt;view()&lt;/code&gt; after &lt;code&gt;permute()&lt;/code&gt; and got a contiguity error.&lt;/p&gt;&#xA;&lt;p&gt;You removed a dimension with &lt;code&gt;squeeze()&lt;/code&gt; and accidentally removed the batch dimension too.&lt;/p&gt;&#xA;&lt;p&gt;Or you reached the familiar message:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RuntimeError: The size of tensor a (...) must match the size of tensor b (...)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This article is about becoming dangerous enough with tensors that these errors stop being mysterious.&lt;/p&gt;</description>
    </item>
    <item>
      <title>00: What Are We Actually Doing?</title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/00-chapter/</link>
      <pubDate>Sat, 08 Aug 2026 12:40:00 +0100</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/00-chapter/</guid>
      <description>&lt;h2 id=&#34;pytorch-from-first-principles&#34;&gt;PyTorch From First Principles&lt;/h2&gt;&#xA;&lt;p&gt;This is &lt;strong&gt;Step 0&lt;/strong&gt; of &lt;em&gt;PyTorch From First Principles&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The book starts with the smallest possible training problem and ends with a small GPT-style language model built from scratch.&lt;/p&gt;&#xA;&lt;p&gt;But the goal is not to memorize a collection of PyTorch commands.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to understand the machinery underneath those commands well enough that unfamiliar PyTorch code becomes something you can inspect, reason about, debug and change.&lt;/p&gt;</description>
    </item>
    <item>
      <title></title>
      <link>http://programmer.ie/books/pytorch-zero-to-hero/_work/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>http://programmer.ie/books/pytorch-zero-to-hero/_work/</guid>
      <description>&lt;h1 id=&#34;pytorch-zero-to-hero--working-ledger&#34;&gt;PyTorch: Zero to Hero — Working Ledger&lt;/h1&gt;&#xA;&lt;h2 id=&#34;book-intention&#34;&gt;Book intention&lt;/h2&gt;&#xA;&lt;p&gt;Learn PyTorch by understanding what the framework is doing from first principles, then build upward from the core training loop to modern model architectures.&lt;/p&gt;&#xA;&lt;p&gt;This book is already substantially written. The ledger does &lt;strong&gt;not&lt;/strong&gt; assume that published chapters are editorially complete: the new pass should test the progression, remove avoidable duplication, and preserve the practical debugging character that makes the sequence useful.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
