<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="rss/style.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>jeremylondon.com</title><description>Exploring AI, tech trends, and engineering in a uniquely engaging blog for the curious mind.</description><link>https://jeremylondon.com/</link><item><title>Backpropagation and Gradient Descent: The Backbone of Neural Network Training</title><link>https://jeremylondon.com/blog/deep-learning-basics-deciphering-backpropagation/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-deciphering-backpropagation/</guid><description>How do neural networks learn? Lets explore backpropagation and gradient descent and their critical roles in updating weights through the lens of loss minimization.</description><pubDate>Fri, 12 Apr 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;import { Image } from &apos;astro:assets&apos;
import HocusPocus from &quot;@assets/hocus-pocus-machine-learning.gif&quot;&lt;/p&gt;
&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;👋 Hi there! In this seventh installment of my Deep Learning Fundamentals Series, lets explore more and finally understand backpropagation and gradient descent. These two concepts are like the dynamic duo that makes neural networks learn and improve, kind of like a brain gaining superpowers! What makes them so mysterious... and how do they work together to make neural networks so powerful?&lt;/p&gt;
&lt;p&gt;Neural networks have captivated the world with their remarkable ability to learn and solve complex problems. From image recognition to natural language processing, these powerful models have revolutionized countless industries. But have you ever wondered how neural networks actually learn? What are the mechanisms that allow them to take in raw data, identify patterns, and make accurate predictions?&lt;/p&gt;
&lt;p&gt;The key to understanding the learning process of neural networks lies in two fundamental concepts: &lt;strong&gt;backpropagation&lt;/strong&gt; and &lt;strong&gt;gradient descent&lt;/strong&gt;. These two ideas form the backbone of how neural networks adapt and improve over time, continuously refining their internal parameters to minimize the difference between their predictions and the true desired outputs.&lt;/p&gt;
&lt;p&gt;&amp;lt;div class=&quot;float-right ml-4 h-auto w-full overflow-hidden sm:w-1/2&quot;&amp;gt;
&amp;lt;Image
src={HocusPocus}
alt=&quot;Hocus Pocus Machine Learning&quot;
class=&quot;-mt-2 block h-auto w-full&quot;
/&amp;gt;
&amp;lt;/div&amp;gt;&lt;/p&gt;
&lt;p&gt;In this in-depth blog post, I&apos;ll get under the hood and into the mechanics of backpropagation and gradient descent, exploring how they work together to enable neural networks to learn. I&apos;ll start by breaking down the core principles behind each concept, then see how they are applied in the context of a multi-layer neural network. Along the way, I&apos;ll unpack the mathematical intuitions and dive into real-world code examples to solidify your understanding.&lt;/p&gt;
&lt;p&gt;By the end, you&apos;ll have a crystal-clear grasp of the inner workings of neural network training, equipping you with the knowledge to build, train, and refine your own sophisticated models. So, let&apos;s get started and see how backpropagation and gradient descent work!&lt;/p&gt;
&lt;h3&gt;What is Gradient Descent and Backpropagation?&lt;/h3&gt;
&lt;p&gt;Think of training a neural network like teaching a student. The network makes predictions, and then backpropagation and gradient descent work together to correct those predictions when they&apos;re off the mark. They do this by adjusting the network&apos;s internal settings, known as weights and biases.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Backpropagation is like a feedback loop. It calculates how much each weight and bias contributed to the mistake and sends this info back through the network. It&apos;s like saying, &quot;Hey, this setting made us veer off course; let&apos;s adjust it next time.&quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Gradient descent, on the other hand, is the optimizer. It uses the info from backpropagation to adjust the weights and biases, nudging the network towards making better predictions. It&apos;s like a guide that helps the network find the path of least resistance to the right answer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Together, they form a cycle of continuous improvement. Backpropagation identifies the mistakes, and gradient descent makes the necessary adjustments. It&apos;s a beautiful partnership that refines the neural network&apos;s skills.&lt;/p&gt;
&lt;h3&gt;Making the Neural Networks Learn&lt;/h3&gt;
&lt;p&gt;At the heart of neural network training lies the challenge of optimization - how do we find the set of weights and biases that minimizes the difference between the model&apos;s predictions and the true target outputs? This is where gradient descent comes into play, serving as the workhorse algorithm that guides the network towards the global minimum of the loss function.&lt;/p&gt;
&lt;p&gt;Imagine you&apos;re standing atop a hilly landscape, and your goal is to find the lowest point as quickly as possible. This is analogous to the optimization problem faced by neural networks - the &quot;landscape&quot; is the loss function, and the &quot;lowest point&quot; represents the configuration of weights and biases that result in the smallest possible error.&lt;/p&gt;
&lt;p&gt;Gradient descent works by calculating the gradients, which show the direction of the steepest loss increase. Then, it does the opposite, moving the network towards the global minimum, the optimal solution. It&apos;s like a smart hiker knowing to avoid steep climbs and finding the easiest path down.&lt;/p&gt;
&lt;p&gt;The learning rate is like your hiking speed. Too fast, and we might overshoot the minimum and end up unstable. Too slow, and it will take forever to reach your destination. Finding the right balance is crucial for effective learning.&lt;/p&gt;
&lt;h3&gt;Backpropagation in Action&lt;/h3&gt;
&lt;p&gt;While gradient descent does the updating, backpropagation provides the directions by calculating the gradients. It&apos;s like backpropagation is the navigator, figuring out the best route by considering past experiences (or, in this case, past predictions).&lt;/p&gt;
&lt;p&gt;Despite its name, backpropagation doesn&apos;t involve information flowing backwards. It&apos;s more like a clever use of math, specifically the chain rule in calculus, to efficiently calculate the gradients.&lt;/p&gt;
&lt;p&gt;The code starts backpropagation when it begins to calculate the gradient of the loss concerning the final layer&apos;s pre-activation values. This gradient shows how much the loss would change if we tweaked those values.&lt;/p&gt;
&lt;p&gt;Then, backpropagation works its way back through the network, layer by layer, using the chain rule to find the gradients for each layer&apos;s weights and biases. It&apos;s like the network is reflecting on how its settings influenced the outcome, and then making informed adjustments.&lt;/p&gt;
&lt;p&gt;The key to understanding backpropagation is recognizing that it&apos;s not a mysterious, magical process, but rather a systematic application of the chain rule of calculus. By breaking down the network into its individual layers and components, backpropagation allows us to efficiently compute the gradients required for effective optimization.&lt;/p&gt;
&lt;h3&gt;Choosing the Right Loss Function&lt;/h3&gt;
&lt;p&gt;The loss function is the heart of the matter. It measures how well the neural network is doing, showing the difference between predictions and reality. Getting this right is crucial for stable and effective training.&lt;/p&gt;
&lt;p&gt;The mean squared error (MSE) loss function is a popular choice. It calculates the average squared difference between predicted and actual outputs, giving us a measure of accuracy. There are other loss functions too, each suited to different types of problems. Choosing the right one is like giving your network the right tools for the job!&lt;/p&gt;
&lt;h3&gt;What are these Math symbolds?&lt;/h3&gt;
&lt;h4&gt;∂ (Partial Derivative)&lt;/h4&gt;
&lt;p&gt;In the context of machine learning, specifically within neural networks, differential calculus plays a crucial role. Specifically, the computation of gradients of the loss function with respect to the network&apos;s weights and biases is fundamental. By using partial derivatives, we can compute the gradients needed for updating the weights and biases during optimization. These gradients guide the network to adjust its parameters and improve its predictions. It&apos;s like using calculus to navigate towards better performance!&lt;/p&gt;
&lt;h4&gt;Z (Pre-activation Outputs):&lt;/h4&gt;
&lt;p&gt;This represents the output of each neuron before applying an activation function, essentially the linear combination of input data with the neuron&apos;s current weights and biases.&lt;/p&gt;
&lt;h4&gt;A (Activations):&lt;/h4&gt;
&lt;p&gt;The activated output of neurons, obtained by applying an activation function to &lt;code&gt;Z&lt;/code&gt;. These activations are the &quot;decisions&quot; made by each neuron, significantly impacting the network&apos;s overall output.&lt;/p&gt;
&lt;h3&gt;The Setup: A Multi-Layer Perceptron&lt;/h3&gt;
&lt;p&gt;Now that we&apos;ve explored the individual components of backpropagation and gradient descent, it&apos;s time to step back and appreciate the symbiotic relationship between these two powerful concepts. Together, they form the backbone of neural network training, enabling these models to learn and improve over time.&lt;/p&gt;
&lt;p&gt;Imagine we have a 3-layer neural network, or a multi-layer perceptron, that takes an input vector X and produces predictions. Our goal is to adjust the network&apos;s weights and biases through backpropagation when these predictions don&apos;t match the ground truth labels. So, let&apos;s get started!&lt;/p&gt;
&lt;p&gt;Step 1: Forward Pass&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We start with a MLP network ready to process an input vector X. For simplicity, let&apos;s say the network makes the following predictions: &lt;code&gt;Y^pred = [0.5, 0.5, 0]&lt;/code&gt;. We compare these predictions against the actual labels, or the ground truth, which are &lt;code&gt;Y^target = [0, 1, 0]&lt;/code&gt;. Straight away, we notice discrepancies between what&apos;s predicted and what&apos;s expected.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 2: Backpropagation Begins&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Now, we prepare the network for the crucial task of learning from its mistakes. This preparation involves setting up variables to hold the calculations critical for adjusting the network&apos;s weights and biases.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 3: Layer 3 - Softmax and Cross-Entropy Loss&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At this layer, we directly compute the gradient of the loss with respect to &lt;code&gt;z3&lt;/code&gt; using the equation: &lt;code&gt;Y^pred - Y^target = [0.5, -0.5, 0]&lt;/code&gt;. This calculation is streamlined thanks to the combination of Softmax and Cross-Entropy Loss, showcasing their compatibility in simplifying backpropagation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 4: Layer 3 - Weights and Biases&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Next, we determine how much each weight and bias at this layer contributed to the overall error. This is done by calculating &lt;code&gt;∂L / ∂W3&lt;/code&gt; and &lt;code&gt;∂L / ∂b3&lt;/code&gt;, involving a multiplication of &lt;code&gt;∂L / ∂z3&lt;/code&gt; and the activations from the previous layer &lt;code&gt;[a2 | 1]&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 5: Layer 2 - Activations&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To understand the impact of Layer 2&apos;s activations on the final output, we compute &lt;code&gt;∂L / ∂a2&lt;/code&gt; by multiplying the gradient from Layer 3 &lt;code&gt;∂L / ∂z3&lt;/code&gt; by the weights of Layer 3 &lt;code&gt;W3&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 6: Layer 2 - RELU&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The RELU function introduces non-linearity, and here we calculate &lt;code&gt;∂L / ∂z2&lt;/code&gt; by applying RELU&apos;s rule: multiply &lt;code&gt;∂L / ∂a2&lt;/code&gt; by 1 for positive values and 0 for negatives.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 7: Layer 2 - Weights and Biases&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Similar to Layer 3, we find &lt;code&gt;∂L / ∂W2&lt;/code&gt; and &lt;code&gt;∂L / ∂b2&lt;/code&gt; by multiplying the gradient of z2 with the activations from Layer 1 &lt;code&gt;[a1 | 1]&lt;/code&gt;, further dissecting the error&apos;s source.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 8: Layer 1 - Activations&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The influence of Layer 1&apos;s activations on subsequent layers is calculated by multiplying &lt;code&gt;∂L / ∂z2&lt;/code&gt; by Layer 2&apos;s weights &lt;code&gt;W2&lt;/code&gt;, resulting in &lt;code&gt;∂L / ∂a1&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 9: Layer 1 - RELU&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Applying RELU again, we determine &lt;code&gt;∂L / ∂z1&lt;/code&gt; by multiplying &lt;code&gt;∂L / ∂a1&lt;/code&gt; with 1 for positive values and 0 for negatives, following RELU&apos;s activation principles.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 10: Layer 1 - Weights and Biases&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finally, we calculate &lt;code&gt;∂L / ∂W1&lt;/code&gt; and &lt;code&gt;∂L / ∂b1&lt;/code&gt; by multiplying the gradient of &lt;code&gt;z1&lt;/code&gt; by the original input vector &lt;code&gt;X&lt;/code&gt;, pinpointing how each input feature influences the prediction error.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Step 11: Gradient Descent&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;With all the gradients calculated, we can now update the weights and biases using gradient descent (typically with a learning rate applied). This adjusts the network&apos;s parameters, guiding it towards more accurate predictions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The synergy between backpropagation and gradient descent is what allows neural networks to learn and adapt. Backpropagation provides the crucial information needed to guide the optimization process, while gradient descent uses that information to efficiently update the network&apos;s parameters. It&apos;s a beautifully integrated system that enables neural networks to tackle increasingly complex problems with remarkable success.&lt;/p&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;The inspiration for this deep dive came from a series of hands-on exercises shared on LinkedIn by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt;. He designed it to break down the complexities of deep learning into manageable, understandable parts, with a particular focus on a seven-layer MLP. By highlighting the power of interactive learning in a neural network, it starts to show how you can see beyond the &apos;black box&apos; and grasp the nuanced mechanisms at play.&lt;/p&gt;
&lt;h3&gt;Conclusion: Embracing the Complexity, Mastering the Fundamentals&lt;/h3&gt;
&lt;p&gt;As we&apos;ve explored the intricacies of backpropagation and gradient descent, it&apos;s clear that the learning process of neural networks is a complex and multi-faceted endeavor. From the mathematical nuances of the chain rule to the intricate dance between forward and backward propagation, there is a wealth of depth and sophistication underlying these concepts.&lt;/p&gt;
&lt;p&gt;However, the true power of backpropagation and gradient descent lies in their elegant simplicity. At their core, these algorithms are built on the fundamental principles of optimization and calculus, using the gradients of a loss function to guide the network towards its most effective configuration. By understanding these core ideas, we can unlock a deeper appreciation for the inner workings of neural networks and harness their transformative potential.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-unpacking-multi-layer-perceptron&quot;&gt;What is a Multi-Layer Perceptron (MLP)?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://www.linkedin.com/posts/jeremyclondon_aibyhand-backpropagation-gradientdescent-activity-7184565713854984192-hZfK&quot;&gt;Coding by Hand: Backpropagation and Gradient Descent&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>What is a Multi-Layer Perceptron (MLP)?</title><link>https://jeremylondon.com/blog/deep-learning-basics-unpacking-multi-layer-perceptron/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-unpacking-multi-layer-perceptron/</guid><description>Unlock the fundamentals of Multi-Layer Perceptrons (MLPs) with a hands-on approach, exploring a seven-layer network example and exploring forward propagation.</description><pubDate>Thu, 04 Apr 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;Diving deeper into the next part of the Deep Learning Foundations Series, I explored a way to deepen my understanding of the inner workings of Multi-Layer Perceptrons (MLPs), building on the knowledge of neural network architectures and constructing a seven layer network! Lets go through each of the layers of this complex mechanism, and explore the interactive example to demonstrating the MLP&apos;s intricate design and functionality.&lt;/p&gt;
&lt;h2&gt;What is a Multi-Layer Perceptron?&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Understanding MLP Structure:&lt;/strong&gt; At its core, an MLP consists of multiple layers of nodes, each layer fully connected to the next. This structure allows for the modeling of complex, non-linear relationships between inputs and outputs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simplifying Assumptions for Clarity:&lt;/strong&gt; To ease this journey, I adopt two simplifications: zero biases across all nodes and direct application of the ReLU activation function, excluding the output layer. These assumptions helps me focus on the network&apos;s depth and its computational process without distrations from additional complexities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Layered Computations:&lt;/strong&gt; The example network, with seven layers, serves as a playground for computational practice. Now I can explore how inputs transition through the network, transforming via weights and activations, to produce outputs across each layer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Walking Through the Code:&lt;/h3&gt;
&lt;p&gt;To translate the the theoretical exploration into practical understanding, I utilize an interactive Python script to model a seven-layer MLP in &lt;code&gt;numpy&lt;/code&gt; and break down each weight group and layer into seperate calculations.&lt;/p&gt;
&lt;h4&gt;Initial Setup:&lt;/h4&gt;
&lt;p&gt;Lets start by defining the network&apos;s architecture, laying out the nodes in each layer, their connections, and the initial inputs. This foundation is crucial for understanding the subsequent computational steps.&lt;/p&gt;
&lt;h4&gt;Forward Pass:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Layer-by-Layer Transformation:&lt;/strong&gt; Examine how inputs are processed through each layer, with specific attention to the application of weights and the ReLU activation function. This step-by-step approach demystifies the network&apos;s operation, showcasing the transformation of inputs into outputs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Computational Insights:&lt;/strong&gt; Special focus is given to the handling of negative values by ReLU and the propagation of data through the network, culminating in the calculation of the output layer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;p&gt;Utilizing this interactive environment, you can now tweak inputs, weights, and see real-time changes in the network&apos;s output. This hands-on component emphasizes learning through doing, and help solidify the concepts of a MLP network.&lt;/p&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;The inspiration for this deep dive came from a series of hands-on exercises shared on LinkedIn shared by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt;. He designed it to break down the complexities of deep learning into manageable, understandable parts. In particular focusing on a seven-layer MLP, highlight the power of interactive learning in a nueral network. By engaging directly with the components of a neural network, it starts to show how you can see beyond the &apos;black box&apos; and grasp the nuanced mechanisms at play.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;The journey through Multi-Layer Perceptrons (MLPs) in the Deep Learning Foundations Series has been an enlightening exploration, bridging the gap between abstract neural network concepts and tangible, impactful applications in our world. MLPs, with their intricate layering and computational depth, play a pivotal role in powering technologies that touch nearly every aspect of our lives—from enhancing the way we communicate through natural language processing to driving innovations in autonomous vehicles.&lt;/p&gt;
&lt;p&gt;A key to unlocking the potential of MLPs lies in understanding forward propagation, the fundamental process that underpins how these networks learn and make predictions. Forward propagation is the heartbeat of a nueral network, which enables it to pass information through the network&apos;s layers, transforming input data into actionable insights. This sequential journey from input to output, is what enables MLPs to perform tasks with astonishing accuracy and efficiency.&lt;/p&gt;
&lt;p&gt;The applications of MLPs, empowered by forward propagation, are vast! In healthcare, they underpin systems that can predict patient outcomes, personalize treatments, and even identify diseases from medical imagery with greater accuracy than ever before. In the realm of finance, MLPs contribute to fraud detection algorithms that protect consumers, and in environmental science, they model complex climate patterns, helping researchers predict changes and mitigate risks.&lt;/p&gt;
&lt;p&gt;Understanding forward propagation not only helps us understand how MLPs function but also reveals the intricate dance of mathematics and data that fuels modern AI innovations. It&apos;s this foundational process that allows us to translate theoretical knowledge into applications that can forecast weather patterns, translate languages in real-time, and even explore the potential for personalized education platforms that adapt to individual learning styles.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-batch-processing-three-inputs&quot;&gt;Batch Processing Three Inputs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-deciphering-backpropagation&quot;&gt;Backpropagation and Gradient Descent&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://www.linkedin.com/posts/jeremyclondon_deeplearning-neuralnetworks-mlp-activity-7181794336861270016-nve0&quot;&gt;Coding by Hand: What are Multi-Layer Perceptrons?&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>Batch Processing Three Inputs</title><link>https://jeremylondon.com/blog/deep-learning-basics-batch-processing-three-inputs/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-batch-processing-three-inputs/</guid><description>Learn how neural networks handle batches of inputs, using three different input vectors to demonstrate the application of weights across a batch for efficient computation.</description><pubDate>Thu, 28 Mar 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;Stepping into the next part of my Deep Learning Foundations Series, the spotlight turns to batch processing. This technique transforms neural network efficiency by processing multiple inputs together, sharpening the system&apos;s ability to generalize from training data. With three distinct input vectors guiding us, let&apos;s explore the underlying mechanisms of weight application in batch processing, illuminating neural computation&apos;s path to efficiency.&lt;/p&gt;
&lt;h2&gt;Exploring Batch Processing&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simultaneous Input Processing:&lt;/strong&gt; This method allows for the simultaneous handling of multiple inputs, improving computational speed. It enables more effective management of large data sets, foundational in current AI training techniques.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Dynamics of Dot Product Calculations:&lt;/strong&gt; The efficiency of neural networks benefits significantly from the dot product operation, where weight matrices interact with input vector batches. This operation is crucial for parallel input computation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Uniform Weight Application Across Batches:&lt;/strong&gt; One of the fascinating aspects of batch processing is how a single set of weights is applied consistently across all inputs in a batch. This uniformity ensures that the network learns cohesively from different data points, showcasing the elegance of neural computation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Walking Through the Code:&lt;/h3&gt;
&lt;p&gt;This section aims to connect theoretical understanding with tangible application through a Python script example in a two-layer neural network.&lt;/p&gt;
&lt;h4&gt;Setting the Stage with Initial Parameters:&lt;/h4&gt;
&lt;p&gt;Our journey begins with the definition of the network&apos;s architecture. We&apos;re working with a two-layer neural network, characterized by its weight matrices W1 and W2, and bias vectors b1 and b2. The weights and biases are meticulously chosen to represent the connections and thresholds at each layer of the network, setting the foundation for our computation.&lt;/p&gt;
&lt;h4&gt;Weights and Biases:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;W1&lt;/code&gt; and &lt;code&gt;b1&lt;/code&gt; govern the transformation from the input layer to the hidden layer, outlining how input signals are weighted and adjusted before activation.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;W2&lt;/code&gt; and &lt;code&gt;b2&lt;/code&gt; take charge from the hidden layer to the output layer, determining the final computation leading to the network&apos;s predictions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Processing the Input Batch:&lt;/h4&gt;
&lt;p&gt;An essential feature of this example is the use of a batch of inputs, &lt;code&gt;x_batch&lt;/code&gt;, consisting of three column vectors made from stacking &lt;code&gt;x1&lt;/code&gt;, &lt;code&gt;x2&lt;/code&gt;, and &lt;code&gt;x3&lt;/code&gt;. This batch processing approach underscores the network&apos;s capacity to handle multiple inputs in parallel, optimizing both time and computational resources.&lt;/p&gt;
&lt;h4&gt;Hidden Layer Dynamics:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pre-Activation Computation&lt;/strong&gt;: The first significant step involves calculating the dot product of &lt;code&gt;W1&lt;/code&gt; with &lt;code&gt;x_batch&lt;/code&gt;, followed by adding the bias &lt;code&gt;b1&lt;/code&gt;. This results in &lt;code&gt;h_z&lt;/code&gt;, the pre-activation output of the hidden layer, representing the raw computations awaiting non-linear transformation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ReLU Activation&lt;/strong&gt;: We then apply the ReLU (Rectified Linear Unit) function to &lt;code&gt;h_z&lt;/code&gt;, producing &lt;code&gt;h&lt;/code&gt;, the activated output of the hidden layer. ReLU&apos;s role is pivotal, introducing non-linearity into the system by setting all negative values to zero, allowing the network to capture complex patterns beyond linear separability.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Output Layer Revelation:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output Calculation Before Activation&lt;/strong&gt;: Leveraging the activated hidden layer&apos;s output &lt;code&gt;h&lt;/code&gt;, we perform another round of dot product and bias addition with &lt;code&gt;W2&lt;/code&gt; and &lt;code&gt;b2&lt;/code&gt;, yielding &lt;code&gt;y_z&lt;/code&gt;. This represents the output layer&apos;s computation before the final activation step.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Final Activation with ReLU&lt;/strong&gt;: Applying ReLU once more to &lt;code&gt;y_z&lt;/code&gt; gives us &lt;code&gt;y&lt;/code&gt;, the final output of the network. This activated output is crucial for the network&apos;s decision-making process, influencing predictions and actions based on the learned patterns.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The script concludes with a display of both the hidden and output layers&apos; computations before and after ReLU activation. This visualization not only solidifies our understanding of the network&apos;s internal mechanics but also showcases the transformative power of batch processing and activation functions in shaping the neural computation landscape.&lt;/p&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;The spark for this exploration came from &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt; and his educational creations for his courses at the University of Colorado Boulder. His commitment to hands-on learning ignited my interest. Faced with a lack of practical deep learning exercises, he crafted a comprehensive set, ranging from foundational to advanced topics. His enthusiasm for hands-on learning has greatly influenced my journey.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Batch processing stands out as a key factor in the streamlined functioning of neural networks, facilitating swift, coherent learning from extensive datasets. This session&apos;s hands-on example has closed the gap between theoretical concepts and their application, showcasing the streamlined elegance of neural computation. Exciting insights await as we delve deeper into the expansive realm of neural networks and deep learning.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-exploring-four-neurons&quot;&gt;Unraveling Four-Neuron Networks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-unpacking-multi-layer-perceptron&quot;&gt;What is a Multi-Layer Perceptron (MLP)?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://lnkd.in/eMg73dPM&quot;&gt;Coding by Hand: Batch Processing in Neural Networks&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>Understanding Hidden Layers</title><link>https://jeremylondon.com/blog/deep-learning-basics-understanding-hidden-layer/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-understanding-hidden-layer/</guid><description>Dive deeper into neural network architecture by adding and understanding the computations involved in a hidden layer, laying the groundwork for more complex networks.</description><pubDate>Thu, 21 Mar 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;In the fourth chapter of my Deep Learning Foundations series, I&apos;m thrilled to introduce the concept of hidden layers. These layers are the backbone of a neural network&apos;s ability to learn complex patterns. By weaving a hidden layer into our network, I&apos;ll illuminate the computations that power these sophisticated architectures, showcasing how they enhance the network&apos;s predictive prowess. Lets dive into the architectural nuances that make neural networks such potent learning machines. Building on the foundational knowledge from previous posts, I aim to enrich your understanding of neural network design and functionality.&lt;/p&gt;
&lt;h2&gt;Deep Dive into Hidden Layers&lt;/h2&gt;
&lt;p&gt;The exploration of hidden layers marks a significant chapter in understanding of neural networks. Unlike the visible input and output layers, hidden layers work behind the scenes to transform data in complex ways, enabling networks to capture and model intricate patterns. Let’s unpack the concept and computational dynamics of hidden layers, and how they empower neural networks to solve advanced problems.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Unveiling Hidden Layers:&lt;/strong&gt; At their core, hidden layers are what differentiate a superficial model from one capable of deep learning. These layers allow the network to learn features at various levels of abstraction, making them indispensable for complex problem-solving. By introducing hidden layers, we significantly boost the network’s capability to interpret data beyond what is immediately observable, facilitating a gradual, layer-by-layer transformation towards the desired output.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Navigating Through Computations:&lt;/strong&gt; The journey from input through hidden layers to output involves a series of calculated steps. Each neuron in a hidden layer applies a weighted sum of its inputs, adds a bias, and then passes this value through an activation function like ReLU. This process not only introduces non-linearity but also allows the network to learn and adapt from data in a multi-dimensional space. Our focus will be on understanding how data is transformed as it propagates through these layers, and how activation functions play a pivotal role in shaping the network&apos;s learning behavior.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exploring the Weights and Nodes Dynamics:&lt;/strong&gt; The relationship between weights and nodes is fundamental to how information is processed and learned within the network. Weights determine the strength of the connection between nodes in different layers, influencing how much of the signal is passed through. Adjusting these weights is how neural networks learn from data over time. In this section, we’ll delve into the mechanics of weight adjustment and its impact on the network&apos;s accuracy and learning efficiency.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For those eager to see these concepts in action, check out the interactive code example which offers a hands-on experience with the mechanics of embedding a hidden layer within a neural network. Through this practical demonstration, you&apos;ll gain insight into the nuances of network operation and the transformative power of hidden layers.&lt;/p&gt;
&lt;h3&gt;Walking Through the Code&lt;/h3&gt;
&lt;p&gt;In this segment, I&apos;m excited to dissect a Python script that simulates a neural network with a hidden layer, emphasizing the function and impact of ReLU activation. This walkthrough is designed to shed light on the critical elements that allow a neural network to process and learn from data effectively.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initiating with NumPy:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Our journey starts with importing &lt;code&gt;numpy&lt;/code&gt; as &lt;code&gt;np&lt;/code&gt;, a fundamental library for numerical computation in Python. This tool is crucial for managing array operations efficiently, a common task in deep learning algorithms.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Activating with ReLU:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I define the &lt;code&gt;relu(x)&lt;/code&gt; function to apply the ReLU (Rectified Linear Unit) activation, a simple but profound mechanism that introduces non-linearity by converting negative values to zero. This step is essential for enabling the network to capture complex patterns.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constructing the Two-Layer Network:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;At the core of this exploration, the &lt;code&gt;two_layer_network&lt;/code&gt; orchestrates the interaction between the input, hidden layer, and output. This function illustrates how data flows through the network, undergoing transformation and activation.
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First Layer Transformation:&lt;/strong&gt; The script begins by transforming the input vector &lt;code&gt;x&lt;/code&gt; using the first layer&apos;s weights &lt;code&gt;W1&lt;/code&gt; and biases &lt;code&gt;b1&lt;/code&gt;. The dot product of &lt;code&gt;W1&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt; plus &lt;code&gt;b1&lt;/code&gt; yields the pre-activation values for the hidden layer, which are then passed through the ReLU function to achieve activation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second Layer Transformation:&lt;/strong&gt; The activated hidden layer output &lt;code&gt;h&lt;/code&gt; is subsequently processed by the second layer&apos;s weights &lt;code&gt;W2&lt;/code&gt; and biases &lt;code&gt;b2&lt;/code&gt;. Similar to the first layer, lets calculate the dot product of &lt;code&gt;W2&lt;/code&gt; and &lt;code&gt;h&lt;/code&gt; plus &lt;code&gt;b2&lt;/code&gt;, followed by ReLU activation to obtain the final output &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Examining Network Parameters:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An integral part of understanding a neural network&apos;s complexity and capacity is analyzing its parameters. The script calculates the total number of parameters by considering the weights and biases across both layers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Executing and Interpreting Results:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;With the network fully defined, executing the &lt;code&gt;two_layer_network&lt;/code&gt; function simulates the processing of input through the hidden to the output layer. The outcomes, both before and after ReLU activation, are printed, offering insights into the network&apos;s operational dynamics.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Visualizing the Process:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;By meticulously detailing each computational step and visualizing the data flow, this walkthrough aims to clarify how hidden layers contribute to a neural network&apos;s ability to learn. It highlights the transformational journey of input data as it moves through the network, emerging as a learned output.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Theoretical Insights and Practical Application&lt;/h3&gt;
&lt;p&gt;This detailed code walkthrough bridges the gap between theoretical neural network concepts and their practical implementation. By dissecting the network layer by layer and focusing on the ReLU activation function, I hope you gained a deeper appreciation for the intricacies of neural computations. It&apos;s a step toward demystifying the complex operations that enable neural networks to perform tasks ranging from simple classifications to understanding the nuances of human language and beyond.&lt;/p&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;This journey was sparked by the insightful exercises created by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt; for his graduate courses at the University of Colorado Boulder. He&apos;s a big advocate for hands-on learning, and so am I. After realizing the scarcity of practical exercises in deep learning, he took it upon himself to develop a set that covers everything from basic concepts like the one discussed today to more advanced topics. His dedication to hands-on learning has been a huge inspiration to me.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;With this exploration of hidden layers complete, it&apos;s clear that these intermediate layers are more than just stepping stones between input and output—they&apos;re the very essence of what enables neural networks to tackle problems with unparalleled complexity and depth. The journey through understanding hidden layers, from their conceptual foundation to their practical application, reveals the incredible versatility and power of neural networks. Through the lens of ReLU activation and the detailed walkthrough of a two-layer network, we&apos;ve seen firsthand how these models evolve from simple constructs to intricate systems capable of learning and adapting with astonishing precision. Hidden layers stand as a testament to the progress and potential of neural network design, offering a glimpse into the future possibilities of AI. As you can continue to push the boundaries of what these models can achieve, the insights gained from understanding hidden layers will undoubtedly serve as a cornerstone for future innovations. In the next installment of my Deep Learning Foundation Series, I&apos;ll venture further into the architecture of neural networks, exploring advanced concepts that build upon the foundations laid by hidden layers. Stay tuned on this fascinating journey into the heart of neural computation, unlocking new levels of understanding and capability in the process.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-exploring-four-neurons&quot;&gt;Unraveling Four-Neuron Networks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-batch-processing-three-inputs&quot;&gt;Batch Processing Three Inputs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://lnkd.in/g2aCmeHS&quot;&gt;Coding by Hand: Understanding Hidden Layers&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>From Simple to Complex: Unraveling Four-Neuron Networks</title><link>https://jeremylondon.com/blog/deep-learning-basics-exploring-four-neurons/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-exploring-four-neurons/</guid><description>Elevate your neural network knowledge by transitioning from the simplicity of a single neuron to the intricate dynamics of a four-neuron layer, complete with ReLU activation insights.</description><pubDate>Thu, 14 Mar 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;Embarking on the third installment of my Deep Learning Foundations series, I find myself at the threshold of a more complex and captivating topic: &lt;strong&gt;the four-neuron network&lt;/strong&gt;. Having previously unraveled the basics of a single neuron&apos;s function, it&apos;s now time to venture deeper into the cooperative world of multiple neurons. This progression from single-neuron analysis to the exploration of four-nueron network signifies a pivotal advancement in the journey to decode the complexities of neural networks.&lt;/p&gt;
&lt;h2&gt;Diving Deeper: The Four-Neuron Network Unveiled&lt;/h2&gt;
&lt;p&gt;The spotlight now turns to a sophisticated subject matter: the architecture and interplay within a four-neuron layer. Building upon the foundational knowledge from our exploration of the single-neuron model, I&apos;m set to broaden our scope and delve into the synergy of multiple neurons within a network. This exploration will underscore the essential roles played by matrix operations and ReLU activation in orchestrating neural network behaviors.&lt;/p&gt;
&lt;p&gt;Far from merely adding complexity, this exploration into this network is a gateway to understanding the underlying collaborative mechanisms of neural networks. By dissecting the contribution of each neuron to the layer&apos;s collective output, I intend to demystify neural computations, shedding light on the intricate engineering that empowers neural networks to tackle tasks with astounding complexity. This is indispensable for those aiming to unlock the full capabilities of neural networks, offering us insights needed to devise more intricate and efficient models.&lt;/p&gt;
&lt;h3&gt;Walking Through the Code&lt;/h3&gt;
&lt;p&gt;In this section, I&apos;m excited to walk you through a Python script that brings to life a four-neuron network layer. This code will not only showcase how inputs are collectively processed but also emphasize the network&apos;s augmented computational prowess in the added layer of complexity it introduces.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Leveraging NumPy for Complex Operations:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I initiate our exploration by leveraging NumPy, an essential library for efficiently conducting matrix operations. These operations are the cornerstone of neural network computations, particularly crucial when navigating the interactions of a multi-neuron layer.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Understanding Matrix Multiplication:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The core of our four-neuron layer&apos;s computation lies in &lt;a href=&quot;/blog/deep-learning-basics-intro-to-matrix-multiplication&quot;&gt;matrix multiplication&lt;/a&gt;. I&apos;ll show you how multiplying the input vector by the weight matrix, followed by adding the bias vector, calculates the pre-activation outputs. This matrix encapsulates the weights and biases of each neuron in the layer, forming the basis for their collective output.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Integrating Non-Linearity with ReLU:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;After obtaining the linear outputs, we introduce non-linearity by applying the ReLU activation function to the entire output vector. This crucial step allows our network to interpret complex patterns and data relationships, significantly enhancing its predictive capabilities.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Visualizing the Interactions:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To demystify the process, I&apos;ll dissect these operations, aiming to clarify how the neurons within a layer influence one another and contribute to the network&apos;s functionality.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Running the Simulation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finally, I execute the model to observe the output of the four-neuron layer after applying ReLU activation. This practical demonstration cements my understanding of the theoretical principles underpinning neural network functionality.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;p&gt;This code meticulously calculates the output for each neuron in the four-neuron layer before and after ReLU activation. It first computes the dot product of weights and biases with the inputs to produce the non-activated Z matrix, and then applies ReLU to derive the final output matrix A. This helps showcase the interplay of weights, biases, and inputs through mathematical operations.&lt;/p&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;This journey was sparked by the insightful exercises created by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt; for his graduate courses at the University of Colorado Boulder. He&apos;s a big advocate for hands-on learning, and so am I. After realizing the scarcity of practical exercises in deep learning, he took it upon himself to develop a set that covers everything from basic concepts like the one discussed today to more advanced topics. His dedication to hands-on learning has been a huge inspiration to me.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Exploring a four-neuron network layer has broadened our understanding of neural networks, emphasizing the critical role of matrix operations and ReLU activation in modeling complex data relationships. As we progress, we&apos;ll delve deeper into network architectures, unraveling the mysteries of deep learning layer by layer. Plus, I&apos;ll include a link to a LinkedIn post where we can dive into discussions and share thoughts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-intro-to-single-neurons&quot;&gt;Understanding Single Neuron Networks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-understanding-hidden-layer&quot;&gt;Understanding Hidden Layers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://lnkd.in/gDHHQ6FB&quot;&gt;Coding by Hand: Four Neuron Networks in Python&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>Introduction to Single Neuron Networks and ReLU</title><link>https://jeremylondon.com/blog/deep-learning-basics-intro-to-single-neurons/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-intro-to-single-neurons/</guid><description>Embark on a deep dive into the workings of a single neuron and the ReLU function, foundational concepts in neural network design.</description><pubDate>Thu, 07 Mar 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;In the second part of my Deep Learning Foundations series, I&apos;m peeling back the layers on one of the most fundamental units of neural networks: the single neuron. This dive is all about breaking down how a neuron takes inputs, works its magic through weights and biases, and pops out an output that&apos;s shaped by something called the ReLU function.&lt;/p&gt;
&lt;h2&gt;Single Neuron: Breaking It Down&lt;/h2&gt;
&lt;p&gt;At its heart, a single neuron is a marvel of simplicity and power. It&apos;s where the rubber meets the road in neural networks. Let&apos;s talk about what happens inside this tiny powerhouse.&lt;/p&gt;
&lt;h3&gt;Walking Through the Code&lt;/h3&gt;
&lt;p&gt;I&apos;ve cooked up a Python script that mirrors the essential function of a single neuron, enhanced with the ReLU activation. Let&apos;s dive into a step-by-step walkthrough of the code that simulates a single neuron&apos;s functionality, focusing on the ReLU activation function. This practical example illuminates the foundational concepts previously discussed.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Kicking Off with NumPy:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I start by importing &lt;code&gt;numpy&lt;/code&gt; as &lt;code&gt;np&lt;/code&gt;, leveraging its robust numerical computation tools, crucial for handling arrays with ease. NumPy is indispensable for mathematical operations in Python, especially within the deep learning realm.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bringing the ReLU Function to Life:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;relu(x)&lt;/code&gt; function embodies the ReLU (Rectified Linear Unit) activation function. It&apos;s straightforward yet powerful: it returns &lt;code&gt;x&lt;/code&gt; if &lt;code&gt;x&lt;/code&gt; is positive, and zero otherwise. This function is key for introducing non-linearity, enabling neural networks to tackle complex problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simulating the Neuron:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The heart of our discussion, the &lt;code&gt;single_neuron_network&lt;/code&gt; function, simulates a neuron at work. It takes &lt;code&gt;weights&lt;/code&gt;, &lt;code&gt;bias&lt;/code&gt;, and &lt;code&gt;inputs&lt;/code&gt; as inputs.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Weights and Inputs:&lt;/strong&gt; Here, each input is multiplied by its corresponding weight. The weights are the knobs and dials of the neural network, adjusted during training to hone the network&apos;s accuracy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bias:&lt;/strong&gt; Adding the bias to the sum of weighted inputs provides an extra layer of flexibility, allowing the neuron to fine-tune its output.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output Calculation Before Activation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;This step involves calculating the neuron&apos;s output before any activation is applied, by summing the products of inputs with their respective weights and adding the bias. This represents the linear aspect of the neuron&apos;s operation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Applying ReLU Activation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The output from the linear calculation is then fed through the ReLU function. This is where non-linearity comes into play, empowering the network with the ability to learn and model intricate patterns.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Detailing the Calculation Steps:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For clarity and educational value, I construct a string outlining each step: multiplying inputs by weights, adding the bias, and the outcome of applying ReLU. This transparency is invaluable for understanding and debugging.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Revealing the Results:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The culmination of this process is printing out the calculation steps, displaying the output before and after the ReLU function&apos;s application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Executing the Simulation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;With &lt;code&gt;inputs&lt;/code&gt;, &lt;code&gt;weights&lt;/code&gt;, and &lt;code&gt;bias&lt;/code&gt; all set, I execute the &lt;code&gt;single_neuron_network&lt;/code&gt; function. This run simulates the neuron in action, applying the discussed steps to output the results of a single neuron after ReLU activation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This code walkthrough demystifies the basic operations underlying neural network functionality. Breaking down the neuron&apos;s process into digestible steps enhances the grasp of how neural networks process inputs to produce outputs, paving the way towards understanding more complex architectures.&lt;/p&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;This journey was sparked by the insightful exercises created by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt; for his graduate courses at the University of Colorado Boulder. He&apos;s a big advocate for hands-on learning, and so am I. After realizing the scarcity of practical exercises in deep learning, he took it upon himself to develop a set that covers everything from basic concepts like the one discussed today to more advanced topics. His dedication to hands-on learning has been a huge inspiration to me.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Understanding how a single neuron works lays the foundation for everything else in neural networks. Today, we&apos;ve covered the ReLU function&apos;s role in transforming a neuron&apos;s output. In my next post, I&apos;ll be taking this foundation and building on it, moving from single neurons to how they connect and interact in larger networks. Plus, I&apos;ve include a link to a LinkedIn post where we can dive into discussions and share thoughts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Last Post: &lt;a href=&quot;/blog/deep-learning-basics-intro-to-matrix-multiplication&quot;&gt;Intro to Matrix Multiplication Basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-exploring-four-neurons&quot;&gt;Unraveling Four-Neuron Networks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LinkedIn Post: &lt;a href=&quot;https://lnkd.in/gD2SvQsu&quot;&gt;Coding by Hand: Single Neuron Networks in Python&lt;/a&gt;&lt;/p&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item><item><title>Intro to Matrix Multiplication Basics</title><link>https://jeremylondon.com/blog/deep-learning-basics-intro-to-matrix-multiplication/</link><guid isPermaLink="true">https://jeremylondon.com/blog/deep-learning-basics-intro-to-matrix-multiplication/</guid><description>Dive into my journey of unraveling matrix multiplication, a foundational stone in neural network computations, and how it propels deep learning forward.</description><pubDate>Sat, 04 Mar 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&amp;lt;h2&amp;gt;
&amp;lt;a
href=&quot;#interactive-code-environment&quot;
class=&quot;m-0 bg-linear-to-r from-blue-200 to-blue-100 bg-size-[0px_10px] bg-bottom-left bg-no-repeat text-blue-100 no-underline transition-[background-size] duration-500 group-hover:bg-size-[100%_10px] hover:bg-size-[100%_3px] dark:from-orange-800 dark:to-orange-900 dark:text-orange-400&quot;&amp;gt;
&amp;lt;span&amp;gt;Scroll down for Interactive Code Environment 👇&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;/h2&amp;gt;&lt;/p&gt;
&lt;p&gt;Welcome to the first chapter of my Deep Learning Foundations series. Today, I&apos;m excited to share my insights into matrix multiplication, an essential piece in the puzzle of neural networks. For those stepping into the vast world of deep learning, understanding this key concept of linear algebra is a game-changer.&lt;/p&gt;
&lt;h2&gt;Matrix Multiplication:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Dimensions and Scaling:&lt;/strong&gt; Discover how matrix dimensions interact and the importance of scaling in my explorations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dot Product Basics:&lt;/strong&gt; Delve into my journey of understanding dot products and their role in merging matrix rows and columns, pivotal for crafting neural network structures.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Matrix multiplication is the powerhouse that drives the deep learning engine, facilitating the seamless execution of complex neural network tasks with remarkable efficiency.&lt;/p&gt;
&lt;p&gt;Despite its critical role, I&apos;ve often found myself and others hesitating when faced with matrix multiplication. This prompted me to develop a simple, yet effective approach to tackle matrix multiplications by hand.&lt;/p&gt;
&lt;p&gt;Let&apos;s consider multiplying matrices A and B to get matrix C &lt;code&gt;(A x B = C)&lt;/code&gt;. My method sheds light on several aspects:&lt;/p&gt;
&lt;p&gt;💡 &lt;strong&gt;Dimensions:&lt;/strong&gt; The size of C is a mix of A&apos;s rows and B&apos;s columns, offering a straightforward visualization of the outcome&apos;s dimensions.&lt;/p&gt;
&lt;p&gt;💡 &lt;strong&gt;Scalability:&lt;/strong&gt; Adjusting the size of A, B, or C showcases the flexible nature of matrices, ensuring dimensions stay compatible throughout operations.&lt;/p&gt;
&lt;p&gt;💡 &lt;strong&gt;Row vs. Column Vectors:&lt;/strong&gt; The computation behind each element in C involves a dot product between a row from A (in green) and a column from B (in yellow), clarifying the calculation process.&lt;/p&gt;
&lt;p&gt;💡 &lt;strong&gt;Stackability:&lt;/strong&gt; This approach&apos;s efficiency enables visualizing consecutive matrix multiplication operations, invaluable for understanding the workings of complex neural networks like multi-layer perceptrons. This clarity enhances the grasp of deep learning architecture fundamentals.&lt;/p&gt;
&lt;p&gt;Through demystifying matrix multiplication, I&apos;ve laid the foundation for a deeper dive into deep learning mechanics. Stick around for more discoveries in this Deep Learning Foundations series.&lt;/p&gt;
&lt;h3&gt;Walking Through the Code:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NumPy, My First Ally:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The adventure begins by bringing in NumPy, a library that supercharges Python with a high-performance array object and tools for array manipulation. It&apos;s my go-to for numerical computations, especially when dealing with matrices.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Crafting the Matrices:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;A&lt;/code&gt; emerges as a 2x2 matrix, arrayed within arrays, where each nested array is a row. Specifically, &lt;code&gt;A&lt;/code&gt; is composed of &lt;code&gt;[1, 1]&lt;/code&gt; and &lt;code&gt;[-1, 1]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;B&lt;/code&gt; takes form as a 2x3 matrix, similarly arrayed. It unfolds into two rows: &lt;code&gt;[1, 5, 2]&lt;/code&gt; and &lt;code&gt;[2, 4, 2]&lt;/code&gt;, each stretching across three columns.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Heart of Multiplication:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Employing &lt;code&gt;np.dot&lt;/code&gt;, I marry &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;. The offspring, matrix &lt;code&gt;C&lt;/code&gt;, embodies the multiplication efforts. In this dance, &lt;code&gt;A&lt;/code&gt;&apos;s columns and &lt;code&gt;B&lt;/code&gt;&apos;s rows must mirror each other in number, enabling their union. Here, &lt;code&gt;A&lt;/code&gt;&apos;s two columns perfectly complement &lt;code&gt;B&lt;/code&gt;&apos;s two rows.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C&lt;/code&gt; inherits dimensions from the outer realms of &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;. With &lt;code&gt;A&lt;/code&gt; as a 2x2 and &lt;code&gt;B&lt;/code&gt; as a 2x3, &lt;code&gt;C&lt;/code&gt; proudly stands as a 2x3 matrix.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Revealing the Magic:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The finale involves unveiling &lt;code&gt;C&lt;/code&gt;&apos;s essence, showcasing the transformative power of matrix multiplication on the initial matrices.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By dissecting this example, I aim to illuminate the path of matrix multiplication, highlighting its critical role in both linear algebra and the deeper realms of deep learning. With NumPy&apos;s elegant syntax and potent functionality, embarking on complex mathematical adventures becomes not just feasible, but exhilarating, paving the way for advancements in deep learning.&lt;/p&gt;
&lt;h3&gt;Interactive Code Environment&lt;/h3&gt;
&lt;h3&gt;Original Inspiration&lt;/h3&gt;
&lt;p&gt;The spark for this series was ignited by the innovative exercises developed by &lt;a href=&quot;http://tomyeh.info&quot;&gt;Dr. Tom Yeh&lt;/a&gt; at the University of Colorado Boulder. His commitment to hands-on education resonates deeply with me, especially in a field as dynamic and critical as deep learning. Facing a lack of practical learning resources, Dr. Yeh crafted a comprehensive suite of exercises, beginning with fundamental concepts like matrix multiplication and extending to the intricacies of advanced neural architectures. His efforts have not only enriched the learning experience for his students but also inspired me to delve deeper into the foundational elements of AI and share these discoveries with you.&lt;/p&gt;
&lt;h3&gt;Wrapping Up and Looking Ahead&lt;/h3&gt;
&lt;p&gt;Diving into matrix multiplication has been about more than just numbers and operations; it&apos;s a gateway into the intricate world of deep learning. By breaking down this fundamental process, we&apos;ve started building a solid base, one that&apos;s essential for anyone looking to navigate through the complexities of neural networks. The journey we embarked on today is just the beginning. In my upcoming posts, I&apos;ll expand on these basics, exploring how these core principles apply to more complex neural network structures. Keep an eye out for my next piece, where we&apos;ll transition from the theoretical groundwork to the practical application of these concepts in creating more sophisticated models. And, as always, I look forward to sharing insights, sparking discussions, and growing together in this fascinating exploration of AI. Check out my &lt;a href=&quot;https://www.linkedin.com/in/jeremyclondon/&quot;&gt;LinkedIn posts&lt;/a&gt; where we can continue the conversation and exchange ideas.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Next Post: &lt;a href=&quot;/blog/deep-learning-basics-intro-to-single-neurons&quot;&gt;Understanding Single Neuron Networks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><language>en-us</language><category>deep-learning-basics</category><author>Jeremy London</author></item></channel></rss>