<?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 Lavanka Harshani on Medium]]></title>
        <description><![CDATA[Stories by Lavanka Harshani on Medium]]></description>
        <link>https://medium.com/@lavankaharshani?source=rss-f9c94889982f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oNI7FLjyAu9uoeewVoQR7g.jpeg</url>
            <title>Stories by Lavanka Harshani on Medium</title>
            <link>https://medium.com/@lavankaharshani?source=rss-f9c94889982f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:06:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lavankaharshani/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[Self-adaptation using Test-Time Adaptation (TTA)]]></title>
            <link>https://medium.com/@lavankaharshani/self-adaptation-using-test-time-adaptation-tta-0e97be8d2a8a?source=rss-f9c94889982f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e97be8d2a8a</guid>
            <category><![CDATA[self-adaptation]]></category>
            <category><![CDATA[tta]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[meta-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Lavanka Harshani]]></dc:creator>
            <pubDate>Thu, 19 Mar 2026 14:11:17 GMT</pubDate>
            <atom:updated>2026-03-19T14:11:17.721Z</atom:updated>
            <content:encoded><![CDATA[<p>Normally, this is how we think about Machine Learning:</p><p>We train a model → then deploy it → and that’s it, the model becomes <strong>fixed</strong>.</p><p>Right?</p><p>But… what if a model could <strong>continue learning while being used</strong>, or in other words, <strong>during test/inference time itself?</strong> 🤔</p><p>That’s exactly the idea behind a powerful concept called <strong>Test-Time Adaptation (TTA)</strong>.</p><p>So today, let’s talk about an AI method that allows models to <strong>learn during usage, Test-Time Adaptation (TTA)</strong>.</p><p>⚠️ One of the biggest and most common problems when deploying models in the real world is:</p><p>👉 <strong>Training data ≠ Real-world data</strong></p><p>For example, the data we use during training is usually <strong>clean and high-quality</strong>.<br> But in real-world scenarios, the input data may not be the same.</p><p>Real-world images can be:</p><ul><li>blurry</li><li>low-light</li><li>noisy</li></ul><p>This mismatch is known as <strong>domain shift</strong>.</p><p>❌ Traditional ML models struggle to handle this situation, which often leads to a <strong>drop in performance</strong>.</p><p>✅ This is where <strong>TTA</strong> becomes useful.</p><p>A TTA model, in simple terms:</p><p>✔ observes incoming data during test time<br> ✔ adjusts its internal parameters<br> ✔ adapts to the new environment (self-adaptation)</p><p>And it does all this <strong>without retraining the model</strong>!</p><h3>How does this self-adaptation happen?</h3><p>TTA methods commonly use techniques such as:</p><ul><li><strong>Entropy minimization</strong> (increasing prediction confidence)</li><li><strong>Updating batch normalization statistics</strong></li><li><strong>Using self-supervised signals</strong></li></ul><p>👉 This allows the model to <strong>self-correct using unlabeled data</strong>.</p><p>🔥 Why is TTA important?</p><p>✔ Essential for real-world AI systems<br> ✔ Eliminates the need for large-scale retraining<br> ✔ Makes effective use of unlabeled data<br> ✔ Enables continuous learning behavior → leading to better accuracy</p><p>👉 Therefore, Test-Time Adaptation can be considered a <strong>highly important method for real-world machine learning applications</strong>, where environments are dynamic and data constantly changes.</p><p>#Week04 #AI #MachineLearning #DeepLearning #TTA #TestTimeAdaptation #MetaLearning #DomainAdaptation #AIResearch #LearnAI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e97be8d2a8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Prototypical Networks in Few-Shot Learning: Classifying Images Using Class Prototypes]]></title>
            <link>https://medium.com/@lavankaharshani/understanding-prototypical-networks-in-few-shot-learning-classifying-images-using-class-prototypes-da578b324652?source=rss-f9c94889982f------2</link>
            <guid isPermaLink="false">https://medium.com/p/da578b324652</guid>
            <dc:creator><![CDATA[Lavanka Harshani]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 04:33:26 GMT</pubDate>
            <atom:updated>2026-03-12T04:33:26.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3DMyWNZDKSTjV7_jQ--8g.png" /></figure><p>💡 In the past few weeks, we discussed a <strong>model training approach that can train models using very small amounts of data</strong>, known as <strong>Few-Shot Learning (FSL)</strong>. We also learned that in this approach, the images in the <strong>support set</strong> are passed through a <strong>CNN backbone</strong> (such as ResNet or ConvNet) to generate <strong>feature embeddings</strong>, and that this is how the training process takes place. 💡</p><p>Although there are several methods used to implement Few-Shot Learning models, one of the <strong>most commonly used architectures in research papers</strong> is <strong>Prototypical Networks</strong>, which is both simple and powerful.</p><p>Let us assume that in our dataset, a particular class has <strong>5 support images</strong>. These images are passed through a <strong>CNN backbone</strong> to generate <strong>feature embeddings</strong>. An <strong>embedding</strong> can be simply understood as the <strong>mathematical representation of an image</strong>. In other words, the image is represented using numbers. 🔢</p><p>After passing the images through the backbone network, we obtain <strong>5 embedding vectors</strong> corresponding to those images. The next step is to <strong>calculate the average embedding</strong> of these 5 vectors.</p><p>The core idea of <strong>Prototypical Networks</strong> lies in this process, which is called <strong>prototype creation</strong>.</p><p>A <strong>prototype</strong> represents the <strong>average embedding vector of a particular class</strong>.</p><p>For example:</p><p>Dog prototype = average (Dog embedding 1, Dog embedding 2, Dog embedding 3)</p><p>Let us denote this prototype as <strong>P01</strong>.</p><p>Now we have the <strong>average embedding (prototype) for that class</strong>. If the dataset contains <strong>3 classes</strong>, we will have <strong>3 prototypes</strong> such as <strong>P01, P02, and P03</strong>.</p><p>Now let’s see <strong>how the model classifies an unseen image</strong>.</p><p>The <strong>query image</strong> (an image the model has not seen before) is also passed through the <strong>same CNN backbone</strong>, and an <strong>embedding vector</strong> is generated for it.</p><p>Example:</p><p>Query image → embedding vector</p><p>Let us denote this embedding as <strong>P1</strong>.</p><p>Now we compare <strong>P1</strong> with all the class prototypes (<strong>P01, P02, P03</strong>). To do this, we use <strong>distance measures</strong>.</p><p>Two of the most commonly used distance metrics are:</p><ul><li><strong>Euclidean distance</strong></li><li><strong>Cosine similarity</strong></li></ul><p>For example:</p><p>d1 = Distance (P1, P01)<br>d2 = Distance (P1, P02)<br>d3 = Distance (P1, P03)</p><p>The model then <strong>assigns the query image to the class with the smallest distance (closest prototype)</strong>.</p><p>📝 Closest distance → Let’s assume <strong>d2</strong><br>Therefore, <strong>Query image (P1) is classified as Class P02</strong>.</p><p>In simple terms:</p><p><strong>Prototypical Networks classify images based on the closest class prototype in the embedding space.</strong></p><p>There are several reasons why <strong>Prototypical Networks are powerful</strong>. ☀︎</p><p><strong>1️⃣ Simple but effective</strong><br>Instead of using complex classifiers, Prototypical Networks rely on <strong>distance-based classification</strong>.</p><p><strong>2️⃣ Works well with small data</strong><br>Even with very few examples, the <strong>prototype concept captures the structure of each class effectively</strong>.</p><p><strong>3️⃣ Good generalization</strong><br>The model can <strong>quickly adapt to completely new classes</strong>.</p><p>If you would like to read this content in Sinhala, please use the following link:</p><p>#Week03 #AI #MachineLearning #FewShotLearning #PrototypicalNetworks #MetaLearning #ArtificialIntelligence #AIResearch #LearnAI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da578b324652" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Few-Shot Learning Works: Step-by-Step Training with Support Sets and Query Sets]]></title>
            <link>https://medium.com/@lavankaharshani/how-few-shot-learning-works-step-by-step-training-with-support-sets-and-query-sets-05f6c50558ed?source=rss-f9c94889982f------2</link>
            <guid isPermaLink="false">https://medium.com/p/05f6c50558ed</guid>
            <dc:creator><![CDATA[Lavanka Harshani]]></dc:creator>
            <pubDate>Wed, 04 Mar 2026 10:21:03 GMT</pubDate>
            <atom:updated>2026-03-04T10:21:03.872Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, we discussed how in the <strong>traditional approach of Machine Learning</strong>, training a model typically requires a <strong>large amount of data (huge datasets)</strong>. We also talked about how, when such large datasets are not available, we can use the <strong>Few-Shot Learning (FSL)</strong> approach to recognize new classes using only a small amount of data. Additionally, we mentioned that the training strategy commonly used in FSL systems is called <strong>episodic training</strong>.</p><p>To explain this concept clearly, let’s consider a <strong>simple animal classification problem</strong>.</p><h3>Problem</h3><p>Imagine that we want to train a model to classify images into <strong>three animal classes</strong>. Our goal is to teach the model to identify <strong>Dog, Cat, and Bird</strong>.</p><h3>Traditional Solution</h3><p>In traditional deep learning approaches, thousands of images per class are usually required for the model to correctly classify a <strong>previously unseen image</strong>.</p><h3>FSL Solution</h3><p>However, in <strong>Few-Shot Learning</strong>, we typically use only <strong>3–5 images per class</strong>.</p><p>Let’s now look at the <strong>training strategy of an FSL model step by step.</strong></p><h3>Step 1 — Dataset Preparation</h3><p>In an FSL scenario, instead of using a large dataset, we use a <strong>small set of labeled examples</strong>.</p><p>Example:</p><p>Dog class → 5 images<br> Cat class → 5 images<br> Bird class → 5 images</p><p>This results in a <strong>very small dataset</strong>. The key idea here is that the model should be able to <strong>grasp the concept of each class using only a limited number of examples</strong>.</p><h3>Support Set</h3><p>From these images, a subset is provided to the model as <strong>learning examples</strong>, which is called the <strong>Support Set</strong>.</p><p>The support set essentially tells the model:</p><blockquote><em>“These images are examples of the classes Dog, Cat, and Bird.”</em></blockquote><p>For example:</p><p>Dog → 3 images<br>Cat → 3 images<br>Bird → 3 images</p><p>If a task contains <strong>N classes with K examples per class</strong>, it is referred to as an <strong>N-way K-shot classification task</strong>.</p><p>Example:<br> 2 classes with 3 examples each → <strong>2-way 3-shot classification</strong></p><p>During this stage, the model extracts <strong>visual features</strong> from the images such as:</p><ul><li>ear shapes</li><li>fur patterns</li><li>beak structures</li></ul><h3>Query Set</h3><p>The <strong>Query Set</strong> consists of images that the model has <strong>not seen before</strong>. These are the images the model must classify.</p><p>The objective is for the model to <strong>learn the concept of each class from the support set and correctly classify the query images</strong>.</p><h3>Step 2 — Feature Extraction and Embeddings</h3><p>At this stage, architectures such as <strong>CNNs, Deep Neural Networks, or ResNet</strong> are typically used to extract <strong>feature representations (embeddings)</strong> from the support images.</p><p>These embeddings allow the model to recognize important characteristics of an image such as:</p><ul><li>edges</li><li>shapes</li><li>textures</li><li>patterns</li><li>semantic features</li></ul><p>In other words, instead of simply learning what an image is, the model learns <strong>how images differ from one another</strong>.</p><p>This is exactly why Few-Shot Learning follows the concept of <strong>“learning to learn.”</strong></p><p>The <strong>feature space</strong> learned during this stage helps the model understand <strong>similarities between classes</strong>.</p><p>We will explore <strong>Feature Extraction and Embedding Creation in more detail in the next post.</strong></p><h3>Step 3 — Model Training (Meta-Learning and Episodic Training)</h3><p>FSL models are <strong>not trained in the same way as traditional supervised learning models</strong>. Instead, the training process follows a <strong>meta-learning framework</strong>.</p><p>This means the model learns through <strong>small learning tasks rather than a single large training process</strong>.</p><p>During training, the dataset is divided into <strong>episodes</strong>, which are small tasks.</p><p>Each episode contains:</p><ul><li><strong>Support Set</strong> (learning examples)</li><li><strong>Query Set</strong> (evaluation examples)</li></ul><p>By solving many such episodes, the model learns the <strong>ability to learn new tasks quickly</strong>.</p><p>This training strategy is known as <strong>episodic training</strong>.</p><p>We will discuss episodic training in greater depth in future posts.</p><h3>Step 4 — Inference and Model Evaluation</h3><p>During training, the model repeatedly learns from the <strong>support set</strong> and evaluates itself using the <strong>query set</strong> across many small episodes.</p><p>The classification process works by comparing the <strong>embedding of the query image</strong> with the <strong>embeddings extracted from the support set</strong>.</p><p>By measuring <strong>similarity between embeddings</strong>, the model predicts the <strong>closest class</strong>.</p><p>Similar to traditional machine learning models, we can evaluate model performance using metrics such as:</p><ul><li>Accuracy</li><li>Precision</li><li>Recall</li><li>F1-score</li></ul><p>A strong Few-Shot Learning model should demonstrate <strong>good generalization ability</strong>, even when trained with very limited labeled data.</p><h3>Step 5 — Transfer and Generalization</h3><p>One of the biggest advantages of Few-Shot Learning is its ability to <strong>adapt to new tasks or classes that the model has never seen before</strong>.</p><p>Example:</p><p>New class → <strong>Fox</strong></p><p>Support Set<br> Fox → 3 images</p><p>Even though the model was originally trained on <strong>Dog, Cat, and Bird</strong>, it can still quickly learn to recognize <strong>Fox</strong> using only a few examples.</p><p>This is possible because the model has already learned <strong>general representations of visual features</strong>.</p><p>By leveraging this <strong>generalization ability</strong>, the model can identify Fox images without requiring a complete retraining process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05f6c50558ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Teaching Machines to “Learn to Learn” : Few Shot Learning]]></title>
            <link>https://medium.com/@lavankaharshani/teaching-machines-to-learn-to-learn-few-shot-learning-957e2fa88a4b?source=rss-f9c94889982f------2</link>
            <guid isPermaLink="false">https://medium.com/p/957e2fa88a4b</guid>
            <dc:creator><![CDATA[Lavanka Harshani]]></dc:creator>
            <pubDate>Sat, 21 Feb 2026 16:45:40 GMT</pubDate>
            <atom:updated>2026-02-21T16:52:46.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Few-Shot Learning as a Foundation for Adaptive AI</h3><p>Artificial Intelligence and Machine Learning are often discussed alongside the phrase “Data is the new fuel.” In reality, traditional Deep Learning models require massive datasets to achieve good performance hundreds of thousands or even millions of data points such as images, recordings, or text samples. However, in the real world, such large amounts of data are not always available. Collecting data is particularly difficult in areas like healthcare, security, rare events, and many research problems. This is where a powerful concept called <strong>Few-Shot Learning (FSL)</strong> comes in as a solution.</p><p>Few-Shot Learning is an approach that trains a model to recognize a new class using only a very small number of examples (sometimes fewer than 10). In a way, it mimics how humans learn. For instance, if we see a new dog breed just two or three times, we can usually recognize it again later. Similarly, an AI model can be trained to do the same. This method is often described as <strong>“learning to learn.”</strong> It is not simple memorization; instead, the model learns deeper concepts such as similarities, patterns, and relationships between features.</p><p>Consider a security system as an example. A typical face recognition system usually requires many photos of each individual to train effectively. But in practical situations ; for example, when a new employee joins an organization there is no time to collect thousands of photos and retrain the model. A system based on Few-Shot Learning can recognize that person using only 2–5 images. The next time the person appears on camera, the system can correctly identify them. This makes FSL extremely powerful for real-world applications where data is limited.</p><p>The training paradigm of FSL is also different from that of conventional machine learning models. In traditional supervised learning, we typically follow a “train once → test later” workflow. In contrast, Few-Shot Learning models are trained in an <strong>episode-based</strong> manner. During training, the model is repeatedly exposed to many small tasks so that it learns to adapt quickly to new classes.</p><p>In these tasks:</p><ul><li><strong>Support Set</strong> — a small labeled set of examples that tells the model, “these are the samples for each class.”</li><li><strong>Query Set</strong> — a separate set of unseen samples used to evaluate how well the model can classify new instances.</li></ul><p>The model constructs a feature representation from the support examples and then determines the closest class for each query sample, often using distance metrics such as Euclidean distance or cosine similarity.</p><p>👉 In simple terms:<br>Few-Shot Learning represents a shift from AI models that depend on large amounts of data to AI models that can learn quickly from very limited data.</p><p>In the next post, we will explore step by step how an FSL model is trained with such small datasets, how Support Sets and Query Sets are used in practice, and what the typical workflow looks like in research papers.</p><p>#Week01 #AI #MachineLearning #FewShotLearning #MetaLearning #ArtificialIntelligence #AIResearch #LearnAI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=957e2fa88a4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>