<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>All Posts - Jorgen Bergstrom</title><link>https://bergstrom.org/posts/</link><description>All Posts | Jorgen Bergstrom</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>Jorgen Bergstrom</copyright><lastBuildDate>Sat, 26 Sep 2026 00:00:00 -0500</lastBuildDate><atom:link href="https://bergstrom.org/posts/" rel="self" type="application/rss+xml"/><item><title>A Tiny Neural Network, Explained</title><link>https://bergstrom.org/posts/scalar_autograd_nn/</link><pubDate>Sat, 26 Sep 2026 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/scalar_autograd_nn/</guid><description>Introduction In the previous article we built engine.py: a complete reverse-mode automatic differentiation engine in about 80 lines, built around a single Value class. That engine knows how to record arithmetic on scalars and hand back the gradient of the final result with respect to every scalar that fed into it.
This article builds the next layer on top: nn.py, a small neural-network library in roughly 60 lines (heres the repo).</description></item><item><title>Predicting Cancer with a Tiny Autograd Engine</title><link>https://bergstrom.org/posts/cancer_prediction/</link><pubDate>Sat, 26 Sep 2026 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/cancer_prediction/</guid><description>Introduction In the first two articles of this series we built a reverse-mode autograd engine (engine.py) and a small neural-network library on top of it (nn.py). Together they are about 140 lines of pure Python with no numerical dependencies beyond the standard library.
This article puts them to work on a real problem: predicting whether a breast tumor is malignant from measurements taken from a digitized image. The script is cancer_prediction.</description></item><item><title>A Tiny Autograd Engine, Explained</title><link>https://bergstrom.org/posts/scalar_autograd/</link><pubDate>Thu, 24 Sep 2026 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/scalar_autograd/</guid><description>Introduction engine.py is a complete reverse-mode automatic differentiation engine in about 80 lines (heres the repo). It has a single class, Value, that wraps one scalar and remembers how that scalar was computed, so that calling .backward() fills in the derivative of the final value with respect to every value that fed into it.
It&amp;rsquo;s the same core idea as PyTorch&amp;rsquo;s autograd, just small enough to read in one sitting. The code is also strongly influenced by Karpathy&amp;rsquo;s micrograd repo.</description></item><item><title>Rubber or Thermoplastic: a Stress-Strain Image Classifier</title><link>https://bergstrom.org/posts/elastomer_thermoplastic_classifier/</link><pubDate>Mon, 14 Sep 2026 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/elastomer_thermoplastic_classifier/</guid><description>Introduction A common way to learn how Convolutional Neural Networks (CNNs) work is to develop a tool that can classify whether an image is a cat or a dog (in this case all images are either of a cat or of a dog, no other options are allowed). I created an example that does just that.
Since my background is in polymer mechanics, I wanted a more interesting version of this classification task: given an image of a stress-strain curve, decide whether it comes from a rubber material or a thermoplastic.</description></item><item><title>Machine Learning Terminology</title><link>https://bergstrom.org/posts/ml_terminology/</link><pubDate>Thu, 27 Feb 2025 20:18:36 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/ml_terminology/</guid><description>Different Types of Neural Networks (NN) There are several types of neural networks designed to perform specific tasks or process different kinds of data. Here are some of the most popular basic types:
Feedforward Neural Networks (FFN) The simplest type of neural network, consisting of interconnected nodes. Convolutional Neural Networks (CNN) Primarily used for image and vision-related tasks such as object recognition. Reccurent Neural Networks (RRN) Designed to process sequential data, like time series, by maintaining internal state variables.</description></item><item><title>CNN Cats vs Dogs Classification</title><link>https://bergstrom.org/posts/cnn_cats_vs_dogs/</link><pubDate>Sat, 07 Dec 2024 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/cnn_cats_vs_dogs/</guid><description>Introduction In this example I will use the Kaggle cats and dogs dataset to train a CNN to classify if an image is a cat or a dog.
The code below reads all images from a local PetImages folder and splits them into a training and a validation set. Before training, the images are preprocessed with simple data augmentation: random horizontal flips and small rotations are applied to make the model more robust, and the pixel values are rescaled to the range [0, 1].</description></item><item><title>Backpropagation Part 3: 1 Hidden Layer, N Perceptrons</title><link>https://bergstrom.org/posts/backpropagation_part_3/</link><pubDate>Sat, 16 Nov 2024 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/backpropagation_part_3/</guid><description>[1 Input] + [1 Hidden Layer with N Perceptrons] + [1 Output] In this example I will extend my previous code to be able to handle a hidden layer with N perceptrons. As before, I will demonstrate the use of the neural network by fitting it to the following mathematical function: $y = 0.1 + 0.1 \cdot x^2$ over the range $x \in [0, 10]$. The C++ implementation for this example can be found in my github account.</description></item><item><title>Backpropagation Part 2: 1 Hidden Layer, 2 Perceptrons</title><link>https://bergstrom.org/posts/backpropagation_part_2/</link><pubDate>Tue, 22 Oct 2024 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/backpropagation_part_2/</guid><description><![CDATA[[1 Input] + [1 Hidden Layer with 2 Perceptrons] + [1 Output] In this example I will create a simple neural network that has one input, one hidden layer with 2 perceptrons, and one output. I will then fit that neural network to the following mathematical function: $y = 0.1 + 0.1 \cdot x^2$ over the range $x \in [0,10]$.
C++ code to solve this problem is listed below:
// 2 Layers: 1 input, 2 hidden, 1 output #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;algorithm&gt; #include &lt;cassert&gt; #include &lt;vector&gt; #include &lt;cmath&gt; #include &lt;random&gt; double activation(double x, int type) { if (type==1) return std::max(0.]]></description></item><item><title>Backpropagation Part 1: Single Perceptron</title><link>https://bergstrom.org/posts/backpropagation_part_1/</link><pubDate>Sun, 20 Oct 2024 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/backpropagation_part_1/</guid><description>One Network Layer with 1 Input and 1 Output The simplest neural network architecture consists of a single perceptron. This network has only one input and one output, making it a highly streamlined model. While suitable for theoretical understanding, it is insufficient for real-world applications due to its limited capacity. However, it serves as a fundamental building block for studying the principles of backpropagation and training neural networks.
Code Location You can find the source code for this example here.</description></item><item><title>Install llama.cpp and Gemma from Huggingface</title><link>https://bergstrom.org/posts/install_llama_cpp_and_gemma/</link><pubDate>Sat, 19 Oct 2024 00:00:00 -0500</pubDate><author>Jorgen Bergstrom</author><guid>https://bergstrom.org/posts/install_llama_cpp_and_gemma/</guid><description>Installation Learning how large language models (LLMs) like ChatGPT and Gemini work can be both fascinating and empowering. While using them through APIs is convenient, running one locally on your own computer unlocks deeper understanding and control. Fortunately, setting up your own LLM on Linux or Windows is surprisingly straightforward.
In this article, I will walk you through the simple steps to run a popular LLM like Transformers on your own computer.</description></item></channel></rss>