<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>View on Programmer.ie: Modern AI programming</title>
    <link>http://programmer.ie/tags/view/</link>
    <description>Recent content in View on Programmer.ie: Modern AI programming</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 08 Aug 2026 12:45:00 +0100</lastBuildDate>
    <atom:link href="http://programmer.ie/tags/view/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>PyTorch Tensor Shapes: Broadcasting, Reshape, View, Permute and the Errors That Waste Your Time</title>
      <link>http://programmer.ie/post/pytorch-zero-to-hero-01/</link>
      <pubDate>Sat, 08 Aug 2026 12:45:00 +0100</pubDate>
      <guid>http://programmer.ie/post/pytorch-zero-to-hero-01/</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>
  </channel>
</rss>
