<?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 Shivam Ardeshna on Medium]]></title>
        <description><![CDATA[Stories by Shivam Ardeshna on Medium]]></description>
        <link>https://medium.com/@ardeshnashivam11?source=rss-488115c2bec3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1K4juaMVn3sA92XgWLfeTA.jpeg</url>
            <title>Stories by Shivam Ardeshna on Medium</title>
            <link>https://medium.com/@ardeshnashivam11?source=rss-488115c2bec3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:23:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ardeshnashivam11/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[Seeing is Believing: How Recommendation Systems Are Learning to See]]></title>
            <link>https://aiadvances.org/seeing-is-believing-how-recommendation-systems-are-learning-to-see-a60b233ebbc1?source=rss-488115c2bec3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a60b233ebbc1</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[becoming-human]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Shivam Ardeshna]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 12:58:38 GMT</pubDate>
            <atom:updated>2024-09-03T11:26:10.927Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>From Likes to Looks: How AI is Getting a Good Look at Your Preferences</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HfjNWGehQgD1tpy9" /></figure><p>The future of recommendation systems lies in their ability to process and understand images. This blog closely examines the technology behind visual recommendations and how it transforms industries from retail to social media.</p><blockquote>“A recommendation system is an AI-driven algorithm, often leveraging machine learning techniques, that analyzes large datasets to suggest relevant products or content to users, enhancing their overall experience.”</blockquote><p><strong>Data Gathering:</strong> Recommendation systems gather data from multiple sources, including user interactions (clicks, views, purchases), user profiles (demographics, preferences), and content data (item descriptions, tags). They also consider contextual factors like device type, location, and time, alongside social and collaborative inputs from friends and networks. These systems deliver highly personalized recommendations by analyzing this vast array of information, including transaction history and external data.</p><p><strong>Why We Need Recommendations?</strong></p><p>Recommendation systems are essential for enhancing personalized user experiences and driving business growth. They boost engagement and revenue across industries by delivering tailored suggestions. For major platforms, recommendations can contribute up to 30% of revenue, and a 1% improvement in recommendation quality can result in billions of dollars in additional income.</p><ul><li><strong>Boosting Retention and Sales:</strong> Personalized recommendations improve user loyalty by aligning with preferences, and they can increase sales by 10–50% through targeted upselling and cross-selling strategies.</li><li><strong>Shaping Habits and Efficiency:</strong> Accurate recommendations build customer habits and influence behavior, while also accelerating research by saving up to 80% of time spent searching for relevant information.</li><li><strong>Maximizing Value:</strong> E-commerce sites with large inventories use recommendations to suggest relevant products, enhancing cart value and streamlining the shopping experience.</li></ul><p>On average, an intelligent recommender system delivers a <a href="https://brandcdn.exacttarget.com/sites/exacttarget/files/deliverables/etmc-predictiveintelligencebenchmarkreport.pdf">22.66% lift in conversion rates</a> for web products.</p><p>Let’s delve into the intricate mechanisms and underlying technologies that drive these sophisticated tools.<br><a href="https://dl.acm.org/doi/pdf/10.1145/245108.245121"><strong><em>Recommender systems</em></strong></a> were first introduced in papers by <em>Paul Resnick and Hal R Varian. </em>These systems have evolved to become essential in various industries, from retail to entertainment, by leveraging data to deliver personalized recommendations. Let’s explore the different types of recommender systems and how they work.</p><h4><strong>Collaborative Filtering:</strong></h4><p>Collaborative Filtering (CF) is one of the most widely used techniques in recommendation systems. It operates on the principle that users who have shown similar preferences in the past will likely continue to share similar tastes in the future. <a href="https://www.researchgate.net/publication/200121027_Collaborative_Filtering_Recommender_Systems">CF</a> relies primarily on user behavior rather than detailed item data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*UJPdixo-ZUnPSxDHXymgBA.png" /></figure><p>Here, we explore a different organization of collaborative filtering algorithms: non-probabilistic algorithms and probabilistic algorithms.</p><h4>Non-Probabilistic Algorithms</h4><p>In the realm of collaborative filtering (CF), non-probabilistic algorithms are among the most widely recognized methods, with nearest-neighbor algorithms being particularly prominent. These algorithms can be categorized into two primary classes: user-based nearest neighbor and item-based nearest neighbor. Both classes aim to predict user preferences by finding similarities, either between users or between items, and making recommendations accordingly.</p><p><strong>User-Based Nearest Neighbor Algorithms:<br></strong>User-based nearest-neighbor algorithms focus on identifying users with similar preferences and behaviors. The <a href="https://journalofbigdata.springeropen.com/articles/10.1186/s40537-022-00592-5">core idea</a> is to recommend items to a target user that have been liked or rated highly by users with similar tastes. This method computes the similarity between users based on their historical ratings or interactions with items. The similarity is often measured using metrics such as cosine similarity, Pearson correlation, or Euclidean distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*kn4gHU2kK9IhY0t3Ebl3KQ.png" /></figure><p>The formula for calculating similarity between two users, <em>u</em> and <em>v</em>, based on their ratings R(<em>u</em>) and R(<em>v</em>), might look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*bZsDU08TzIOlWRQ3hk8QYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*ge0lDFb-o81e9Qx_XVa1QA.png" /></figure><p>Another method is Cosine similarity measures the cosine of the angle between two non-zero vectors in a multi-dimensional space. When applied to user-based collaborative filtering, it treats each user as a vector of ratings. The similarity between two users <em>u</em> and <em>v</em> is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*XvRIPFGtu7H1jwkiSfZcHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*58uOiQHacf9Ua2eKyD-IYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*e3D56BMt4PIr3nrqBTymwg.png" /></figure><p><strong>Item-Based Nearest Neighbor Algorithms:</strong></p><p>In the vast universe of recommendation systems, item-based nearest neighbor algorithms are like a well-connected friend who always knows what you’ll like next. Instead of trying to find people similar to you, this algorithm focuses on finding items similar to the ones you’ve already shown interest in. It’s as if, after enjoying a certain book, a well-read friend suggests another that matches its vibe perfectly.</p><p><strong>How Does It Work?<br></strong>Imagine walking into your favorite bookstore. Instead of asking the staff what everyone else is reading, you say, “I loved <em>The Great Gatsby</em>. What’s next?” The system scours the shelves, looking for books that share similar themes, styles, or author profiles with <em>The Great Gatsby</em>. This recommendation isn’t about what others enjoyed, but what the books themselves have in common.</p><p><strong>Let’s Break It Down:</strong></p><ul><li><strong>Similarity Calculation</strong>: Just as with user-based algorithms, similarity is key, but this time, the system calculates how alike two items are. For example, if users who buy <em>The Great Gatsby</em> also frequently buy <em>To Kill a Mockingbird</em>, the system sees a strong connection between these two books.</li><li><strong>Recommendation Process</strong>: When you rate or purchase an item, the algorithm identifies similar items based on past user interactions. This is particularly effective in scenarios where items share inherent characteristics, like genre, brand, or type.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*E-xQ1elcybn5z1CNHlOyFA.png" /></figure><p><strong>Scenario:<br></strong>Imagine we have a small dataset of user ratings for a set of movies. Our goal is to predict the rating that User 4 would give to “Movie C” using both user-based and item-based collaborative filtering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*rU8OsFi2Mm-ANOffXp6U7A.png" /></figure><ol><li><strong>User-Based Collaborative Filtering</strong><br><strong>Step 1: Calculate Similarity Between Users</strong> We calculate the similarity between User 4 and the other users using cosine similarity.<br><strong>Example Calculation (User 4 vs. User 1):</strong> For User 4 and User 1, considering only common items (Movies A and D):</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*LbGwwam-vQO7qlpBaGQQ3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*IfuXNhyWy0lfqBRuUiNQOA.png" /></figure><p><strong>Using Similarities:</strong></p><ul><li>Sim(4, 1) ≈ 0.89, User 1 rated Movie C as 1.</li><li>Sim(4, 2) ≈ 0.85, User 2 rated Movie C as 2.</li><li>Sim(4, 3) ≈ 0.79, User 3 rated Movie C as 4.</li></ul><p>Thus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*qMCUDVhsH52UFVPyJXrpgQ.png" /></figure><p><strong>2. Item-Based Collaborative Filtering<br>Step 1: Calculate Similarity Between Items</strong> We calculate the similarity between “Movie C” and the other movies using cosine similarity.<br><strong>Example Calculation (Movie C vs. Movie A):</strong> For Movie C and Movie A, considering all users who have rated both movies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*8uKyaBVXXTzp4dVnWIIt9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*kPM83FUddBmUpKXRBPTPAg.png" /></figure><p><strong>Using Similarities:</strong></p><ul><li>Sim(C, A) ≈ 0.91, User 4 rated Movie A as 4.</li><li>Sim(C, D) ≈ 0.85, User 4 rated Movie D as 3.</li></ul><p>Thus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*Jtr4tC5ysQu9ZypL6iGoqA.png" /></figure><p><strong>Summary of Predictions:<br>User-based CF</strong> predicts that User 4 would rate Movie C as approximately <strong>2.20</strong>.<br><strong>Item-based CF</strong> predicts that User 4 would rate Movie C as approximately <strong>3.50</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*6Ef18E2_O7j4WalPUssdtw.png" /></figure><h4><strong>Content-based filtering:</strong></h4><p>Content-based filtering is like having a friend who knows exactly what you like and always recommends things that match your taste. This technique works by analyzing the content or characteristics of the items themselves and matching them with the user’s preferences. Let’s dive into how this works and why it’s so powerful.</p><p><strong>How It Works: The Secret Sauce<br></strong>the essence lies in analyzing item features to match user preferences. For example, the paper “<a href="https://www.researchgate.net/publication/351863177_Content-based_Music_Recommendation_System">A Content-Based Filtering Algorithm for Music Recommendation</a>” demonstrates how a music recommendation system uses attributes like genre and tempo to tailor suggestions. If a user enjoys energetic pop from the 80s, the system identifies similar tracks by comparing their features to the user’s profile, ensuring recommendations align with their established tastes.</p><p><strong>Scenario:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*LhfEwO0bZI6HFFnCoyp2iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*LRDJmoMf0YlQNszC2Ab3qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*6iTksRXnbpqgxkfx3NZ1oQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*d17vSIb9QB2ICkjBE3lgdg.png" /></figure><p><strong>Summary of Similarity Scores</strong></p><ul><li><strong>Movie A Similarity:</strong> 0.32</li><li><strong>Movie B Similarity:</strong> 0.49</li><li><strong>Movie C Similarity:</strong> 0.32</li></ul><p>Based on the cosine similarity scores, <strong>Movie B</strong> has the highest similarity with the user profile and would be recommended first, as it aligns most closely with the user’s preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Vyg4GfiST_kr04Moxv7wWw.png" /></figure><h4>Challenges and Limitations in Recommendation Systems</h4><p><strong>The Cold Start Problem: A Creative Perspective</strong></p><p>Picture a new café opening in town. Enthusiastic about its unique offerings, the café owner is eager to attract customers, but the challenge is that no one has yet tasted or reviewed the coffee. The owner has no clue which drinks might become customer favorites. This is akin to the <a href="https://www.mdpi.com/1999-4893/16/4/182"><strong>cold start problem</strong></a> in recommendation systems.</p><p><strong>Cold Start</strong> occurs when a recommendation system encounters difficulty due to a lack of data for new users or items. It’s like trying to recommend a book to a reader who just joined a platform but hasn’t yet reviewed or rated any books. Similarly, if a new item, such as a movie or product, is introduced to a platform without any prior ratings or interactions, the system struggles to make meaningful recommendations.</p><p><strong>Example:</strong> Consider a new movie that has just been added to a streaming service. With no user ratings or reviews available, the system cannot assess how well this movie aligns with user preferences. Imagine recommending this movie to a user who loves action films but has never interacted with the new release. The system is left guessing, much like our café owner trying to predict which coffee will become popular without any customer feedback.</p><p><strong>Serendipity: The Quest for Unexpected Discoveries</strong></p><p>Serendipity in recommendation systems is like finding a hidden gem in a treasure hunt. It’s about surprising users with novel suggestions that go beyond their usual preferences. While traditional systems might only recommend similar items, a touch of luck can introduce users to unexpected yet delightful finds.</p><p><strong>Example:</strong> If a user loves action movies, instead of just suggesting more action films, a recommendation system could suggest a highly-rated thriller that aligns with their broader interests, adding an element of surprise and enrichment.</p><p><strong>Ethical Considerations: Navigating Privacy and Bias</strong></p><p>Recommendation systems raise ethical issues like <strong>privacy</strong> and <strong>bias</strong>. Privacy concerns stem from the extensive data collection required for accurate recommendations, which can make users uncomfortable about how their data is used. Bias occurs when systems favor certain products or viewpoints, limiting diversity and potentially reinforcing existing inequalities.</p><p><strong>Example:</strong> If the system prefers larger companies over smaller startups in job recommendations, it might restrict opportunities for users interested in niche roles. Users may also worry about how their job search data is handled and shared.</p><p>Despite challenges such as the cold start problem, serendipity, and ethical concerns, ongoing advancements in technology and data science are continuously refining these systems. Innovations in algorithm design, data processing, and user experience are driving improvements in recommendation accuracy and relevance.</p><p>Here are some links with credible sources and statistics about the impact and usage of recommendation systems:</p><p><strong>Amazon’s Recommendation Engine</strong>:</p><ul><li><a href="https://www.mckinsey.com/capabilities/growth-marketing-and-sales/our-insights/the-value-of-getting-personalization-right-or-wrong-is-multiplying"><strong>McKinsey Report on E-commerce</strong></a>: This report discusses the significant impact of recommendation systems on e-commerce platforms, including Amazon.</li></ul><p><strong>Netflix’s Recommendation Algorithms</strong>:</p><ul><li><strong>Journal of Media Economics Study</strong>: This study highlights how <a href="https://web.archive.org/web/20220801212715id_/https://aisel.aisnet.org/cgi/viewcontent.cgi?article=1010&amp;context=icis2020">Netflix’s</a> recommendation algorithms contribute to increased viewing time and engagement.</li></ul><p><strong>Facebook’s News Feed Algorithm</strong>:</p><ul><li><a href="https://transparency.meta.com/features/explaining-ranking/fb-feed-recommendations/"><strong>Facebook’s Transparency Report</strong></a>: This document provides insights into how Facebook’s recommendation algorithms influence the content seen by users.</li></ul><blockquote>As we wrap up our exploration of recommendation systems, here’s a light-hearted challenge for you: If a recommendation system were a superhero, what would its superpower be? And more importantly, what would its kryptonite look like? Share your thoughts and let’s have some fun with how our digital sidekicks might save or sabotage our browsing adventures. Ready, set, recommend!</blockquote><p>Recommendation systems need improved handling of new or sparse data to enhance accuracy and relevance. They also lack effective mechanisms for ensuring diversity and addressing biases, which can limit the breadth and fairness of recommendations.</p><p><em>Thanks for reading this article! Share with me your reviews/ideas. If you have any doubts or face an error, let me know in the comments. Don’t forget to give me a clap👏 :)</em></p><p><strong>References<br>[1]</strong><a href="https://brandcdn.exacttarget.com/sites/exacttarget/files/deliverables/etmc-predictiveintelligencebenchmarkreport.pdf">https://brandcdn.exacttarget.com/sites/exacttarget/files/deliverables/etmc-predictiveintelligencebenchmarkreport.pdf</a><br>[2]Paul Resnick and Hal R. Varian. 1997. Recommender systems. Commun. ACM 40, 3 (March 1997), 56–58. <a href="https://doi.org/10.1145/245108.245121">https://doi.org/10.1145/245108.245121</a><br>[3]Schafer, Ben &amp; J, Ben &amp; Frankowski, Dan &amp; Dan, &amp; Herlocker, &amp; Jon, &amp; Shilad, &amp; Sen, Shilad. (2007). Collaborative Filtering Recommender Systems.<br>[4]Roy, Deepjyoti and Mala Dutta. “A systematic review and research perspective on recommender systems.” <em>Journal of Big Data</em> 9 (2022): n. pag.<br>[5]Niyazov, Aldiyar &amp; Mikhailova, Elena &amp; Egorova, Olga. (2021). Content-based Music Recommendation System. Proceedings of the XXth Conference of Open Innovations Association FRUCT. 29. 274–279. 10.23919/FRUCT52173.2021.9435533.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a60b233ebbc1" width="1" height="1" alt=""><hr><p><a href="https://aiadvances.org/seeing-is-believing-how-recommendation-systems-are-learning-to-see-a60b233ebbc1">Seeing is Believing: How Recommendation Systems Are Learning to See</a> was originally published in <a href="https://aiadvances.org/">AI Advances</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vision Transformers: Demystifying the Latest Breakthrough in Image Recognition]]></title>
            <link>https://medium.com/the-modern-scientist/vision-transformers-demystifying-the-latest-breakthrough-in-image-recognition-e886b3d1f8a8?source=rss-488115c2bec3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e886b3d1f8a8</guid>
            <category><![CDATA[vision-transformer]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[transformer-model]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Shivam Ardeshna]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 17:57:55 GMT</pubDate>
            <atom:updated>2024-09-03T12:17:22.562Z</atom:updated>
            <content:encoded><![CDATA[<p>ViTamin Your Vision: A Powerful Dose of Vision Transformer Insights</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNvExAd3JWgq5QcwUFap0A.jpeg" /><figcaption>Vision Comes with Pieces</figcaption></figure><p>Explore the revolutionary landscape of <strong>Vision Transformers (ViTs)</strong> in computer vision, blending attention mechanisms with transformer scalability. This blog unravels ViT architecture, showcases strengths, and explores applications, providing insights into their transformative impact on image recognition. Join the journey where <strong>attention</strong> meets vision, revolutionizing the computer vision landscape.</p><p>Transformer architectures introduced in the <a href="https://arxiv.org/pdf/1706.03762.pdf"><strong>ATTENTION IS ALL YOU NEED</strong></a> paper have greatly impacted the NLP domain. However, its applications in the Computer Vision domain have been limited. In 2021, a research team at Google introduced the paper <a href="https://arxiv.org/pdf/2010.11929v2.pdf"><strong>AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE (2021)</strong></a>, which applied the Transformer encoder architecture to the image recognition(classification) task.</p><p>There is one more paper introduced by Meta AI and groups <a href="https://arxiv.org/pdf/2203.09795.pdf"><strong>Three things everyone should know about Vision Transformers</strong></a>, They discussed how the ViT has achieved state-of-the-art results.</p><p><strong>Vision Transformer vs CNN:</strong></p><p>Architectural Foundation:</p><ul><li>CNN: Built on convolutional layers that detect patterns using local receptive fields.</li><li>ViTs: Utilize transformer architectures, incorporating self-attention mechanisms to capture global dependencies in images.</li></ul><p>Image Representation:</p><ul><li>CNN: Process images in fixed-size patches, limiting their ability to capture long-range dependencies.</li><li>ViTs: Consider the entire image as a sequence of tokens, enabling global context understanding through self-attention.</li></ul><p>Interpretable Representations:</p><ul><li>CNN: Features are less interpretable due to hierarchical layers of convolutions.</li><li>ViTs: Offer more interpretable representations as each token corresponds to a specific region of the image.</li></ul><p>State-of-the-Art Performance:</p><ul><li>CNN: Historically dominant for image-related tasks.</li><li>ViTs: Achieving state-of-the-art results on various benchmarks, showcasing their efficacy in challenging scenarios.</li></ul><blockquote>“State-of-the-art refers to the highest level of performance achieved in a particular field, often representing the most advanced and cutting-edge technology or methodologies at a given point in time.”</blockquote><p><strong>How Does Vision Transformer Work?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*SoXHGxDPUqFQHFbJKYoVLg.png" /></figure><p>The above diagram is the Architecture of a Vision Transformer</p><p>ViT is divided into 3 different components:</p><ol><li>Embedding(positional + patch)</li><li>Transformer Encoder</li><li>Multi-layer Perceptron Head</li></ol><p><strong>1: Embedding</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkNcNOeyqWDSa6YyJN6tyg.png" /><figcaption>patches of an image</figcaption></figure><p>Vision Transformers (ViT) revolutionize image processing through patch-based segmentation, converting <strong>non-overlapping</strong> patches into sequential tokens for holistic feature extraction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Gi32je0aTzQGI23G6D6PPQ.png" /></figure><p>The most important part of this paper is how to break down the image into patches. An image is represented as</p><p>3D Image (X) <strong>∈ </strong>resolution R HxWxC</p><p>reshape the 3D image into flattened 2D patches</p><p>Patch Image ( Xp) <strong>∈ </strong>R Nx(P² . C)</p><p>Where sequence length N = H . W / P2 and (P, P) is the resolution of each image patch.</p><p>Each patch is a D-dimension vector with a trainable linear projection.</p><blockquote>“Resolution refers to the number of pixels per unit of area in a digital image, determining its clarity and detail. It is commonly expressed as width x height pixels in digital images, influencing visual quality and sharpness.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*FqCYy6Jf77KgCh1Jfady6Q.png" /><figcaption>Simple Representation of patches</figcaption></figure><p>In this vector space, similar tokens share a similar location. Therefore, when we calculate the <strong>dot product</strong> between token embeddings (inside the attention mechanism), we return a high <em>alignment</em> score when embeddings are aligned in vector space. When embeddings are <em>not aligned</em>, we produce a low alignment score.</p><figure><img alt="This equation shows the dot product between every features and show attention between them, and after comparision high attention will will be selected" src="https://cdn-images-1.medium.com/max/356/1*1gkkBmFKUn-x_q86lGx2mg.png" /><figcaption>Dot Product for alignment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*DhX5gsq_FxfuofKkictk7A.png" /><figcaption>attention</figcaption></figure><p>Attention requires the comparison of every input to all other inputs. If we perform that on a <em>224x224</em> pixel image, we must perform 224⁴ (2.5<em>E⁹</em>) comparisons. That’s for a single attention layer, of which transformers contain several.</p><h4><strong>Linear Projection</strong></h4><p>After building the image patches, a <em>linear projection</em> layer is used to map the image patch <em>“arrays”</em> to <em>patch embedding “vectors”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*r7rgNJGvBhiJq3k1qdA1ww.png" /></figure><p>The linear projection layer attempts to transform arrays into vectors while maintaining their “physical dimensions”. Meaning similar image patches should be mapped to similar patch embeddings.</p><h4><strong>Learnable Embedding</strong></h4><p>Transformers, notably with <strong>BERT</strong> models, introduced a distinctive element known as the <strong>[CLS]</strong> (or “classification”) token. This special token is added at the beginning of each input sentence processed by <strong>BERT</strong>, contributing to the model’s understanding and classification tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*5OP-elFotnCP5Ft7GC0KMw.png" /></figure><p>The [CLS] token transforms a token embedding and traverses multiple encoding layers. The uniqueness of [CLS] embeddings lies in two aspects. Firstly, it doesn’t represent an actual token initially, serving as a starting point for each sentence. Secondly, the ultimate output from the [CLS] embedding acts as input for a classification head during pretraining.</p><p>Employing a <strong>“blank slate”</strong> token as the exclusive input for a classification head prompts the transformer to grasp the skill of encoding a “general representation” of the entire sentence into that embedding. This is crucial for the model to make accurate predictions with classifiers.</p><p>ViT adopts a similar approach by incorporating a <strong>“learnable embedding”,</strong> mirroring the [CLS] token concept used in BERT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*oviCFQChdBlUM1MN2DjgMQ.png" /><figcaption>ViT process with the learnable class embedding highlight (left).</figcaption></figure><h4>Positional Embedding</h4><p>Transformers lack an inherent mechanism to consider the inherent “order” of token or patch embeddings, despite the vital role order plays. In language, the sequence of words significantly influences their meaning.</p><p>The same holds for images. When faced with a disordered jigsaw puzzle, accurately predicting the complete picture becomes challenging. Transformers face a similar challenge, requiring a method to enable the model to discern the order or position of puzzle pieces.</p><p>To address this, positional embeddings come into play. In ViT, these positional embeddings are vectors learned during pretraining, sharing the same dimensionality as patch embeddings.</p><p>After generating patch embeddings and adding the “class” embedding, they are summed with positional embeddings. These positional embeddings evolve during training, converging into vector spaces where they exhibit high similarity to neighboring position embeddings, especially those in the same column and row.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_md47ooXIQiFc3DzoGZsfg.png" /></figure><p>Position embeddings are added to the patch embeddings to retain positional information. In Computer Vision, these embeddings can represent either the position of a feature in a 1-dimensional flattened sequence or they can represent a 2-dimensional position of a feature.</p><p>1-dimensional: a sequence of patches, works better</p><p>2-dimensional: X-embedding and Y-embedding</p><p>Relative: Define the relative distance of all possible pairs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*Mcz40XJxsIBntiutplUiJQ.png" /><figcaption>Position Embedding formula as per attention mechanism</figcaption></figure><blockquote>“For Understanding the Positional Embedding for Transformers refer <a href="https://machinelearningmastery.com/a-gentle-introduction-to-positional-encoding-in-transformer-models-part-1/">machinelearningmastery</a> or a video explaining Relative distance <a href="https://www.youtube.com/watch?v=dichIcUZfOw">Visual Guide to Transformer Neural Networks — (Part 1) Position Embeddings</a>”</blockquote><p>After adding the positional embeddings, our <em>patch embeddings</em> are complete. From here, we pass the embeddings to the ViT model, which processes them as a typical transformer model.</p><h4><strong>2. Transformer Encoder</strong></h4><p>After Embedding the Images the transformer will now work, for detailed information on transformers refer <a href="https://jalammar.github.io/illustrated-transformer/">The Illustrated Transformer</a> Blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGsIs0vn4W713uQTayVJdg.png" /></figure><p>This is the basic structure of a transformer containing two main components encode &amp; decoder.</p><h4>3. MLP</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*G8iv3Yqqt4ftbrlaiY0X9w.png" /></figure><p>MLP is a two-layer classification network with GELU (Gaussian Error Linear Unit) at the end. The final MLP block also called the MLP head, is used as an output of the transformer. An application of softmax on this output can provide classification labels (i.e. if the application is Image Classification).</p><p>Here are some of the key benefits of ViTs:</p><ul><li>They can capture long-range dependencies in images. This is because they use a self-attention mechanism, which allows them to attend to any part of the image when processing another part. CNNs, on the other hand, are limited to local receptive fields.</li><li>They are more interpretable than CNNs. This is because each token in a ViT corresponds to a specific region of the image. In contrast, the features learned by CNNs are often difficult to interpret.</li><li>They can be scaled to handle large datasets and model sizes. This is because they are based on a parallel processing architecture.</li></ul><h4>Summary</h4><p>ViT’s arrival has shaken the image recognition scene. Unlike traditional CNNs with their limited gaze, ViTs see the whole picture. Their superpower lies in “attention,” allowing them to connect any image part, revealing hidden relationships invisible to CNNs. This leads to a clearer understanding, as each ViT token maps to a specific image region, unlike the mysterious features of a CNN. And finally, ViTs thrive on big data and complex models, scaling up effortlessly to tackle ambitious tasks. With their powerful attention, clear vision, and impressive scalability, ViTs are undeniably transforming the way we see and understand images.</p><p>I hope this article is helpful and easy to follow. And Keep Learning and Keep Hustling!!!</p><blockquote>“For code implementation refer <a href="https://github.com/google-research/vision_transformer">vision_transformer</a> Repo”.</blockquote><p><em>Thanks for reading this article! Share with me your reviews/ideas. If you have any doubts or face an error, let me know in the comments. Don’t forget to give me a clap👏 :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e886b3d1f8a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-modern-scientist/vision-transformers-demystifying-the-latest-breakthrough-in-image-recognition-e886b3d1f8a8">Vision Transformers: Demystifying the Latest Breakthrough in Image Recognition</a> was originally published in <a href="https://medium.com/the-modern-scientist">The Modern Scientist</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>