<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rutuparna Kolte on Medium]]></title>
        <description><![CDATA[Stories by Rutuparna Kolte on Medium]]></description>
        <link>https://medium.com/@rutuparna.kolte15?source=rss-c28d1234abb6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Wok_COczgHVa-WPjo7ekzQ.jpeg</url>
            <title>Stories by Rutuparna Kolte on Medium</title>
            <link>https://medium.com/@rutuparna.kolte15?source=rss-c28d1234abb6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:14:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rutuparna.kolte15/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Activation Functions in Neural Networks: ReLU, Sigmoid, Tanh, and Softmax Explained]]></title>
            <link>https://medium.com/@rutuparna.kolte15/activation-functions-in-neural-networks-relu-sigmoid-tanh-and-softmax-explained-a8cb8797aa2a?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8cb8797aa2a</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 01 Nov 2026 18:37:21 GMT</pubDate>
            <atom:updated>2026-11-01T18:37:21.503Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/@rutuparna.kolte15/how-cnn-pooling-works-reducing-feature-maps-without-losing-key-features-2d5500aa9c1d?sharedUserId=rutuparna.kolte15">previous article</a>, we explored how pooling layers reduce the spatial dimensions of feature maps while preserving important information. Before that, we saw how convolution helps a CNN detect patterns such as edges, textures, and shapes in an image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RNeTTgWgq9yKVARWOIZHg.png" /></figure><p>But detecting features and reducing their size is not enough. A neural network must also learn how to combine these features to recognise more complex patterns. For example, detecting edges alone does not help much if the network cannot learn how those edges combine to form an eye, a face, or an entire object.</p><p>So, how does a neural network learn these complex relationships? One important part of the answer is <strong>activation functions</strong>.</p><p>Activation functions introduce non-linearity into neural networks, allowing them to learn patterns that simple linear operations cannot represent.</p><p>In this article, we’ll explore why activation functions are necessary and understand how popular functions such as <strong>ReLU, Sigmoid, Tanh and Softmax </strong>work.</p><h3><strong>Why Do We Need Activation Functions?</strong></h3><p>Imagine building a neural network with several layers. Each layer takes the output from the previous layer, performs calculations using weights and biases, and passes the result forward.</p><p>You might expect that adding more layers would automatically allow the network to learn more complex patterns. However, there is a catch.</p><p>If every layer performs only a linear transformation, stacking multiple layers still produces a single linear transformation.</p><p>Let’s understand why.</p><p>Suppose a layer performs this operation:</p><pre>y = 2x + 3</pre><p>Now, imagine the next layer applies another linear transformation:</p><pre>z = 4y + 1</pre><p>Substituting the first equation into the second:</p><pre>z = 4(2x+3)+1<br>  = 8x+13</pre><p>Although we used two layers, the final result is still a linear function of the input.</p><p>The same principle applies to deeper networks. Without non-linear operations, combining multiple linear layers does not give the network the ability to learn genuinely non-linear relationships.</p><h3>How Do Activation Functions Help?</h3><p>Activation functions solve this limitation by introducing non-linearity into the network.</p><p>Instead of passing a neuron’s calculated output directly to the next layer, an activation function transforms that output before it continues through the network.</p><p>A simplified neural network layer looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ySlwjRqydf_Ldndj6AMdvg.webp" /><figcaption><a href="https://www.geeksforgeeks.org/machine-learning/activation-functions-neural-networks/">Source</a></figcaption></figure><p>Here, <strong>w </strong>represents the weight, <strong>b </strong>represents the bias, and <strong>f </strong>represents the activation function.</p><p>By introducing non-linearity, the network can learn more complex relationships between inputs and outputs. In a CNN, this helps the network build from simple patterns, such as edges, toward more complex features, such as textures, shapes, and object parts.</p><p>Different activation functions transform values in different ways. Some suppress negative values, some map outputs to a fixed range, and others convert class scores into probabilities. In this article, we’ll explore four important activation functions: <strong>ReLU</strong>, <strong>Sigmoid</strong>, <strong>Tanh</strong>, and <strong>Softmax</strong>, and understand when each one is useful.</p><h3>ReLU (Rectified Linear Unit)</h3><p>ReLU is one of the most widely used activation functions in deep learning, particularly in convolutional neural networks. ReLU is popular because it is simple, computationally efficient, and helps neural networks learn complex patterns.</p><h4>How Does ReLU Work?</h4><p>ReLU follows a simple rule:</p><ul><li>If the input is positive, it returns the input unchanged.</li><li>If the input is negative or zero, it returns zero.</li></ul><p>Mathematically, it is defined as:</p><pre>f(x) = max(0,x)</pre><p>For example, if a neuron produces an output of -2, ReLU transforms it into 0. If the neuron produces 3, ReLU leaves it unchanged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*OUiy1kg7pR9jgh25oCczFA.png" /><figcaption><a href="https://www.geeksforgeeks.org/deep-learning/relu-activation-function-in-deep-learning/">Source</a></figcaption></figure><h4>Why Is ReLU Useful in CNNs?</h4><p>Recall that convolutional layers produce feature maps containing activations that indicate how strongly particular patterns are detected. ReLU is commonly applied after convolution to introduce non-linearity. Negative responses are set to zero, while positive responses are retained.</p><p>ReLU also has a practical advantage: its calculation is extremely cheap. Unlike activation functions that require exponential calculations, ReLU only needs to compare its input with zero.</p><h4>What Is the Dying ReLU Problem?</h4><p>Despite its advantages, ReLU has a limitation. When a neuron’s input remains negative, ReLU outputs zero. Its gradient is also zero for negative inputs, so that neuron may stop updating through that path during training. If this happens persistently, the neuron may effectively stop learning. This is known as the dying ReLU problem.</p><p>Variants such as Leaky ReLU address this issue by allowing a small, non-zero output for negative inputs.</p><h3>Sigmoid Activation Function</h3><p>Unlike ReLU, which sets negative inputs to zero and leaves positive inputs unchanged, the Sigmoid function transforms any real-valued input into a value between 0 and 1.</p><p>This makes Sigmoid particularly useful when a model needs to represent a value as a probability, such as predicting whether an email is spam or not.</p><h4>How Does Sigmoid Work?</h4><p>The Sigmoid function is defined as:</p><pre>σ(x) = 1 / (1 + e⁻ˣ)</pre><p>Here, <strong>x </strong>is the input, and <strong>e </strong>is the mathematical constant approximately equal to 2.718.</p><p>Sigmoid compresses a wide range of input values into a narrow range between 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*JB0d_5GeAbEMWUETvK5XaQ.png" /><figcaption><a href="https://www.geeksforgeeks.org/machine-learning/derivative-of-the-sigmoid-function/">Source</a></figcaption></figure><h4>Where Is Sigmoid Used?</h4><p>Consider a binary image classification model that predicts whether an image contains a cat.</p><p>The model produces a score, which is passed through Sigmoid to obtain an output between zero and one. Suppose the output is 0.92. The model can interpret this as a predicted probability of 92% for the positive class, assuming the model is appropriately trained and calibrated.</p><p>A threshold, often 0.5, can then be used to make a decision:</p><ul><li>Output greater than or equal to 0.5: predict the positive class.</li><li>Output below 0.5: predict the negative class.</li></ul><p>The threshold can be adjusted depending on the task.</p><h4>Why Isn’t Sigmoid Used Everywhere?</h4><p>Although Sigmoid is useful for binary classification outputs, it has limitations when used throughout deep networks.</p><ol><li><strong>Vanishing gradients: </strong>For very large positive or negative inputs, the Sigmoid curve becomes almost flat. Its gradient approaches zero, so during backpropagation, the corresponding weight updates can become extremely small. This can slow learning in deeper networks.</li><li><strong>Outputs are not zero-centred: </strong>Sigmoid outputs are always positive, between zero and one. This can make optimisation less convenient in some network settings. Because of these limitations, ReLU and its variants are generally preferred for hidden layers in many modern CNNs.</li></ol><h3>Tanh (Hyperbolic Tangent)</h3><p>We’ve seen how ReLU keeps positive values and how Sigmoid maps inputs to a range between 0 and 1. Another commonly discussed activation function is Tanh, short for hyperbolic tangent.</p><p>Like Sigmoid, Tanh produces an S-shaped curve. However, its output ranges from -1 to 1, allowing it to represent both negative and positive values.</p><h4>How Does Tanh Work?</h4><p>The Tanh function is defined as:</p><pre>tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ)</pre><p>Its behaviour is straightforward:</p><ul><li>Large negative inputs produce outputs close to -1.</li><li>An input of zero produces an output of 0.</li><li>Large positive inputs produce outputs close to 1.</li></ul><p>As the input moves further from zero, the output approaches -1 or 1. It gets compressed into this range rather than increasing indefinitely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*mivBtPuD0ForqDIl7FKCUQ.png" /><figcaption><a href="https://www.geeksforgeeks.org/deep-learning/tanh-activation-in-neural-network/">Source</a></figcaption></figure><h4>What Are the Limitations of Tanh?</h4><p>Tanh has a limitation similar to Sigmoid: vanishing gradients.</p><p>When the input becomes very large or very negative, the curve flattens. Its gradient approaches zero, which can make it difficult for earlier layers in a deep network to learn effectively.</p><p>For this reason, ReLU and its variants are generally more common in the hidden layers of modern CNNs, although Tanh remains useful in some architectures and applications.</p><h3>Softmax</h3><p>So far, we’ve explored ReLU, Sigmoid, and Tanh, which transform individual values. But what happens when a neural network needs to classify an image into one of several categories?</p><p>For example, imagine a CNN that classifies images into three categories: cat, dog, and bird.</p><p>The network might produce three raw scores:</p><ul><li>Cat: 2.5</li><li>Dog: 1.2</li><li>Bird: 0.3</li></ul><p>These scores indicate how strongly the model favours each class, but they are not probabilities. They can be negative, positive, or larger than 1, and they do not necessarily add up to 1.</p><p>This is where Softmax comes in.</p><h4>How Does Softmax Work?</h4><p>Softmax converts a set of raw scores, often called logits, into values between 0 and 1 that sum to 1. These values can be interpreted as a probability distribution across the classes.</p><p>For a class <strong>i</strong>, the Softmax function is:</p><pre>Softmax(zᵢ) = eᶻⁱ / Σⱼ eᶻʲ</pre><p>Here:</p><ul><li><strong>zᵢ</strong> is the raw score for the class we are calculating the probability for.</li><li><strong>eᶻⁱ</strong> is the exponential of that score.</li><li>The denominator is the sum of the exponentials of the scores for all classes.</li></ul><p>Let’s work through an example using our CNN that classifies images into three categories: cat, dog, and bird.</p><p>Suppose the model produces these raw scores:</p><pre>Class      | Score <br>-------------------------<br>Cat        | 2.5<br>Dog        | 1.2<br>Bird       | 0.3</pre><p>Step 1: Apply the exponential function to each score.</p><pre><br>Class  | Calculation | Exponential Value<br>-----------------------------------------------<br>Cat    | e^2.5       | 12.182<br>Dog    | e^1.2       | 3.320<br>Bird   | e^0.3       | 1.350</pre><p>Exponentiation makes every value positive and increases the relative weight of larger scores.</p><p>Step 2: Add all the exponential values.</p><p>The denominator is:</p><pre>12.182 + 3.320 + 1.350 = 16.852</pre><p>We use this same total to calculate the probability of each class.</p><p>Step 3: Divide each exponential value by the total.</p><p>For cat:</p><pre>P(cat) = 12.182 / 16.852 ≈ 0.723</pre><p>For dog:</p><pre>P(dog) = 3.320 / 16.852 ≈ 0.197</pre><p>For bird:</p><pre>P(bird) = 1.350 / 16.852 ≈ 0.080</pre><p>The resulting probabilities are approximately:</p><pre>Class      | Probability<br>-------------------------<br>Cat        | 72.3%<br>Dog        | 19.7%<br>Bird       | 8.0%<br>-------------------------<br>Total      | 100%</pre><p>Small differences in the final decimal places can occur due to rounding.</p><p>Step 4: Choose the predicted class.</p><p>The model selects the class with the highest probability. In this example, the cat class receives approximately 72.3%, so the model predicts cat.</p><p>The important point is that Softmax does not simply divide each raw score by their sum. It first applies the exponential function and then normalises the results. This ensures that the outputs form a probability distribution, with every value between 0 and 1 and all values adding up to 1.</p><h3>Conclusion</h3><p>Activation functions play an important role in neural networks by introducing non-linearity and helping models learn complex patterns.</p><p>Each function serves a different purpose, and choosing the right one depends on the architecture and the problem being solved.</p><p>With this, we have covered another important building block of CNNs. Understanding how convolution extracts features, pooling reduces spatial dimensions, and activation functions introduce non-linearity gives us a stronger foundation for understanding how neural networks learn from images.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8cb8797aa2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How CNN Pooling Works: Reducing Feature Maps Without Losing Key Features]]></title>
            <link>https://medium.com/@rutuparna.kolte15/how-cnn-pooling-works-reducing-feature-maps-without-losing-key-features-2d5500aa9c1d?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d5500aa9c1d</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[pooling-layer]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 19:57:01 GMT</pubDate>
            <atom:updated>2026-09-27T19:57:01.655Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*3VtFoKpQD2UbqhFnxtnYWw.png" /><figcaption><a href="https://guandi1995.github.io/Pooling-Layers/">Source</a></figcaption></figure><p>In the <a href="https://medium.com/@rutuparna.kolte15/convolution-explained-how-a-tiny-matrix-finds-patterns-in-an-image-0bd4637f45d2">previous article</a>, we saw how convolution takes an image and transforms it into a feature map. A CNN uses filters to detect patterns such as edges, textures, and shapes at different locations in the image.</p><p>But there is a problem. The feature map produced by convolution can still be quite large.</p><p>For example, imagine that a convolution layer produces a feature map like this:</p><pre>[ 0.1  0.2  0.8  0.1 ]<br>[ 0.0  0.7  0.9  0.2 ]<br>[ 0.1  0.3  0.2  0.1 ]<br>[ 0.6  0.8  0.1  0.0 ]</pre><p>Every value contains information about the features detected in a particular region of the image. But do we really need to keep every single value?</p><p>In many cases, we mainly care about whether a particular feature was detected strongly within a small region.</p><p>For example, if a filter is looking for an edge and produces these values:</p><pre>[ 0.1  0.2 ]<br>[ 0.8  0.7 ]</pre><p>The exact location of the strongest response may not always be important at this stage. What matters is that a strong response exists somewhere in this region. This is where <strong>pooling </strong>comes in.</p><p>Pooling reduces the spatial size of a feature map by summarising information from small local regions.</p><p>Instead of passing every value to the next layer, we can combine several values into a single value.</p><p>For example:</p><pre>Before Pooling<br><br>[ 0.1  0.2  0.8  0.1 ]<br>[ 0.0  0.7  0.9  0.2 ]<br>[ 0.1  0.3  0.2  0.1 ]<br>[ 0.6  0.8  0.1  0.0 ]<br><br>After Pooling<br><br>[ 0.9  0.9 ]<br>[ 0.8  0.2 ]</pre><p>The feature map has become smaller, while important information can still be retained. So pooling gives us a simple way to reduce the spatial dimensions of feature maps while summarising the information they contain. But how exactly does it decide which information to keep? Let’s look at what a pooling layer actually does.</p><h4>What Is a Pooling Layer?</h4><p>A pooling layer takes a feature map and looks at small regions of it at a time. Instead of performing a learned calculation like convolution, pooling applies a simple mathematical operation to the values inside each region. The most common example is a 2 × 2 pooling window. Suppose we have the following feature map:</p><pre>[ 1  3  2  4 ]<br>[ 5  6  1  2 ]<br>[ 7  2  8  3 ]<br>[ 4  1  5  6 ]</pre><p>We can place a 2 × 2 window over the top-left corner:</p><pre>[ 1   3 ]  2   4<br>[ 5   6 ]  1   2<br>  7   2    8   3<br>  4   1    5   6</pre><p>The pooling layer takes these four values inside this window and combines them into one value. How it combines them depends on the type of pooling being used.</p><p>The two most common types are:</p><ul><li><strong>Max Pooling:</strong> keeps the largest value.</li><li><strong>Average Pooling:</strong> calculates the average of the values.</li></ul><p>For example:</p><pre>              [ 1  3 ]<br>              [ 5  6 ]<br>                  ↓<br>        ┌──────────────────┐<br>        │                  │<br>   Max Pooling       Average Pooling<br>        │                  │<br>        ↓                  ↓<br>        6                3.75</pre><p>The four values have been reduced to one. The pooling window then moves to another region of the feature map and repeats the same operation. So, just like a convolution filter scans across an image, a pooling window scans across a feature map.</p><p>The important difference is that a pooling layer does not learn filters. It simply applies an operation such as maximum or average to each local region.</p><h4>Max Pooling</h4><p>Max pooling keeps the strongest activation within a small region of a feature map. For example, in an image classification model, a convolution layer may detect features such as edges, corners, textures, or parts of an object. If a feature is strongly detected within a region, max pooling preserves that strong response while discarding weaker responses from the same region. This allows the network to retain prominent features while reducing the spatial size of the feature map.</p><h4>Average Pooling</h4><p>Another common type of pooling is average pooling. Instead of keeping the strongest activation from a region, average pooling calculates the average response of that region. While max pooling focuses on the strongest detected feature, average pooling provides a more general summary of the features present in the area. It can be useful when the overall presence of a feature matters more than its strongest individual response, although max pooling is more commonly used in many traditional CNN architectures.</p><h4>Pooling Window and Stride</h4><p>Two important parameters determine how a pooling layer reduces a feature map: <strong>pooling window size</strong> and <strong>stride</strong>.</p><p>The pooling window determines the size of the region considered at each step. For example, a 2 × 2 window looks at four values at a time, while a 3 × 3 window looks at nine values.</p><p>The stride determines how far the window moves after processing each region.</p><p>Let’s see how they work together.</p><h4><strong>2 × 2 Pooling with Stride 2</strong></h4><p>Consider this 4 × 4 feature map:</p><pre>[ 1  3  2  4 ]<br>[ 5  6  1  2 ]<br>[ 7  2  8  3 ]<br>[ 4  1  5  6 ]</pre><p>Using a 2 × 2 window and a stride of 2, we divide the feature map into four non-overlapping regions:</p><pre>[ 1  3 ]  [ 2  4 ]<br>[ 5  6 ]  [ 1  2 ]<br><br>[ 7  2 ]  [ 8  3 ]<br>[ 4  1 ]  [ 5  6 ]</pre><p>For max pooling, we take the largest value from each region:</p><pre>[ 6  4 ]<br>[ 7  8 ]</pre><p>The original feature map was 4 × 4, and the resulting feature map is 2 × 2. The window moves two positions horizontally and vertically, so the regions do not overlap.</p><h4>2 × 2 Pooling with Stride 1</h4><p>Now keep the same 2 × 2 pooling window, but change the stride to 1.</p><p>The first region is:</p><pre>[ 1  3 ]<br>[ 5  6 ]</pre><p>The window then moves one position to the right, and the next region is:</p><pre>[ 3  2 ]<br>[ 6  1 ]</pre><p>It continues moving one position at a time:</p><pre>[ 1  3 ]    [ 3  2 ]    [ 2  4 ]<br>[ 5  6 ]    [ 6  1 ]    [ 1  2 ]<br><br><br>[ 5  6 ]    [ 6  1 ]    [ 1  2 ]<br>[ 7  2 ]    [ 2  8 ]    [ 8  3 ]<br><br><br>[ 7  2 ]    [ 2  8 ]    [ 8  3 ]<br>[ 4  1 ]    [ 1  5 ]    [ 5  6 ]</pre><p>Because the windows overlap, more regions are processed. For max pooling, the output becomes:</p><pre>[ 6  6  4 ]<br>[ 7  8  8 ]<br>[ 7  8  8 ]</pre><p>This gives us a 3 × 3 feature map from the original 4 × 4 feature map.</p><p>The important difference from stride 2 is that stride 1 creates overlapping pooling regions, because the window moves only one position at a time. This produces a larger output and preserves more spatial information.</p><h4>What Happens With a 3 × 3 Window?</h4><p>The pooling window can also be larger.</p><p>For example, using a 3 × 3 window with stride 1 on the same 4 × 4 feature map:</p><pre>[ 1  3  2 ]  4<br>[ 5  6  1 ]  2<br>[ 7  2  8 ]  3<br>  4  1  5    6</pre><p>The window then moves one position at a time and processes the other possible 3 × 3 regions. With stride 1, a 4 × 4 feature map produces a 2 × 2 output. So, both the window size and the stride affect how much the feature map is reduced.</p><p>In practice, 2 × 2 pooling with a stride of 2 is a common choice because it reduces the height and width of the feature map by roughly half while keeping the operation simple.</p><h4>What Information Does Pooling Remove?</h4><p>Pooling reduces the size of a feature map, but this reduction comes with a trade-off: some spatial information is lost.</p><p>With max pooling, the network keeps the strongest activation, but the other values are discarded. We no longer have the same level of detail about the exact features and their locations within that region.</p><p>This can be useful because the network does not always need every pixel-level detail. For image classification, for example, knowing that a particular feature is strongly present may be more important than knowing its exact position. However, for tasks where precise spatial information matters, such as object detection or image segmentation, excessive downsampling can remove useful information.</p><h4>Is Pooling Always Used?</h4><p>Pooling has been an important part of many CNN architectures, but it is not required in every CNN. Traditional CNNs often use pooling layers between convolutional layers to progressively reduce the spatial dimensions of feature maps. However, some modern architectures use strided convolutions instead, where the convolution itself reduces the spatial dimensions by using a stride greater than 1.</p><p>The choice depends on the architecture and the task. Pooling provides a simple way to downsample feature maps, but because downsampling also removes some spatial information, architectures may use other approaches when preserving spatial detail is important.</p><p>But there is still another important question.</p><p>We have seen how convolution extracts features and how pooling reduces their spatial size. But how does a CNN actually learn complex patterns from these operations?</p><p>The answer lies in <strong>activation functions</strong>.</p><p>In the next article, we’ll explore activation functions, understand why neural networks need them, and see how functions such as <strong>ReLU, Sigmoid, and Tanh</strong> help CNNs learn non-linear patterns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d5500aa9c1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convolution Explained: How a Tiny Matrix Finds Patterns in an Image]]></title>
            <link>https://medium.com/@rutuparna.kolte15/convolution-explained-how-a-tiny-matrix-finds-patterns-in-an-image-0bd4637f45d2?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bd4637f45d2</guid>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 17:28:46 GMT</pubDate>
            <atom:updated>2026-08-30T17:28:46.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*d_8jHoiHvrZm_RB9oNOD-Q.jpeg" /><figcaption><a href="http://www.kerrywong.com/2009/05/07/canny-edge-detection-auto-thresholding/">Source</a></figcaption></figure><p>In the <a href="https://medium.com/@rutuparna.kolte15/how-cnns-actually-work-from-pixels-to-predictions-d5e256cbcfd1">previous article</a>, we looked at the basic components of a Convolutional Neural Network and saw how convolution helps a CNN find useful patterns in an image.</p><p>But we only looked at convolution from a distance. We saw that CNNs use small filters that move across an image and produce feature maps.</p><p>What actually happens when a filter<strong> </strong>is placed over an image?</p><h4>Let’s Start With a Tiny Image.</h4><p>To understand convolution, we don’t need a complicated photograph. Let’s take a small 5 × 5 grayscale image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RaTaI9r5f2tcBodc9SwHA.png" /><figcaption>Representing an Image as Numbers</figcaption></figure><p>If we visualise these numbers as pixels, we can imagine a simple pattern running through the image.</p><p>But how can a CNN find that pattern? This is where a filter comes in.</p><h4>Now, what is a filter?</h4><p>For our example, let’s use a <strong>3 × 3 filter:</strong></p><pre>[ 1  0 -1 ]<br>[ 1  0 -1 ]<br>[ 1  0 -1 ]</pre><p>This particular filter responds strongly to certain vertical edges, where the brightness changes significantly from one side to the other.</p><p>The filter doesn’t look at the entire image at once. Instead, it is placed over a small 3 × 3 region of the image. We then perform a simple calculation between the filter and that region. This calculation produces one number. Then the filter moves to another region and does the same thing again. By repeating this process across the entire image, the CNN can figure out where a particular pattern appears.</p><p>But what exactly is that calculation?</p><h4>The convolution operation.</h4><p>Let’s place our 3 × 3 filter over the <strong>top-left corner</strong> of the image. The filter covers the first 3 rows and first 3 columns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7M8mYbKmKSCuyprXM3efg.png" /><figcaption>Filter</figcaption></figure><p>Now we compare the two matrices element by element:</p><pre>Image region              Filter<br><br>[ 1  1  1 ]               [ 1  0 -1 ]<br>[ 0  1  1 ]       ×       [ 1  0 -1 ]<br>[ 0  0  1 ]               [ 1  0 -1 ]</pre><p>We multiply each pixel by the corresponding value in the filter:</p><pre>(1 × 1) + (1 × 0) + (1 × -1)<br>+<br>(0 × 1) + (1 × 0) + (1 × -1)<br>+<br>(0 × 1) + (0 × 0) + (1 × -1)</pre><p>Now add everything together:</p><pre>1 + 0 - 1 + 0 + 0 - 1 + 0 + 0 - 1 = -2</pre><p>So, this particular region produces the value <strong>-2</strong>.</p><p><strong>That single number represents how strongly this region responds to the pattern represented by the filter.</strong></p><p>After processing the first 3 × 3 region, the filter moves one position to the right.</p><pre>Image region              Filter<br><br>[ 1  1  0 ]               [ 1  0 -1 ]<br>[ 1  1  0 ]       ×       [ 1  0 -1 ]<br>[ 0  1  0 ]               [ 1  0 -1 ]</pre><p>The same calculation is performed again. Then the filter keeps moving across the image, one position at a time. When it reaches the end of a row, it moves down and starts scanning the next row.</p><p>Eventually, we have a collection of numbers. That collection forms a new matrix called a <strong>feature map</strong>.</p><p>This entire process of sliding the filter across the image and performing these calculations is what we mean by <strong>convolution</strong>.</p><h4>From Numbers to a Feature Map</h4><p>For our <strong>5 × 5 image</strong> and <strong>3 × 3 filter</strong>, the filter can move to 9 different positions if we move it one pixel at a time. The resulting feature map might look something like this:</p><pre>[ -2   3   1 ]<br>[ -1   4   2 ]<br>[  0   5   1 ]</pre><p>Each number corresponds to one position where the filter was placed.</p><p>But what do these numbers actually tell us?</p><p>Remember that our filter was designed to respond to a particular pattern, such as a vertical edge. If the region of the image contains that pattern, the calculation produces a stronger response. If the pattern isn’t present, the response is weaker.</p><p>This is why it’s called a feature map. It maps the locations where a particular feature appears in the image.</p><p>And one filter doesn’t have to look for everything. A CNN can use many different filters, with each one learning to respond to different patterns.</p><p>But who decides what numbers should go inside these filters in the first place?</p><p>After all, we chose [1, 0, -1] ourselves for this example. A real CNN doesn’t have someone manually creating hundreds of filters. <strong>The network learns them.</strong></p><h4>How Does the CNN Learn the Filters?</h4><p>The network learns these filters during training. Initially, the filter values are usually initialised with small random values.</p><pre>[ 0.1  -0.2   0.1 ]<br>[-0.2   0.1  -0.2 ]<br>[ 0.4   0.4  -0.3 ]</pre><p>At this point, the filters don’t necessarily detect anything meaningful. The CNN takes an image, passes it through the network, and makes a prediction. Suppose the correct answer is Dog, but the network predicts Cat. The network calculates how far its prediction was from the correct answer using a <strong>loss function</strong>. The network then uses <strong>backpropagation</strong> to determine how its weights contributed to that error. An optimisation algorithm such as <strong>gradient descent</strong> then adjusts the filter values slightly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lay-zoQfaXPxHUMYZHXMPw.png" /><figcaption>How a CNN Learns Its Filters</figcaption></figure><p>This process happens repeatedly across many training images. Over time, the network discovers filter values that are useful for the task.</p><p>Some early filters may learn to respond to simple patterns such as edges, lines and corners. Deeper layers can then combine these simple patterns into Textures and Shapes. Eventually, the network can learn representations useful for recognising complete objects.</p><p>So the [1, 0, -1] filter we used earlier was just an example to understand how convolution works. In a real CNN, the filter values are learned automatically during training.</p><p>Now that we understand what convolution does and how filters are learned, there are two more concepts that determine how the filter moves across the image: <strong>Stride and Padding.</strong></p><h4>Stride: How Far Does the Filter Move?</h4><p>So far, we’ve assumed that the filter moves one pixel at a time across the image. But the filter doesn’t have to move only one pixel. The distance the filter moves after each operation is called the stride.</p><p>For example, with a stride of 2, the filter skips one position each time. This affects the size of the resulting feature map.</p><p>Suppose we have a <strong>5 × 5 image</strong> and a <strong>3 × 3 filter</strong>.</p><p>With a stride of 1:</p><pre>5 × 5 Image<br>     ↓<br>3 × 3 Filter<br>     ↓<br>3 × 3 Feature Map</pre><p>If we increase the stride to 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGZxJQiF7EOi12R6ARDR1w.png" /><figcaption>Visualizing Stride in Convolution</figcaption></figure><p>A larger stride means the filter moves faster across the image, producing a smaller feature map.</p><p>Now what happens when the filter reaches the edge of the image? That is where <strong>padding</strong> comes in.</p><h4>Padding: What Happens at the Edges?</h4><p>There is a problem with the way we’ve been applying the filter so far.</p><p>Remember our 5 × 5 image and 3 × 3 filter?</p><p>The filter can move across the image, but it cannot be placed completely outside the image. As a result, the pixels near the edges get processed fewer times than the pixels in the middle.</p><p>This can cause two problems:</p><ol><li>Information near the edges may be underrepresented.</li><li>The feature map becomes smaller after convolution.</li></ol><p>One way to solve this is padding.</p><p>Padding means adding extra pixels around the border of the image before applying the filter.</p><p>The most common approach is <strong>zero padding</strong>, where zeros are added around the border of the image.</p><p>Now the filter can also be centred around pixels near the boundary. This allows the CNN to process information close to the edges more effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EGy_rC68Qxn0-R8RT0VFZQ.png" /><figcaption><a href="https://datahacker.rs/what-is-padding-cnn/">Source</a></figcaption></figure><p>However, zero padding isn’t the only way to handle image boundaries. Different padding strategies determine what values are added around the edges. Some common approaches include:</p><ul><li><strong>Constant Padding:</strong> Adds a fixed value around the border. Zero padding is a special case of constant padding where the value is 0.</li><li><strong>Replicate Padding:</strong> Extends the image by repeating the pixels at the boundary.</li></ul><p>You may also come across two terms that describe whether padding is used at all and how it affects the output size: <strong>valid padding</strong> and <strong>same padding</strong>.</p><p><strong>Valid padding</strong> means no padding is added. The filter only operates where it completely fits inside the image, which makes the output smaller.</p><p><strong>Same padding</strong> adds enough padding so that, with a stride of 1, the output has the same height and width as the input.</p><p>So, padding isn’t just about adding extra pixels. It gives us control over how the edges of an image are processed and how large the resulting feature map will be.</p><p>And that brings us to the core idea behind convolution. In the next article, we’ll explore <strong>pooling</strong>, another important component of CNNs</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bd4637f45d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How CNNs Actually Work: From Pixels to Predictions]]></title>
            <link>https://medium.com/@rutuparna.kolte15/how-cnns-actually-work-from-pixels-to-predictions-d5e256cbcfd1?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5e256cbcfd1</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 18:30:54 GMT</pubDate>
            <atom:updated>2026-08-16T18:30:54.898Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/@rutuparna.kolte15/why-deep-neural-networks-struggle-with-images-ec9a8e893a12">previous article</a>, we saw why traditional Deep Neural Networks struggle with images.</p><p>When an image is flattened into a long vector, the network loses the spatial relationships between pixels. A fully connected network also requires a huge number of parameters because every neuron is connected to every neuron in the next layer.</p><p>So we are left with a question:</p><p><strong>If fully connected networks are not designed for images, what should we use instead?</strong></p><p>The answer is the <strong>Convolutional Neural Network, or CNN</strong>. Let’s see how a CNN goes from raw pixels to recognising an object.</p><h4>The Basic Idea Behind CNNs</h4><p>Think about how you recognise a dog in an image. You don’t memorise the exact value of every pixel. Instead, you notice:</p><ul><li>Eyes</li><li>Ears</li><li>Nose</li><li>Body structure</li><li>Textures</li><li>Shapes</li><li>Curves</li></ul><p>These features are combined to form the concept of a dog. CNNs follow a similar hierarchical approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*DBt8ZDw6tbYk-h2dmhlRcQ.png" /></figure><p>The network starts with low-level visual information and gradually builds higher-level representations.</p><p>To achieve this, CNNs use several specialised components. A simplified CNN can look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*HIULYK3zKjDidX6Om1MO9A.png" /><figcaption><a href="https://www.researchgate.net/figure/Basic-structure-of-Convolutional-Neural-Network-CNN-23-Artificial-neural-network_fig1_353049916">Source</a></figcaption></figure><p>Different CNN architectures use these components differently, and modern architectures may replace or modify some of them.</p><p>But this gives us a useful mental model. Let’s briefly understand what each component does.</p><h4>What Is Convolution?</h4><p>Consider a small grayscale image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MlvkwxyYGbsiycgvwxyWhg.png" /></figure><p>Instead of connecting every pixel to every neuron, we take a small window, such as a <strong>3 × 3 matrix</strong>, and place it over a small region of the image.</p><p>This small matrix is called a <strong>filter</strong> or <strong>kernel</strong>.</p><pre>3 × 3 Filter<br><br>[ 1 0 -1 ]<br>[ 1 0 -1 ]<br>[ 1 0 -1 ]</pre><p>The filter interacts with the pixels in that region. Each pixel is multiplied by the corresponding value in the filter, and the results are added together. This produces a single number. The filter then moves to the next position and repeats the same operation. By sliding across the entire image, the filter produces a new matrix called a <strong>feature map</strong>. This process is called <strong>convolution</strong>.</p><p>In practice, an activation function such as <strong>ReLU </strong>is typically applied after convolution, but we’ll leave that discussion for a later article.</p><h4>What is Pooling?</h4><p>After convolution, the network has feature maps containing information about the patterns it found. But these feature maps can still be large.</p><p>Do we really need to keep every single detail? Usually, no. This is where <strong>pooling</strong> comes in. Pooling reduces the spatial size of a feature map while keeping the most important information.</p><p>One of the most common types is <strong>Max Pooling</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*up6p4bwDNuxf88JC8hA6hQ.png" /><figcaption><a href="https://analyticsindiamag.com/deep-tech/max-pooling-in-convolutional-neural-network-and-its-features">Source</a></figcaption></figure><p>Max pooling looks at this region and keeps the largest values: <strong>8, 9, 7 &amp; 6.</strong></p><p>When applied across a larger feature map, this reduces its dimensions.</p><p>It also makes the representation less sensitive to small changes in the exact position of a feature. For example, if an edge shifts slightly within a pooling region, the strongest activation may still be retained.</p><h4>Fully Connected Layer</h4><p>After several rounds of convolution and pooling, the network has extracted many useful visual features. At this point, we want to use those features to make a prediction. This is where the <strong>fully connected layer</strong> comes in. You may remember fully connected layers from traditional neural networks. In a fully connected layer, every neuron in one layer is connected to every neuron in the next layer.</p><p>By the time information reaches this stage of a CNN, the network is no longer dealing with raw pixels. It has already extracted higher-level features. The fully connected layer combines these features and uses them to make the final decision.</p><h4>What’s Next?</h4><p>So far, we’ve only looked at the big picture.</p><p>We know that convolution uses filters to find patterns, pooling reduces feature maps, and fully connected layers use those learned features to make predictions. But there is a lot more happening inside these operations.</p><p>What exactly happens when a <strong>3 × 3 filter</strong> moves across an image?</p><p>How are the filter values learned?</p><p>Why do CNNs use <strong>padding and stride</strong>?</p><p>And how does a tiny filter learn to recognise something as simple as an edge?</p><p>In future articles, we’ll zoom into these operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5e256cbcfd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Deep Neural Networks Struggle with Images]]></title>
            <link>https://medium.com/@rutuparna.kolte15/why-deep-neural-networks-struggle-with-images-ec9a8e893a12?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec9a8e893a12</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-neural-networks]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[image-classification]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 13:11:25 GMT</pubDate>
            <atom:updated>2026-08-02T13:11:25.276Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/@rutuparna.kolte15/from-perceptrons-to-cnns-the-evolution-of-machines-that-learned-to-see-94ea3f7ca343">previous article</a>, we explored how <strong>Deep Neural Networks (DNNs)</strong> evolved from the original perceptron and became capable of solving complex problems by stacking multiple layers of neurons.</p><p>But there’s a catch.</p><p>While DNNs perform remarkably well on structured numerical data like customer information, stock prices, or medical measurements, they struggle when the input is an image.</p><p>Why?</p><p>Let’s find out.</p><h4><strong>A Computer Doesn’t See Images Like We Do</strong></h4><p>To a computer, an image is nothing more than a matrix of numbers. Let’s understand this with the example of a dog image. In practice, images are resized to a fixed resolution before being fed into a neural network. The chosen resolution depends on factors such as the model architecture, available computational resources, and the level of detail required for the task. For simplicity, we’ll resize our image to <strong>12 × 12 pixels</strong> and convert it to <strong>grayscale</strong>, so each pixel is represented by a single intensity value ranging from <strong>0 (black) to 255 (white)</strong>. Real-world applications often use colour images, which are represented using multiple channels. For example, an RGB image consists of three channels, one each for the Red, Green, and Blue colour components. Since our goal is to understand the basic concept, we’ll use a grayscale image throughout this explanation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*loOiYWe85lf_SaZRpSdwNA.png" /><figcaption>Grayscale Image Representation for Deep Neural Networks</figcaption></figure><p>Since the image contains 144 pixels, it can simply be represented as 144 numbers.</p><p>A Deep Neural Network doesn’t understand matrices. It expects a one-dimensional vector. So before feeding the image into the network, we flatten it.</p><p>Instead of <strong>12 x 12</strong>, we convert it into <strong>144 x 1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPlKfRpQgxWeQ6kGJZ2KwA.png" /><figcaption>Image Classification Using a Deep Neural Network (DNN)</figcaption></figure><p>Each value becomes one neuron in the input layer. Since there are <strong>144 pixel</strong> values, the input layer contains <strong>144 neurons</strong>.</p><p>These neurons are connected to hidden layers, which eventually predict the correct class.</p><p>The network finally outputs the probability for each class and selects the one with the highest confidence. At first glance, this seems reasonable. But this is where the real problem begins.</p><h4>Problem 1: The Image Loses Its Spatial Structure</h4><p>Look carefully at what happened during flattening. Originally, neighbouring pixels were physically next to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnZOAAjw0lLGm36KCgkhSw.jpeg" /><figcaption><a href="https://www.3blue1brown.com/lessons/neural-networks/">Source</a></figcaption></figure><p>After flattening, the computer no longer knows which pixels were neighbours. It only sees a long list of numbers.</p><p>Imagine tearing apart a jigsaw puzzle, placing all the pieces into a single line, and asking someone to identify the picture without knowing which pieces were originally adjacent.</p><p>That’s exactly what happens. The DNN receives all pixel values, but loses the image’s geometry.</p><h4>Problem 2: Every Pixel Is Connected to Every Neuron</h4><p>Our image has <strong>144 pixels. </strong>Suppose the <strong>first hidden layer</strong> has <strong>100 neurons</strong>. Every input neuron connects to every hidden neuron.</p><p>That means <strong>144 × 100 = 14,400 weights </strong>…just for the first layer.</p><p>Now imagine using a much more realistic image. A small RGB image of size <strong>224 x 224 x 3</strong> contains <strong>224 × 224 × 3 = 150,528 input values</strong>.</p><p>If the first hidden layer contains only <strong>1000 neurons</strong>, the number of weights becomes <strong>150,528 × 1000 = 150,528,000 weights. </strong>Over <strong>150 million parameters</strong>. And this is only the first layer.</p><p>As image resolution increases, the number of input neurons grows rapidly. Because every neuron is fully connected, the number of trainable parameters also explodes.</p><p>Eventually, the network becomes slower to train and more memory intensive.</p><h4>Problem 3: DNNs Don’t Understand Translation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SRO1mNmHLjhrcyFCNTmpMQ.jpeg" /><figcaption><a href="https://www.stocksy.com/photo/3353690/puppy-sleeping-upside-down">Source</a></figcaption></figure><p>Imagine training the network using thousands of dog images. Every dog appears exactly in the centre. Eventually, the model learns that arrangement of pixels. Now imagine moving the same dog just slightly toward the left. Nothing about the dog changed. Humans immediately recognise it. But to the DNN, almost every pixel value has shifted to a different position. The flattened vector now looks completely different. Although the image still contains the same dog, the network treats it almost like a new object. A simple shift in position can dramatically reduce prediction accuracy.</p><h4>Problem 4: DNNs Learn Individual Pixels Instead of Features</h4><p>Humans don’t memorize millions of pixel values. We recognise objects using meaningful features. For example, when identifying a dog, we notice eyes, ears, nose, tail, etc.</p><p>A traditional DNN doesn’t naturally learn these hierarchical visual features. It simply tries to find mathematical relationships among thousands of independent pixel values. As images become larger and more complex, this approach becomes increasingly inefficient.</p><h4>Why Image Classification Needed Convolutional Neural Networks</h4><p>Deep Neural Networks were a significant milestone in the evolution of artificial intelligence.</p><p>However, images exposed a fundamental weakness in fully connected networks. Flattening destroys spatial information, fully connected layers require an enormous number of parameters, and the network struggles to recognise the same object when it appears in different locations.</p><p>These limitations inspired a new architecture designed specifically for visual data: the <strong>Convolutional Neural Network (CNN)</strong>.</p><p>In the next article, we’ll explore the core idea behind <strong>CNNs</strong> and see how a simple operation called <strong>convolution</strong> allows computers to learn edges, textures, and shapes, much like the human visual system does.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec9a8e893a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Perceptrons to CNNs: The Evolution of Machines That Learned to See]]></title>
            <link>https://medium.com/@rutuparna.kolte15/from-perceptrons-to-cnns-the-evolution-of-machines-that-learned-to-see-94ea3f7ca343?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/94ea3f7ca343</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 19:13:32 GMT</pubDate>
            <atom:updated>2026-07-26T19:13:32.440Z</atom:updated>
            <content:encoded><![CDATA[<p>What animal is this? A cat. Even though she’s lying upside down, we can still recognise that it’s a cat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_VAQFdFejAsMFhJ2tLQsw.jpeg" /><figcaption><a href="https://www.rd.com/list/happy-cat-signs/">Source</a></figcaption></figure><p>You do not need to consciously analyse the shape of its ears, the texture of its fur, or the curvature of its tail. Light enters your eyes, signals fire in your brain, and you instantly know what you are looking at. It is an effortless, elegant process honed by millions of years of evolution.</p><p>A computer, however, does not see a cat. A computer only sees millions of numbers. When you feed an image into a machine, it receives a massive grid of pixel values, representing red, green, and blue light intensities.</p><p>How do you look at a spreadsheet of numbers and find a cat?</p><p>How did we teach computers to understand images, recognise faces, and drive cars?</p><p>This journey did not happen overnight. It took decades of relentless experimentation, involving brilliant breakthroughs, crushing failures, and a relentless pursuit to understand human intelligence. In this article, you will travel through the history of neural networks. You will see exactly what problems early computer scientists faced, why their initial ideas failed, and how they eventually built the foundation of modern artificial intelligence.</p><h3>The Inspiration: Biological Neurons</h3><p>Before we could build an artificial brain, we had to look at the only working model we had: our own.</p><p>The human brain is an unparalleled supercomputer. It contains roughly 86 billion biological cells called neurons. These neurons are constantly communicating with each other through a massive, intricate web of connections.</p><p>If you zoom in on a single biological neuron, you will notice a few key components. It has a cell body that acts as the central processor. Branching out from this centre are dendrites, which act like antennas receiving signals from other neurons. Finally, it has a long cable called an axon, which passes signals to the next neuron in the chain. The microscopic gap where two neurons connect is called a synapse.</p><p>When a neuron receives enough electrical signals from its neighbours through its dendrites, it “fires,” sending an electrical spike down its axon to trigger other neurons.</p><p>Scientists in the early 20th century were fascinated by this mechanism. They asked a profound question: If human intelligence is just the result of billions of simple cells firing electrical signals, could we simulate this behaviour with mathematics and machines?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*HUeS9UADstHxiJlbCzuzeQ.png" /><figcaption><a href="https://towardsdatascience.com/the-concept-of-artificial-neurons-perceptrons-in-neural-networks-fab22249cbfc/">Source</a></figcaption></figure><p>This biological inspiration paved the way for the very first attempt to build a synthetic mind.</p><h3>McCulloch &amp; Pitts Neuron (1943)</h3><p>A neurophysiologist named Warren McCulloch and a young, self-taught mathematical genius named Walter Pitts decided to translate the biological neuron into the language of mathematics.</p><p>They created the first mathematical model of a neuron.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*j-pMjiqjNbTXVJddW3ef_A.png" /><figcaption><a href="https://www.google.com/imgres?q=mp%20neuron&amp;imgurl=https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A738%2F1*fDHlg9iNo0LLK4czQqqO9A.png&amp;imgrefurl=https%3A%2F%2Fmedium.com%2Fdata-science%2Fmcculloch-pitts-model-mankinds-first-mathematical-model-of-a-biological-neuron-5fdf65ac5dd1&amp;docid=WV3XAdvZjcvZTM&amp;tbnid=DJgOGclUBhzMyM&amp;vet=12ahUKEwjD_r_U_PCVAxXeklYBHTm-OIIQnPAOegUIlAEQAA..i&amp;w=369&amp;h=287&amp;hcb=2&amp;ved=2ahUKEwjD_r_U_PCVAxXeklYBHTm-OIIQnPAOegUIlAEQAA">Source</a></figcaption></figure><h4>How It Worked</h4><p>The McCulloch-Pitts model was beautifully simple. It attempted to replicate the “all-or-nothing” firing behaviour of biological cells.</p><p>Here is how they designed it:</p><ul><li><strong>Inputs:</strong> The neuron receives binary inputs (either 0 or 1).</li><li><strong>Weights:</strong> Some inputs were “excitatory” (encouraging the neuron to fire), and others were “inhibitory” (preventing it from firing).</li><li><strong>Threshold:</strong> The neuron had a built-in limit.</li><li><strong>Binary Output:</strong> If the sum of the excitatory inputs was greater than or equal to the threshold, the neuron output a 1 (it fired). Otherwise, it outputs a 0.</li></ul><p>Think of it like a stubborn bouncer at an exclusive nightclub. The bouncer has a strict mental threshold. If three people on the VIP list show up (excitatory inputs), the bouncer lets them in (fires a 1). But if someone on the banned list arrives (inhibitory input), the bouncer immediately shuts the door, no matter who else is there.</p><h4><strong>The Fatal Flaw</strong></h4><p>The McCulloch-Pitts neuron was a conceptual breakthrough. It proved that artificial neurons could compute logic functions like AND, OR, and NOT.</p><p>But it had one massive limitation: it could not learn.</p><p>If you wanted the neuron to solve a problem, you had to manually figure out the correct weights and threshold, and program them by hand. The model had no mechanism to adapt, improve, or learn from experience. It was a fixed calculator, not a learning machine.</p><h3>The Perceptron (1958)</h3><p>The inability to learn was the exact problem Frank Rosenblatt sought to solve.</p><p>In 1958, working at the Cornell Aeronautical Laboratory, Rosenblatt introduced a revolutionary concept: The Perceptron. Rosenblatt did not just write a math paper; he built a massive physical machine, the Mark I Perceptron, designed to recognise simple shapes. Rosenblatt wanted to build a machine that could learn its own rules. Instead of humans hardcoding the weights, what if the machine could start with random weights, make a guess, and correct itself if it was wrong?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*IoGbkyATRdmRX2bAf2uaoA.jpeg" /><figcaption><a href="https://www.sciencedirect.com/topics/engineering/perceptron">Source</a></figcaption></figure><h4><strong>The Architecture</strong></h4><p>The Perceptron improved upon the McCulloch-Pitts model in a few critical ways:</p><ul><li><strong>Inputs:</strong> It could take multiple input values.</li><li><strong>Weights:</strong> Instead of simple excitatory/inhibitory switches, weights were continuous numbers. They represented the “importance” of a specific input.</li><li><strong>Bias:</strong> A flexible threshold that allowed the neuron to shift its decision boundary.</li><li><strong>Step Activation:</strong> Just like its predecessor, it summed up the inputs multiplied by their weights, added the bias, and used a step function to output a 1 or a 0.</li></ul><h3>The First AI Winter</h3><p>By the late 1960s, neural networks were heavily funded and highly publicised. However, progress had stalled. Researchers were finding that single Perceptrons could only solve very simple problems.</p><p>In 1969, two prominent AI researchers from MIT, Marvin Minsky and Seymour Papert, published a book simply titled Perceptrons. In it, they provided a rigorous mathematical proof showing that a single Perceptron was fundamentally incapable of solving a specific class of problems.</p><p>The most famous of these was the <strong>XOR problem</strong> (Exclusive OR).</p><h4>The XOR Problem Explained</h4><p>A Perceptron is a “linear classifier.” This means it draws a single straight line through data to separate it into two categories.</p><p>Imagine you are plotting data points on a piece of paper. If you want a Perceptron to learn the logical “AND” function, it can easily draw a single straight line to separate the scenarios where both inputs are true from the rest.</p><p>But XOR is different. XOR outputs a 1 <em>only</em> if the inputs are different (e.g., 1 and 0, or 0 and 1). If both inputs are the same (1 and 1, or 0 and 0), it outputs a 0.</p><p>If you plot the XOR data points on a graph, you will see two dots of one category in opposite corners, and two dots of the other category in the remaining corners. Try as you might, it is physically impossible to draw a single straight line that separates the two categories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*8ZUB-dCGAO721NcrKDg1Og.jpeg" /><figcaption><a href="https://www.google.com/imgres?q=xor&amp;imgurl=https%3A%2F%2Fwww.analog.com%2Fen%2F_%2Fmedia%2Fanalog%2Fen%2Fdesign-center%2Fglossary%2Fxor-gate-symbol.jpg&amp;imgrefurl=https%3A%2F%2Fwww.analog.com%2Fen%2Fresources%2Fglossary%2Fxor-gate.html&amp;docid=eXEGOswbb7Td5M&amp;tbnid=QuUwKrjdh7ZMpM&amp;vet=12ahUKEwj3z7bJ_vCVAxWrbmwGHekqCwkQnPAOegQIehAA..i&amp;w=326&amp;h=206&amp;hcb=2&amp;ved=2ahUKEwj3z7bJ_vCVAxWrbmwGHekqCwkQnPAOegQIehAA">Source</a></figcaption></figure><p>Minsky and Papert pointed this out explicitly. Because a single Perceptron could only draw one line, it could never learn XOR.</p><p>The impact of this book was catastrophic for neural network research. Funding agencies withdrew their financial support. The scientific community abandoned neural networks, pivoting to symbolic AI and rule-based systems.</p><p>This period of stagnation, lasting through the 1970s, became known as the First AI Winter.</p><h3>The Rise of Multi-Layer Neural Networks</h3><p>The solution to the XOR problem seems obvious to us today: if one line is not enough, why not use multiple lines? If one Perceptron cannot solve the problem, why not connect several of them together?</p><p>Scientists knew this theoretically. They realised that to solve complex, non-linear problems, they needed to stack neurons into layers.</p><h4>The Architecture of Layers</h4><p>A multi-layer neural network introduces a new structure:</p><ul><li><strong>Input layer:</strong> Receives the raw data.</li><li><strong>Hidden layer(s):</strong> One or more layers of neurons sandwiched in the middle.</li><li><strong>Output layer:</strong> Produces the final prediction.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*a5StM6222Ge6NjkWUSyf-A.jpeg" /><figcaption><a href="https://www.google.com/imgres?q=multi%20layer%20perceptron%20in%20machine%20learning&amp;imgurl=https%3A%2F%2Fars.els-cdn.com%2Fcontent%2Fimage%2F1-s2.0-S0925231223004502-gr1.jpg&amp;imgrefurl=https%3A%2F%2Fwww.sciencedirect.com%2Ftopics%2Fcomputer-science%2Fmultilayer-perceptron&amp;docid=cwVAPp-XaVfE-M&amp;tbnid=m4B41_gb7L728M&amp;vet=12ahUKEwiGqJWA__CVAxXXXGwGHXjoAXQQnPAOegUIpAEQAA..i&amp;w=367&amp;h=263&amp;hcb=2&amp;ved=2ahUKEwiGqJWA__CVAxXXXGwGHXjoAXQQnPAOegUIpAEQAA">Source</a></figcaption></figure><p>The hidden layers are the secret sauce. They allow the network to learn intermediate representations.</p><p>Instead of a single neuron trying to look at a complex image and immediately shouting “It is a car!”, the workload is distributed. The hidden layers can ask intermediate questions: “Are there circles?” “Is there glass?” “Is there a metallic chassis?”</p><p>By combining the outputs of these hidden neurons, the final output layer has enough information to make a highly complex, non-linear decision.</p><p>But there was a massive roadblock. While researchers knew they <em>needed</em> hidden layers, they had no idea how to train them. The Perceptron learning rule only worked when you knew the exact error of a neuron. In a multi-layer network, if the final output is wrong, which hidden neuron was responsible for the mistake? How do you distribute the blame?</p><p>Without a way to train them, multi-layer networks were useless.</p><h3>Backpropagation</h3><p>The breakthrough that thawed the AI Winter arrived in 1986. Researchers David Rumelhart, Geoffrey Hinton, and Ronald Williams published a paper detailing a method for training multi-layer neural networks.</p><p>They popularized an algorithm called <strong>Backpropagation</strong>.</p><h4>The Intuition of Backpropagation</h4><p>Backpropagation is the mechanism a neural network uses to learn from its mistakes. The process happens in four steps:</p><ul><li><strong>Forward Pass:</strong> The network processes data and makes a prediction.</li><li><strong>Loss:</strong> The network compares its prediction to the actual truth to measure its error.</li><li><strong>Gradient:</strong> Using calculus, specifically the Chain Rule; the network traces the error backwards through its layers to identify exactly which internal connections caused the mistake.</li><li><strong>Weight Update:</strong> The network adjusts those specific connections to improve future accuracy.</li></ul><p>To understand backpropagation, imagine a student taking a complex math exam.</p><p>The student attempts a multi-step calculus problem (this is the <strong>Forward pass</strong>, where data moves from the input, through the hidden layers, to the output).</p><p>The student finishes the problem and gets the answer 42. They check the answer key at the back of the book. The correct answer is 100. The student realizes they are way off. (This difference is the <strong>Loss</strong>).</p><p>Now, how does the student improve? They do not just randomly change numbers. They work backwards from the final answer. They look at their last step and see how much it contributed to the error. Then they look at the step before that, and the step before that, tracing the mistake all the way back to the beginning. (This backward tracing of errors is calculating the <strong>Gradient</strong>).</p><p>Once the student knows exactly which steps caused the most trouble, they study those specific formulas to ensure they don’t make the same mistake again. (This is the <strong>Weight update</strong>).</p><p>Backpropagation does exactly this using calculus, specifically, the Chain Rule. It calculates the error at the output layer and propagates that error backwards through the network, layer by layer, adjusting the weights of every single neuron based on how much it contributed to the final mistake.</p><p>Suddenly, hidden layers were no longer hidden black boxes. They could be systematically trained. The AI Winter was officially over.</p><h3>Deep Neural Networks</h3><p>With backpropagation in hand, researchers started adding more hidden layers to their networks. A neural network with many hidden layers is what we call a <strong>Deep Neural Network.</strong></p><p>But why go deep? Why not just have one incredibly wide hidden layer with a million neurons?</p><p>The answer lies in <strong>hierarchical feature learning</strong>.</p><p>The world is highly compositional. Complex things are built out of simpler things. Deep neural networks mirror this reality by learning features in a hierarchy, step-by-step.</p><p>Imagine feeding an image of a human face into a deep neural network:</p><ul><li><strong>Layer 1</strong> looks at raw pixels and learns to detect simple edges and color contrasts.</li><li><strong>Layer 2</strong> combines those edges to detect basic shapes, like curves and corners.</li><li><strong>Layer 3</strong> combines curves to identify distinct textures or small patterns.</li><li><strong>Layer 4</strong> combines patterns to recognise object parts, like a nose, an eye, or an ear.</li><li><strong>Layer 5</strong> combines the eyes, nose, and ears to recognise a complete human face.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*sQB4kvgwjbeX5-VVXXIIow.jpeg" /><figcaption><a href="https://www.researchgate.net/figure/Deep-neural-networks-learn-hierarchical-feature-representations-After-LeCun-et-al_fig1_338600485">Source</a></figcaption></figure><p>If you only had one hidden layer, the network would try to learn the entire face in a single leap, which is incredibly difficult and inefficient. Deep networks conquer complexity by breaking it down into manageable, hierarchical steps.</p><p>The journey from a single mathematical neuron to deep, multi-layered networks was a monumental triumph in computer science.</p><p>We started with a rigid, hardcoded imitation of biological cells. We gave it the ability to learn from its mistakes using the Perceptron. When linear limitations triggered the AI Winter, we broke through the ice by stacking neurons into hidden layers and using backpropagation to systematically train them.</p><p>By stacking these layers, we finally created Deep Neural Networks capable of learning complex, hierarchical features. The machines were finally getting smart.</p><p>But there was a catch.</p><p>When researchers pointed these powerful new “deep” brains at a seemingly simple task i.e., looking at a grid of pixels to recognise a face, a car, or a handwritten digit, they hit a massive, catastrophic brick wall. The networks choked. They ran out of memory, they trained too slowly, and they completely failed to understand what they were looking at.</p><p>In the next article, we will explore exactly why traditional neural networks are fundamentally broken when it comes to processing images.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94ea3f7ca343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding How the Brain Perceives the World. Can Machines Learn to See Like Humans?]]></title>
            <link>https://medium.com/@rutuparna.kolte15/understanding-how-the-brain-perceives-the-world-can-machines-learn-to-see-like-humans-38cbbaf57f25?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/38cbbaf57f25</guid>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[human-brain]]></category>
            <category><![CDATA[perception-of-reality]]></category>
            <category><![CDATA[vision]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 17:38:35 GMT</pubDate>
            <atom:updated>2026-07-19T17:38:35.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqFXJMzumSAI4e8__YGJlA.png" /></figure><p>The brain does not directly experience the world around us. It does not see light, hear sound, or feel touch on its own. Instead, it receives electrical signals generated by our sensory organs and uses them to construct our perception of reality.</p><p>When a baby is born, its brain already contains billions of neurons and many pre-wired neural connections. However, it has very little experience of the outside world. As the baby interacts with its surroundings, the brain continuously gathers information and strengthens, weakens, or creates new neural connections based on those experiences.</p><p>Over time, these networks of neurons begin forming associations between what the baby perceives and what those perceptions mean. The brain gradually learns to recognize objects, predict outcomes, remember experiences, and determine appropriate responses to different situations.</p><p>A significant part of this learning comes from observing other living beings. Babies constantly watch how people and animals behave, imitate their actions, and learn from their reactions. This ability to learn from experience and observation allows humans to understand increasingly complex situations as they grow.</p><p>Image perception is far more than simply detecting light. Although vision begins when light strikes the retina and is converted into electrical signals, what we ultimately “see” depends on much more than that. Context, attention, expectations, and past experiences all influence our perception. The brain does not merely record the visual information it receives. Instead, it interprets that information based on the surrounding environment and what it has learned from previous experiences.</p><p>Replicating this remarkable process in machines is an incredibly challenging task. Yet, this challenge is exactly what inspired the development of Artificial Intelligence and Neural Networks. Scientists have spent decades trying to understand how the brain recognizes the world around us. Although we still don’t fully understand the brain, one idea inspired modern Artificial Intelligence: learning through interconnected neurons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*aGZSaOvdhg-SCQ-q7MGIXw.png" /><figcaption><a href="https://www.cloudflare.com/learning/ai/what-is-neural-network/">Source</a></figcaption></figure><p>Artificial Neural Networks (ANNs) are a simplified mathematical model inspired by biological neurons. Unlike the human brain, artificial neurons don’t think or understand. Each neuron simply performs a small mathematical operation and passes the result to the next layer. Yet, when millions of these neurons work together, surprisingly intelligent behavior emerges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38cbbaf57f25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is Tokenization & How It Works?]]></title>
            <link>https://medium.com/@rutuparna.kolte15/what-is-tokenization-how-it-works-cfd1b8f0508a?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfd1b8f0508a</guid>
            <category><![CDATA[tokenization]]></category>
            <category><![CDATA[nltk]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai-token]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Thu, 19 Sep 2024 12:02:26 GMT</pubDate>
            <atom:updated>2024-09-19T12:02:26.865Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Learn What Tokens Are, Explore Different Types, and Discover How NLTK Makes Tokenization Easy</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vFt4lp8hmJGyU6zK.jpg" /><figcaption><a href="https://wisdomml.in/wp-content/uploads/2022/08/tokenizer.jpg">Source</a></figcaption></figure><h3>What is Tokenization?</h3><p>The language we use in everyday communication is often informal and not strictly adherent to grammatical and linguistic rules. As a result, machines can struggle to understand such language. Therefore, preprocessing is necessary to make it comprehensible for machines.</p><p>Tokenization is an initial step in data preprocessing for natural language processing (NLP). It involves dividing paragraphs and sentences into smaller units, known as tokens, which can be more easily analyzed and interpreted. This process facilitates machines in understanding the meaning and context of natural language more effectively.</p><h3><strong>Types of Tokenization:</strong></h3><ol><li><strong>Word Tokenization:</strong><br>Word tokenization splits text based on natural breaks, such as spaces or pauses in speech, dividing the data into individual words. However, it can be challenging to handle unknown or out-of-vocabulary (OOV) words. This issue is typically addressed by replacing such words with a placeholder token. The accuracy of word tokenization depends on the vocabulary the model has been trained with.</li><li><strong>Character Tokenization:</strong><br>In character tokenization, the text is broken down into individual characters. This method resolves OOV issues by ensuring that even unfamiliar words are tokenized at the character level. However, this approach increases the length of the output by fragmenting even simple sentences into characters. Additionally, it introduces the challenge of understanding the relationship between characters to derive the meaning of words.</li><li><strong>Subword Tokenization:</strong><br>Subword tokenization goes beyond word boundaries by breaking words into smaller units based on linguistic rules. It can segment words into meaningful parts, such as affixes. This approach is particularly useful for handling OOV words, as recognizing affixes can provide additional context and insight into the function of unknown words.</li><li><strong>Sentence Tokenization:<br></strong>When dealing with large volumes of data, sentence tokenization is employed. In this method, a paragraph is segmented into individual sentences for easier processing and analysis.</li></ol><h3><strong>Tokenization using Natural Language Toolkit (nltk):</strong></h3><p><strong>Installation</strong></p><p>Install nltk using pip</p><pre>pip install nltk</pre><p>Download necessary data</p><pre>import nltk<br>nltk.download(&#39;punkt&#39;)Sentence Tokenization</pre><p><strong>Sentence Tokenization</strong></p><pre>from nltk.tokenize import sent_tokenize<br><br>text = &quot;Tokenization splits text into smaller parts. It helps machines understand language better.&quot;<br>sentences = sent_tokenize(text)<br><br>print(sentences)</pre><pre>#Output<br>[&#39;Tokenization splits text into smaller parts.&#39;,&#39;It helps machines understand language better.&#39;]</pre><p><strong>Word Tokenization</strong></p><pre>from nltk.tokenize import word_tokenize<br><br>words = word_tokenize(text)<br>print(words)</pre><pre>#Output<br>[&#39;Tokenization&#39;, &#39;splits&#39;, &#39;text&#39;, &#39;into&#39;, &#39;smaller&#39;, &#39;parts&#39;, &#39;.&#39;, &#39;It&#39;, &#39;helps&#39;,<br> &#39;machines&#39;, &#39;understand&#39;, &#39;language&#39;, &#39;better&#39;, &#39;.&#39;]</pre><p><strong>Character Tokenization</strong></p><p>Although nltk doesn’t have a function for character tokenization, you can easily split a string into characters using Python’s built-in list() function:</p><pre>characters = list(text)<br>print(characters)</pre><pre>#Output<br>[&#39;T&#39;, &#39;o&#39;, &#39;k&#39;, &#39;e&#39;, &#39;n&#39;, &#39;i&#39;, &#39;z&#39;, &#39;a&#39;, &#39;t&#39;, &#39;i&#39;, &#39;o&#39;, &#39;n&#39;, &#39; &#39;, &#39;s&#39;, &#39;p&#39;, &#39;l&#39;, &#39;i&#39;, &#39;t&#39;, &#39;s&#39;, &#39; &#39;,  &#39;t&#39;, &#39;e&#39;, &#39;x&#39;, &#39;t&#39;, &#39; &#39;, &#39;i&#39;, &#39;n&#39;, &#39;t&#39;, &#39;o&#39;, &#39; &#39;, &#39;s&#39;, &#39;m&#39;, &#39;a&#39;, &#39;l&#39;, &#39;l&#39;, &#39;e&#39;, &#39;r&#39;, &#39; &#39;, &#39;p&#39;, &#39;a&#39;,  &#39;r&#39;, &#39;t&#39;, &#39;s&#39;, &#39;.&#39;, &#39; &#39;, &#39;I&#39;, &#39;t&#39;, &#39; &#39;, &#39;h&#39;, &#39;e&#39;, &#39;l&#39;, &#39;p&#39;, &#39;s&#39;, &#39; &#39;, &#39;m&#39;, &#39;a&#39;, &#39;c&#39;, &#39;h&#39;, &#39;i&#39;, &#39;n&#39;,  &#39;e&#39;, &#39;s&#39;, &#39; &#39;, &#39;u&#39;, &#39;n&#39;, &#39;d&#39;, &#39;e&#39;, &#39;r&#39;, &#39;s&#39;, &#39;t&#39;, &#39;a&#39;, &#39;n&#39;, &#39;d&#39;, &#39; &#39;, &#39;l&#39;, &#39;a&#39;, &#39;n&#39;, &#39;g&#39;, &#39;u&#39;, &#39;a&#39;,  &#39;g&#39;, &#39;e&#39;, &#39; &#39;, &#39;b&#39;, &#39;e&#39;, &#39;t&#39;, &#39;t&#39;, &#39;e&#39;, &#39;r&#39;, &#39;.&#39;]</pre><h3>Need of Counting Tokens:</h3><p>Knowing the token count of a text input can help estimate costs on a per-token basis. It also allows for an estimation of how long the text will take to process before receiving a response. Additionally, counting tokens can provide insight into usage, helping to manage resources effectively.</p><p><strong>Tools for counting Tokens:</strong></p><ul><li><a href="https://quizgecko.com/tools/token-counter">GPT-4 Token Counter Online</a></li><li><a href="https://token-counter.app/">All in one LLM Token Counter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfd1b8f0508a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master Web Scraping with BeautifulSoup: A Beginner’s Guide to Data Extraction]]></title>
            <link>https://medium.com/@rutuparna.kolte15/master-web-scraping-with-beautifulsoup-a-beginners-guide-to-data-extraction-c623a7813670?source=rss-c28d1234abb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c623a7813670</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[beautifulsoup]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[website]]></category>
            <dc:creator><![CDATA[Rutuparna Kolte]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 12:31:04 GMT</pubDate>
            <atom:updated>2024-09-16T17:28:54.819Z</atom:updated>
            <content:encoded><![CDATA[<p>With BeautifulSoup, you can effortlessly extract data from websites with just a few simple steps, fully unlocking the potential of web scraping.</p><figure><img alt="Introduction to web scrapping" src="https://cdn-images-1.medium.com/max/841/1*xctNcvKEk8sz9_mHBRHR-Q.png" /><figcaption><a href="https://monashdatafluency.github.io/python-web-scraping/images/request.png">Source</a></figcaption></figure><p>Companies like Google and Facebook provide public APIs to access their data. However, some websites either do not allow users to access their data or cannot provide it. In such cases, web scraping techniques extract data from these websites.</p><h3>Web Scraping with BeautifulSoup</h3><p>After reading this article, you will be able to scrape any website on the internet. We will cover the basic functionalities of BeautifulSoup.</p><h4>What is BeautifulSoup?</h4><p>BeautifulSoup is a Python library used to extract data from HTML or XML documents.</p><h4>1. Installing BeautifulSoup</h4><p>To install BeautifulSoup, use the following command:</p><pre>pip install beautifulsoup4</pre><h4>2. Creating a BeautifulSoup Object</h4><p>Create a BeautifulSoup object by passing the HTML document and a parser (e.g., html.parser, lxml) as parameters:</p><pre>from bs4 import BeautifulSoup<br>html_doc = &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&quot;<br>soup = BeautifulSoup(html_doc, &#39;html.parser&#39;)</pre><h4>3. Finding Elements</h4><p>To locate elements within the document:</p><ul><li><strong>.find()</strong>: Finds the first occurrence of the specified tag.</li></ul><pre>h1_tag = soup.find(&#39;h1&#39;)<br>print(h1_tag.text)  # Output: Hello World</pre><p><strong>.find_all()</strong>: Returns all occurrences of the specified tag as a list.</p><pre>soup = BeautifulSoup(&quot;&lt;p&gt;Paragraph 1&lt;/p&gt;&lt;p&gt;Paragraph 2&lt;/p&gt;&quot;, &quot;html.parser&quot;)<br>paragraphs = soup.find_all(&#39;p&#39;)<br>for p in paragraphs:<br>    print(p.text)<br># Output:<br># Paragraph 1<br># Paragraph 2</pre><h4>4. Navigating the DOM Tree</h4><p>You can navigate through the HTML structure using various properties:</p><p><strong>.parent</strong>: Retrieves the parent of a tag.</p><pre>h1_parent = h1_tag.parent<br>print(h1_parent.name)  # Output: body</pre><p><strong>.children</strong>: Retrieves the direct children of a tag (returns an iterator).</p><pre>for child in soup.body.children:<br>    print(child.name)  # Output: h1</pre><p><strong>.descendants</strong>: Retrieves all descendants of a tag (includes all levels).</p><pre>for descendant in soup.body.descendants:<br>    print(descendant.name)</pre><h4>5. Extracting Attributes</h4><p>You can extract attributes of a tag, such as id, class, or any custom attributes:</p><ul><li><strong>.get()</strong>: Retrieves the value of an attribute.</li></ul><pre>tag = soup.find(&#39;h1&#39;)<br>print(tag.get(&#39;id&#39;))</pre><p><strong>.attrs</strong>: Returns a dictionary containing all the attributes of a tag.</p><pre>print(tag.attrs)</pre><h4>6. Searching by Attributes</h4><p>You can search for elements by attributes such as id, class, etc.</p><ul><li>Using <strong>.find()</strong> or <strong>.find_all()</strong> with attributes:</li></ul><pre>tag = soup.find(&#39;h1&#39;, {&#39;class&#39;: &#39;header&#39;})<br>print(tag.text)</pre><p>Or</p><pre>tag = soup.find(class_=&#39;header&#39;)<br>print(tag.text)</pre><h4>7. Modifying the HTML</h4><p>You can modify the content of elements:</p><ul><li><strong>.string</strong>: Changes the text inside a tag.</li></ul><pre>tag = soup.find(&#39;h1&#39;)<br>tag.string = &quot;New Heading&quot;<br>print(tag)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c623a7813670" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>