<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Neural Network From Scratch on Programmer.ie: Modern AI programming</title>
    <link>http://programmer.ie/tags/neural-network-from-scratch/</link>
    <description>Recent content in Neural Network From Scratch on Programmer.ie: Modern AI programming</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 08 Aug 2026 12:59:00 +0100</lastBuildDate>
    <atom:link href="http://programmer.ie/tags/neural-network-from-scratch/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Build a Neural Network From Scratch in PyTorch Without nn.Module</title>
      <link>http://programmer.ie/post/pytorch-zero-to-hero-03/</link>
      <pubDate>Sat, 08 Aug 2026 12:59:00 +0100</pubDate>
      <guid>http://programmer.ie/post/pytorch-zero-to-hero-03/</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>
  </channel>
</rss>
