<?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 Sahasra_7k on Medium]]></title>
        <description><![CDATA[Stories by Sahasra_7k on Medium]]></description>
        <link>https://medium.com/@sahasra007k?source=rss-162822c2bcae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3YUIZJG0AAtp8IfvVJ_o8Q.jpeg</url>
            <title>Stories by Sahasra_7k on Medium</title>
            <link>https://medium.com/@sahasra007k?source=rss-162822c2bcae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:16:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sahasra007k/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[Teaching Robots in Shades of Gray]]></title>
            <link>https://medium.com/@sahasra007k/teaching-robots-in-shades-of-gray-bf88248abd68?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf88248abd68</guid>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[pybullet]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 11:03:59 GMT</pubDate>
            <atom:updated>2025-08-21T11:03:59.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Fuzzy Logic + Reinforcement Learning</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*VMGGHounNKwdoQV88j4lBQ.png" /></figure><p>When teaching robots, the world rarely looks black and white.<br> A gripper isn’t just “open” or “closed” — sometimes it’s <em>almost holding</em> an object. A mobile robot isn’t just “near” or “far” from an obstacle — it might be <em>kinda close</em>.</p><p>This is where <strong>fuzzy logic</strong>, the classic master of gray zones, meets <strong>reinforcement learning (RL)</strong>, the modern champion of trial-and-error. Together, they offer a pathway for robots that not only learn from experience but also reason with intuition.</p><blockquote><strong>Think of a washing machine:</strong> it doesn’t just decide <em>“dirty” or “clean”</em>.<br> With fuzzy logic, it says: <em>“Clothes are 70% dirty, water level is 40% full, so spin gently for 15 more minutes.”</em></blockquote><blockquote>That’s the magic — decisions in <strong>shades of gray</strong> instead of rigid yes/no rules, just like how the cat is wondering if the wash is done <em>or almost done</em>. 🐱</blockquote><h4><strong>Why Reinforcement Learning, Why Now?</strong></h4><p>I’ve always been fascinated by the bridge between theory and application — equations turning into actuators, models moving machines. Recently, I started diving into the basics of <strong>reinforcement learning (RL)</strong> and applying them in <strong>robotic simulations</strong>. My current work revolves around <strong>training RL agents inside simulators</strong> like <strong>PyBullet</strong> and <strong>NVIDIA Isaac Sim</strong>, with a strong focus on bridging the notorious <strong>Sim2Real gap</strong>.</p><p>This shift to RL wasn’t random — it came from realizing that many robotic problems, from grasping objects to adaptive motion, don’t have fixed solutions. RL, especially when paired with fuzzy logic and mechatronics insights, offers a path to handle uncertainty while keeping physics and engineering constraints in the loop.</p><h3>Why Fuzzy Logic Still Matters</h3><p>Fuzzy logic works with <strong>degrees of truth</strong>, unlike binary logic which insists everything must be 0 or 1.</p><h3>Mobile Robot Navigation</h3><ul><li><strong>Classical logic:</strong> “Obstacle detected → Turn left” or “No obstacle → Go straight.”</li><li><strong>Fuzzy logic:</strong> “If obstacle is <strong>near (80%)</strong>, turn left <strong>sharply (70°)</strong>; if obstacle is <strong>moderately close (40%)</strong>, turn left <strong>gently (20°)</strong>.”</li></ul><p>Instead of rigid yes/no behavior, the robot <em>grades</em> its decisions, leading to smoother navigation.</p><p>In robotics, fuzzy controllers shine because they capture <strong>human-like reasoning in uncertain conditions</strong>, something pure equations often miss.</p><h3>Reinforcement Learning’s Superpower (and Weakness)</h3><p>Reinforcement Learning (RL) has taken center stage in AI.<br> It learns by <strong>interacting with the environment</strong>, receiving rewards (positive or negative), and optimizing its strategy over time.</p><ul><li>Robot moves an arm closer to an object → small positive reward.</li><li>Drops the object → penalty.</li><li>Successfully places it → big reward.</li></ul><p>The problem? RL is <strong>data-hungry and brittle</strong> in noisy environments. It struggles when rewards are sparse or when mistakes are too harsh. That’s where fuzzy logic offers a helping hand.</p><h3>The Hybrid Approach: Fuzzy + RL</h3><p>By blending fuzzy rules with reinforcement learning, we unlock new strengths:</p><ol><li><strong>Fuzzy Reward Shaping</strong><br> Instead of punishing everything that’s “wrong,” fuzzy logic gives <em>partial credit</em>.<br> <em>Example: If a robot almost grasps an object, reward it 60% instead of 0. This smoothens the learning curve.</em></li><li><strong>Fuzzy State Representation</strong><br> States aren’t strictly “aligned” or “not aligned.” They can be <em>partially aligned,</em> letting RL perceive the world in gradients.</li><li><strong>Fuzzy Policy Initialization</strong><br> We can kickstart RL with fuzzy controllers (expert knowledge), then let RL fine-tune from experience.<br> This reduces training time and avoids dangerous random explorations.</li></ol><h3>From Simulation to Reality</h3><p>In <strong>simulation</strong> (PyBullet, Isaac Lab, Mujoco), fuzzy logic accelerates training by providing smoother feedback.<br> In <strong>real robots</strong>, fuzzy controllers add <strong>safety constraints</strong>, preventing jerky or unsafe actions during exploration.</p><p>This makes the hybrid approach not only efficient but also safer — a key factor in industrial robotics.</p><h3>Applications That Excite Me</h3><ul><li><strong>Adaptive Grasping</strong> — Fuzzy rules for grip pressure, RL for motion strategy.</li><li><strong>Navigation</strong> — Fuzzy sets for obstacle distance, RL for efficient path planning.</li><li><strong>Industrial Robots</strong> — Fuzzy safety zones with RL precision for assembly tasks.</li></ul><p>In all cases, fuzzy logic adds <strong>intuition</strong>, while RL brings <strong>adaptability</strong>.</p><blockquote>As someone who straddles <strong>mechatronics and AI</strong>, I see fuzzy logic as the teacher’s intuition and RL as the student’s experience.</blockquote><blockquote>Alone, each has limits. Together, they give us robots that <strong>learn like machines but reason more like humans</strong>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf88248abd68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Enigmatic World of Fractals]]></title>
            <link>https://medium.com/@sahasra007k/the-enigmatic-world-of-fractals-59fea0a20a36?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/59fea0a20a36</guid>
            <category><![CDATA[fractals]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Wed, 05 Mar 2025 09:37:04 GMT</pubDate>
            <atom:updated>2025-03-05T09:37:04.291Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fractals are a paradox. Amazingly simple, yet infinitely complex. New, but older than dirt. What are fractals? Where did they come from? Why should I care?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/185/1*MnUzl3xc7thLqe-q3O5qGQ.gif" /><figcaption>A fractal is a never-ending pattern</figcaption></figure><p>Fractals are not only pervasive and multifaceted in nature but also form the foundation of complex lines like coastlines and branching trees. In technology, they are integral to computer systems architecture, 3D modeling, and data management, influencing mathematical theories and shaping computer-generated fractal shapes and patterns. Beyond their scientific and technological applications, fractals resonate within the human psyche, influencing art and sound production, and extending surprisingly even into legal frameworks.</p><h3>Fractal Terminology and Origins</h3><p>Unconventional 20th-century mathematician Benoit Mandelbrot created the term “fractal” from the Latin word “fractus” (meaning irregular or fragmented) in 1975. You can find this type of irregular and fragmented geometric shape or pattern all around.</p><p>Fractals are not just fascinating mathematical oddities; they are deeply rooted in the natural and technological worlds.</p><ul><li><strong>Self-Similar Structures</strong>: At the heart of fractals lies the concept of self-similarity. This principle is observable in nature, where a fern’s frond mirrors the shape of its smaller parts, and each branch resembles the whole. This recursive pattern is created through simple mathematical equations repeated over and over, a process known as iteration.</li><li><strong>Recursive and Infinite Complexity</strong>: Fractals are recursive, meaning their intricate pattern repeats indefinitely, regardless of the scale. This is similar to standing between two mirrors, seeing the repeating image extending infinitely. The fractal dimensions of these patterns, often non-integer, quantify how they fill space, transcending traditional three-dimensional geometry.</li></ul><h3><strong>Historical Perspectives: Beyond Mandelbrot</strong></h3><p>While Benoit Mandelbrot’s work in the 1970s popularized fractals with the Mandelbrot Set, the intuitive use of self-similarity predates him, evident in art and nature. Notable figures like the Japanese artist Katsushika Hokusai and Leonardo da Vinci captured fractal-like patterns in their work. Earlier mathematicians like Gaston Julia and Helge von Koch also explored these complex geometries, paving the way for the formal development of fractal geometry.</p><h3><strong>Practical Applications of Fractals</strong></h3><p>Fractals’ applications are extensive:</p><ul><li><strong>Computer Graphics</strong>: In 1978, Loren Carpenter used fractals to simulate realistic mountain landscapes for computer graphics, a technique now fundamental in CGI technology.</li><li><strong>Telecommunications</strong>: Nathan Cohen innovated compact fractal antennas in the 1990s, now used in mobile phones to maximize space and reception.</li><li><strong>Environmental and Medical Sciences</strong>: Fractals help model complex systems such as weather patterns and biological structures like blood vessels, playing a crucial role in both fields.</li></ul><h3><strong>Chaos Theory and Fractals</strong></h3><p>Chaos theory, which explores the unpredictable and nonlinear aspects of the world, often uses fractal mathematics to describe systems like weather or stock markets that are inherently difficult to predict or control. This theory teaches us to expect the unexpected and recognize the underlying order in apparent randomness.</p><ul><li><strong>The Butterfly Effect</strong> and <strong>Unpredictability</strong>: Small changes can have significant impacts, making long-term predictions unreliable.</li><li><strong>Order and Disorder</strong>: Chaos is not merely disorder but involves surprising transitions between order and disorder.</li><li><strong>Mixing and Feedback</strong>: Demonstrated in systems like stock markets where investor reactions can cause prices to fluctuate unpredictably.</li></ul><p>Fractals, with their infinitely complex, self-similar patterns, are seen in natural settings like rivers and coastlines and are instrumental in understanding and navigating the chaotic systems in which they appear.<br>They bridge the gap between theoretical mathematics and practical application, illustrating the profound complexity of both natural and human-made systems. They challenge our traditional understanding of dimensions and patterns, providing a richer, more interconnected view of the world. As we continue to explore fractals, we deepen our understanding of the universe’s complexities, finding beauty and order in what seems like chaos.</p><blockquote>“As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality”</blockquote><h3>The Fusion of Fractal Geometry with Deep Neural Networks: A Mathematical Perspective</h3><p>In the realm of deep learning, fractal mathematics extends beyond theoretical musings, offering practical implementations in neural network architectures. The innovative concept of FractalNet introduces a fractal-based design to construct deep neural networks without the reliance on residual learning, commonly employed in traditional architectures like ResNets. This approach leverages the self-similar nature of fractals to create networks with inherent depth and complexity that facilitate robust learning processes.</p><h4>The FractalNet Architecture</h4><p>Uses a recursively repeating architectural pattern, akin to a fractal, to form a network with multiple paths of varying lengths. This design ensures that learning is distributed across different scales and depths, simplifying the training process. Here, deep supervision emerges naturally as each layer is directly or indirectly connected to the output, allowing gradients to flow smoothly and effectively mitigating the vanishing gradient problem associated with deeper networks.</p><p>The mathematical formulation of FractalNet can be expressed as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*VmyWg0bXKb4Ce6qi2VCFPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXVjs6uBr-S523lyZeEKYA.png" /></figure><p>The equation describes how each new layer in the FractalNet is formed by taking the output of applying the network at the current depth <em>C</em> to itself, then combining this output with the result of a convolutional operation on <em>x</em>. The combination (likely through addition or concatenation) is processed through a function <em>r, </em>which could modify or normalize its inputs to ensure stability and promote effective learning.</p><h4>Drop-path Regularization</h4><p>Moreover, FractalNet introduces “drop-path” regularization, an innovative technique enhancing generalization by randomly disabling certain paths during training. This method, similar to dropout but tailored for fractal structures, encourages the network to develop redundant paths to maintain performance, even when parts of the network are disabled:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*VS__VjhPr8EfkWgMrzuB4Q.png" /></figure><p>This probability ensures that each path within the network can independently contribute to the final output, enhancing the network’s ability to generalize from training to unseen data.</p><h4>Exploring Mandelbrot’s Set in Neural Networks</h4><p>On another frontier, the exploration of Mandelbrot’s set as an activation function in neural networks presents an intriguing potential. While direct implementation remains largely theoretical, the concept reflects a broader interest in integrating complex mathematical structures to improve neural network capabilities. Potential activation functions derived from Mandelbrot’s set could take the form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*53a6oA7VPnmjcjF58kpP_Q.png" /></figure><p>where <em>z</em> and <em>c</em> are complex numbers. This recursive function is at the heart of Mandelbrot’s set and could inspire nonlinear activation functions that handle complex patterns and dynamics in data, akin to the chaotic patterns described by fractal geometry.</p><h3>Finally,</h3><p>The convergence of fractal design principles with neural network architectures symbolizes a significant step forward in AI development. FractalNet, with its deep supervision and modular construction, alongside the potential use of fractal-based activation functions, demonstrates that fractal geometry could indeed play a crucial role in shaping the future of neural networks. This fusion not only enhances model depth and efficiency but also opens new avenues for creating robust and adaptive AI systems.</p><p><a href="https://arxiv.org/pdf/1605.07648v4">References</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59fea0a20a36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Secrets of Vectors: The Magic of Dot and Cross Products]]></title>
            <link>https://medium.com/@sahasra007k/unlocking-the-secrets-of-vectors-the-magic-of-dot-and-cross-products-8b64125230a4?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b64125230a4</guid>
            <category><![CDATA[dot-product]]></category>
            <category><![CDATA[cross-product]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 09:42:28 GMT</pubDate>
            <atom:updated>2025-03-04T05:58:14.626Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Journey into the Heart of Vectors</h4><p><em>Imagine vectors as arrows flying through space, each pointing from one destination to another. These arrows don’t just float aimlessly; they carry with them the secrets of direction and magnitude, essential to everything from video games to rocket science. This post delves into two magical operations — dot and cross products — that reveal the hidden interactions between vectors.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*AeZq9VtSeLA8NXoAPMAaHQ.gif" /><figcaption>Dot product between two vectors</figcaption></figure><h3>1. Dot Product: The Silent Whisper of Alignment</h3><h4>Whispering Numbers: How Vectors Talk to Each Other</h4><p>The dot product listens quietly to the whispers between vectors, measuring how much one vector echoes along the line of another. It’s a subtle conversation, resulting in a single number that reveals whether two vectors share the same path.</p><p><strong>Real-World Drama</strong>: In the world of sports, imagine a quarterback throwing a football — the dot product calculates how much of that throw is directed straight towards the touchdown line, influencing the ball’s effective movement and the game’s outcome.</p><h4>Navigating the City: A Tale of Two Streets</h4><p>Picture a bustling city with two parallel streets. The traffic flow on each street tells a story of alignment, similar to the dot product. When the traffic moves smoothly and in sync, the dot product peaks, signaling perfect harmony.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*IB6ll5IqZWmBMUQc8GCrcg.gif" /><figcaption>cross product between two vectors</figcaption></figure><h3>2. Cross Product: The Dance of Dimensions</h3><h4>Crafting Space with a Twist</h4><p>While the dot product whispers, the cross product shouts, creating a new vector that leaps out of the plane, defiant and perpendicular. This vector is not just any direction — it’s a bold declaration of new possibilities, defining the very essence of 3D environments.</p><p><strong>Art of Engineering</strong>: Consider a crane at a construction site, swinging a steel beam into place. The cross product dictates the beam’s swinging path, ensuring it moves precisely within the desired plane, clear of obstacles.</p><h4>Intersecting Lives: The Story of Crossroads</h4><p>Imagine a vibrant intersection where two roads meet, each road a vector. The cross product is like a traffic light that guides a new flow of movement directly upwards, creating order and predicting the dynamic interplay of vehicles.</p><h3>3. Beyond the 3D: Tensors and the Dance in Higher Dimensions</h3><h4>The Orchestra of Elements: Conducting Complex Data</h4><p>In the quantum leaps from lines and planes to realms of higher dimensions, tensors take the stage. They are like conductors in an orchestra, where each instrument’s note (data point) plays in harmony to produce symphonies of insights, extending the principles of dot and cross products into vast, multidimensional datasets.</p><p><strong>Innovation in AI</strong>: In artificial intelligence, tensors help teach machines to perceive the world, analyzing countless dimensions of data to recognize patterns from speech to images, much like understanding the nuances of a complex musical composition.</p><h3>4. The Critical Role of Dot and Cross Products in Transformer Architectures</h3><h4>Fundamental Building Blocks of Self-Attention</h4><p><strong>Dot Products: Simplifying Complexity</strong>: At its core, the self-attention mechanism of transformer models relies on dot products to compute attention scores. These scores determine how much each part of the input should influence other parts. For example, when a transformer processes a sentence, the dot product is used to measure the influence of each word on every other word, thereby capturing their contextual relationships. The elegance of the dot product lies in its ability to distill complex relationships into a single scalar, which quantifies how much attention one vector (word) should pay to another.</p><p><strong>Cross Products: Envisioning New Directions</strong>: While not a direct component of standard transformer architecture, the cross product concept helps in understanding possible extensions or theoretical models where understanding orientation and directionality between features could be beneficial. For example, in tasks involving spatial reasoning or 3D data processing, envisioning how cross products might be used to determine the relationships between data points can inspire new neural network designs that mimic these mathematical properties.</p><h4>Extending Einstein Notation to Transformer Math</h4><p>By applying Einstein notation to these vector operations within transformers, we can achieve a more streamlined and intuitive representation of these complex processes. Einstein notation helps clarify the role of each element in the tensor operations used in transformers, from embedding layers to output calculations. This clarity can demystify the underlying processes for a broader audience and provide a fresh perspective that might lead to optimization insights.</p><p><strong>Example in Transformer Calculations</strong>: In the context of a transformer, consider the matrix multiplication involved in calculating the query and key matrices. Traditionally represented with extensive summation symbols, applying Einstein notation simplifies these expressions significantly. For instance, the product of matrices Q and K^T (Transpose of K) in attention scores calculation can be elegantly expressed with fewer symbols, highlighting the implicit summation over shared indices, thus making the operations more accessible and less error-prone.</p><h3>5. Decoding Complex Patterns: Dot Products in Machine Learning Classification</h3><h4>Simplifying Classification: The Power of Projection</h4><p>In the realm of machine learning, particularly in image classification, the dot product plays a crucial role in determining the similarity between an unknown item and established categories. By representing images as vectors in a high-dimensional feature space, algorithms can efficiently classify new images based on their proximity to known category vectors.</p><p><strong>Vector Similarity in Action</strong>: For instance, if we classify images into categories such as ‘dog’ and ‘cat,’ the algorithm calculates the dot product between the vector of an unknown image and the vectors representing each category. This calculation measures the cosine of the angle between the vectors, providing a numerical value that quantifies similarity. An unknown image whose vector has a higher dot product with the ‘dog vector’ than with the ‘cat vector’ is classified as a dog, and vice versa. This method effectively projects the unknown vector onto the direction vectors of known categories to determine similarity.</p><h4>Hierarchical Classification in Deep Learning</h4><p>Deep learning architectures, such as multi-layer perceptrons (MLP) and convolutional neural networks (CNNs), leverage dot products at each layer to perform classification. This is not a singular computation but a series of layered dot products, each followed by a non-linear activation function.</p><p><strong>Neuron’s Computational Role</strong>: Each neuron in a neural network layer computes a dot product of the input vector with its weight vector. This can be represented as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*Lu-WYxzsTpE9-0szwUv_3A.png" /></figure><p>where x is the input vector, w is the weight vector of the neuron, and n is the number of inputs. The resulting scalar is then passed through a nonlinear function to add non-linearity, which is crucial for the model’s ability to learn complex patterns.</p><p><strong>Beyond Simple Layers</strong>: This dot product computation repeats across successive layers, with the output of one layer becoming the input to the next, creating a hierarchy of ‘dot-product classifications.’ This hierarchical approach allows neural networks to learn from very simple to highly complex features, enabling them to handle intricate and nuanced datasets effectively.</p><blockquote>The story of dot and cross products is a narrative woven into the fabric of our universe, from the simplest particles to the vast structures of space, and into the complex realms of artificial intelligence. By mastering these vector operations, we gain more than just mathematical tools — we unlock a new perspective on the universe, discovering beauty and order in the chaos of dimensions. These foundational mathematical concepts not only aid in our understanding of the physical world but also empower our technological advancements, proving indispensable in the development of algorithms that can perceive, learn from, and interact with the world around us.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b64125230a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Walking on Eggshells]]></title>
            <link>https://medium.com/@sahasra007k/walking-on-eggshells-205ae17e236e?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/205ae17e236e</guid>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 06:58:50 GMT</pubDate>
            <atom:updated>2025-03-05T09:39:03.954Z</atom:updated>
            <content:encoded><![CDATA[<h4>Life with a Narcissist and the Battle for Self-Worth</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*RRq_GowLe32-mXD6IeZxYA.png" /></figure><p><em>Imagine waking up every day feeling suffocated — not because of physical constraints, but because the people around you drain your energy, distort your reality, and manipulate your emotions. You try to do everything right, yet you are always the one at fault, always the one apologizing, always the one feeling empty.</em></p><p>You try to be the best version of yourself, yet you’re constantly questioned, <strong>blamed for things you didn’t do, and made to feel like you’re the problem.</strong></p><p><strong>YOU ARE NOT ALONE. </strong>Millions suffer in silence under the toxic grip of narcissists — sometimes inescapable ones.</p><p>These narcissistic personalities, <strong>destroy your mental peace without ever laying a hand on you.</strong> This blog uncovers <strong>how they operate, the pain they cause, and how you can break free.</strong></p><p>Narcissists exist in every form:</p><ul><li>A mother who manipulates instead of nurtures.</li><li>A mother-in-law who poisons your marriage.</li><li>Siblings who secretly hate you but play the victim.</li><li>A partner who wastes years of your life.</li><li>Friends who use you as their emotional crutch.</li><li>A CEO who makes you feel replaceable.</li></ul><h3>The Narcissistic Mother: Love That Feels Like a Life Sentence</h3><p>A narcissistic mother doesn’t just raise a child — she <strong>owns</strong> them. She sees her child as <strong>an extension of herself, not as an individual.</strong></p><h4>How a Narcissistic Mother Controls You:</h4><p>🔴 She demands complete obedience and guilt-trips you for independence.<br>🔴 Your achievements only matter if they serve her ego.<br>🔴 She plays the victim if you call out her behavior.<br>🔴 She gaslights you, making you believe you’re the ungrateful one.</p><h3>Example:</h3><p>👩‍👧 A daughter earns a scholarship to study abroad, but her mother cries and says, <strong>“After all I’ve done for you, you’re abandoning me?”</strong> Instead of being happy, she makes her daughter feel <strong>guilty for having dreams.</strong></p><p>💡 <strong>The Damage:</strong></p><ul><li>You feel <strong>unworthy of love</strong> unless you sacrifice yourself.</li><li>You second-guess <strong>every decision.</strong></li><li>You live under <strong>constant guilt.</strong></li></ul><p>➡ <strong>Breaking Free:</strong> Set <strong>firm boundaries.</strong> You are not responsible for her happiness.</p><h3>The Narcissistic Mother-in-Law: The Woman Who Won’t Let Her Son Be a Husband</h3><p>A narcissistic mother-in-law <strong>sees her son’s wife as competition.</strong> Instead of supporting the marriage, she works behind the scenes to <strong>tear it apart.</strong></p><p>🔴 She treats you like an outsider in your own marriage.<br>🔴 She manipulates her son into always choosing her over you.<br>🔴 She criticizes everything you do but pretends to be innocent.<br>🔴 She plays the victim, claiming you are the problem.</p><h3>Example:</h3><p>👩‍👦 A wife notices her husband <strong>always sides with his mother.</strong> When she tries to address it, he says, <strong>“That’s just how she is.”</strong> Meanwhile, his mother <strong>constantly undermines his wife’s authority in the home.</strong></p><p>💡 <strong>The Damage:</strong></p><ul><li>You feel <strong>alone in your marriage.</strong></li><li>Your husband becomes <strong>emotionally unavailable.</strong></li><li>You start <strong>resenting your relationship.</strong></li></ul><p>➡ <strong>Breaking Free:</strong> A husband must <strong>choose his wife</strong> over toxic family interference. If he won’t set boundaries, <strong>the marriage will suffer.</strong></p><h3>The Narcissistic Sibling: A Lifetime of Competition and Betrayal</h3><p>A narcissistic sibling doesn’t see you as family; <strong>they see you as competition.</strong></p><p>🔴 They try to one-up you in everything.<br>🔴 They make sure you look bad in front of the family.<br>🔴 They spread lies to turn others against you.<br>🔴 They act like they care but secretly undermine you.</p><h3>Example:</h3><p>👩‍👦 A younger brother always acts innocent but <strong>secretly tells the parents that his sister is “selfish” for moving away.</strong> The family believes him, and she is labeled the bad one.</p><p>💡 <strong>The Damage:</strong></p><ul><li>You feel like <strong>an outsider in your own family.</strong></li><li>Your accomplishments <strong>are never celebrated.</strong></li><li>You develop <strong>trust issues</strong> in relationships.</li></ul><p>➡ <strong>Breaking Free:</strong> <strong>Stop seeking approval.</strong> They will never truly be happy for you.</p><h3>The Fake Step-Sibling: The Two-Faced Manipulator</h3><p>Step-siblings can either be <strong>a blessing or a curse.</strong> Narcissistic step-siblings <strong>reject you in private but pretend to care in public.</strong>A narcissistic step-sibling <strong>is a master of dual personalities</strong>. To outsiders, they <strong>act like they care about you</strong> — but behind closed doors, they <strong>invalidate you, exclude you, and make sure you never truly belong.</strong></p><p>🔴 <strong>They manipulate perceptions.</strong> In public, they act <strong>supportive and protective</strong>, maintaining the image of a “caring” step-sibling. Behind closed doors, they <strong>belittle you, undermine your efforts, and subtly turn your step-parent against you.</strong></p><p>🔴 <strong>They blame and play the victim.</strong> No matter the situation, <strong>you are always at fault.</strong> If they fail, it’s <strong>your influence</strong> or an external factor. If you succeed, they either <strong>downplay it or take credit.</strong></p><p>🔴 <strong>They compete for validation.</strong> If you have a strong bond with a family member, <strong>they insert themselves to weaken it.</strong> They make sure you never feel truly <strong>included or valued.</strong></p><p>🔴 <strong>They gaslight and manipulate.</strong> They hurt you but <strong>deny it ever happened</strong>, making you question your reality. When confronted, they <strong>flip the script</strong>, acting as if <strong>you are the aggressor.</strong></p><p>🔴 <strong>They shift blame effortlessly.</strong> If caught in a lie, they say you <strong>misunderstood.</strong> If they break family rules, <strong>you influenced them.</strong> If they fall short, <strong>you were just the favorite.</strong></p><p>🔴 <strong>They thrive on your reactions.</strong> They know your <strong>triggers</strong> and push until you <strong>snap — only to paint you as unstable.</strong> If you stay silent, <strong>they escalate until you break.</strong></p><p>💡 <strong>The Damage:</strong></p><ul><li>You feel <strong>unwanted in your own home.</strong></li><li>You start <strong>isolating yourself.</strong></li><li>You constantly <strong>question your worth.</strong></li><li>You are never respected.</li></ul><p>➡ <strong>Breaking Free:</strong> Stop <strong>playing their game.</strong> If they don’t accept you, <strong>don’t seek their validation.</strong></p><p>One of the most <strong>soul-crushing</strong> traits of a <strong>narcissistic step-sibling</strong> is that they <strong>only see you as useful when they need something.</strong></p><p>They <strong>don’t care about you as a person</strong> — they care about what you can do for them. The moment you <strong>are no longer useful, they discard you like you never mattered.</strong></p><h3>The Narcissistic Friend: When the Person You Trusted the Most Walks Away Like You Never Existed</h3><ul><li><strong>Narcissistic friendships are built on convenience, not genuine care.</strong> You gave years of loyalty, but it was never mutual.</li><li>One day, they <strong>walk away over something petty</strong>, leaving you questioning everything.</li><li><strong>They replace you instantly</strong> — not with real friends, but with people who <strong>validate their ego</strong> and reassure them that you were the problem.</li><li><strong>They erase you</strong> — acting like your friendship never existed, even though you sacrificed so much for them.</li><li><strong>They left because you no longer served their ego.</strong> The moment you stopped playing by their rules, you became disposable.</li><li><strong>Real friendships don’t require blind worship</strong> — true friends don’t discard you the moment you stop being convenient.</li><li><strong>Let them go.</strong> Let them create their illusion of a perfect friendship elsewhere.</li><li><strong>You are free now.</strong> Free to choose yourself, reconnect with real people, and build <strong>friendships that don’t cost you your self-worth.</strong></li><li><strong>The greatest revenge?</strong> Understanding that losing them wasn’t a loss at all.</li></ul><h3>The Narcissistic Partner: Love That Feels Like a Trap</h3><p>A narcissistic partner <strong>doesn’t love you — they use you.</strong></p><p>🔴 <strong>They love-bomb you at first, then withdraw.</strong><br>🔴 <strong>They make you feel guilty for their actions.</strong><br>🔴 <strong>They gaslight you into questioning your reality.</strong><br>🔴 <strong>They isolate you from others so you depend on them.</strong></p><p>💡 <strong>The Damage:</strong></p><ul><li>You forget <strong>who you were before them.</strong></li><li>You waste <strong>years trying to fix them.</strong></li><li>You feel like <strong>love is supposed to hurt.</strong></li></ul><p>➡ <strong>Breaking Free:</strong> <strong>Cut them off.</strong> They will never change.</p><p>A narcissistic partner doesn’t just cheat — they make sure you <strong>feel it in the most painful way possible.</strong> Instead of remorse, they <strong>blame you</strong>, saying you weren’t good enough or digging up your past to justify their betrayal. They want you to <strong>question your worth, your reality, and your sanity.</strong> But their infidelity was never about you — it was about <strong>their endless need for validation and control.</strong> <em>Walking away isn’t losing — it’s </em><strong><em>choosing yourself.</em></strong></p><h3>The Narcissistic CEO: The Boss Who Sees You as a Tool</h3><p>A narcissistic CEO <strong>only cares about power.</strong> Employees are nothing more than <strong>disposable tools.</strong></p><ul><li>They promise career growth but never deliver.</li><li>They take credit for your hard work.</li><li>They create a toxic, anxiety-driven workplace.</li><li>They see you as replaceable.</li></ul><p>💡 <strong>The Damage:</strong></p><ul><li>You lose your <strong>confidence and self-worth.</strong></li><li>You work <strong>endless hours with no appreciation.</strong></li><li>You feel <strong>expendable.</strong></li></ul><p>➡ <strong>Breaking Free:</strong> <strong>Find an employer who values you.</strong> No paycheck is worth your mental health.</p><h3>The Illusion of Equality: When Power, Control, and Deception Rule the Workplace</h3><p>Workplaces often <strong>sell the illusion of fairness and inclusivity</strong>, but beneath this façade lies <strong>a system built on control, favoritism, and strategic manipulation.</strong> Those who <strong>flatter leadership</strong> are rewarded, while those who <strong>rely on merit</strong> are sidelined. The environment becomes <strong>less about skill and innovation, and more about survival — where loyalty, not competence, dictates success.</strong></p><h3>When Manipulation Extends Beyond Work</h3><p>Toxic workplaces are draining, but when personal and professional lives intertwine with <strong>narcissism, the damage is far worse.</strong> Some individuals <strong>sabotage others while maintaining a flawless reputation.</strong> They withhold information, assign blame, and ensure that <strong>when things go wrong, they appear as the solution — never the problem.</strong></p><p>For those caught in this cycle, <strong>tasks are disrupted, achievements dismissed, and concerns ignored.</strong> Speaking up often leads to <strong>betrayal, not justice.</strong> The system protects the <strong>manipulators, while the real victims are left to pick up the pieces.</strong></p><h3>The Only Way Out? Walk Away.</h3><p>In toxic workplaces, <strong>trust is an illusion, and loyalty is exploited.</strong> No job is worth sacrificing your self-worth. The power they held over you was <strong>never real — it was only borrowed.</strong> And when you walk away, <strong>you take it back.</strong></p><p>But the lesson in all this? <strong>No job, no position, and no paycheck is worth your mental well-being.</strong></p><h3>The Aftermath: The Mental Toll of a Manipulative Workplace</h3><p>The scars left behind by such <strong>corporate deceit and emotional abuse</strong> don’t fade overnight. The <strong>constant anxiety, the feeling of being watched, the fear of speaking up — it lingers. It makes you question your worth. It forces you into survival mode. It teaches you that honesty is punished, and manipulation is rewarded.</strong></p><p>But if there’s one thing I learned, it’s this — <strong>walking away is not defeat. It is power.</strong></p><p><em>And when you finally walk away, </em><strong><em>you will realize that the power they held over you was never real — it was only borrowed. And you just took it back.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*xIzGCFGwJvk_jSa4UHMbPg.png" /></figure><h3>Final Words: You Deserve Better</h3><blockquote>You <strong>cannot change a narcissist, but you can change how much power they have over you.</strong></blockquote><blockquote>🔹 <strong>Set firm boundaries.</strong><br>🔹 <strong>Stop explaining yourself to people who only hear what they want.</strong><br>🔹 <strong>Prioritize yourself, not their ego.</strong><br>🔹 <strong>Choose growth over staying in pain.</strong></blockquote><blockquote>🔥 <strong>You deserve better.</strong> Start acting like it.</blockquote><p>💬 <strong>Have you dealt with a narcissist? Share your story in the comments!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=205ae17e236e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coded Couture]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@sahasra007k/coded-couture-how-fashion-inspires-a-data-scientist-44114d31e956?source=rss-162822c2bcae------2"><img src="https://cdn-images-1.medium.com/max/1098/1*P3w6FAQsbCVmdf42CmTxkA.png" width="1098"></a></p><p class="medium-feed-snippet">How Fashion Inspires a Data Scientist</p><p class="medium-feed-link"><a href="https://medium.com/@sahasra007k/coded-couture-how-fashion-inspires-a-data-scientist-44114d31e956?source=rss-162822c2bcae------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@sahasra007k/coded-couture-how-fashion-inspires-a-data-scientist-44114d31e956?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/44114d31e956</guid>
            <category><![CDATA[fashion-technology]]></category>
            <category><![CDATA[fashion-designer]]></category>
            <category><![CDATA[fashion-trends]]></category>
            <category><![CDATA[fashion-design]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 10:17:35 GMT</pubDate>
            <atom:updated>2025-03-05T09:39:47.749Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Smart Query Handling for Smarter Sales]]></title>
            <link>https://medium.com/@sahasra007k/smart-query-handling-for-smarter-sales-abe10ba7fabb?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/abe10ba7fabb</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 09:13:37 GMT</pubDate>
            <atom:updated>2025-03-05T09:41:24.974Z</atom:updated>
            <content:encoded><![CDATA[<h4>Enhancing Customer Interactions with Intelligent Automation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*QGviwKXzkGbck9RgzZOVLw.png" /></figure><p>Imagine a day when every repetitive customer question is handled instantly, and your sales team can focus on what truly matters: building connections and closing deals. That’s exactly the kind of query assistant we set out to create — an intelligent digital sidekick built with the power of <strong>Ollama</strong>, <strong>Chroma</strong>, and open-source Large Language Models (LLMs).</p><p>This isn’t just a <strong>chatbot</strong>; it’s a purpose-built AI that dives into a knowledge base, surfaces relevant information, and intelligently answers questions — all without breaking a sweat. Here’s the inside story of how we made it happen, step-by-step.</p><h3>1. Giving the Assistant a “Memory” with Embeddings</h3><p>Every assistant needs a foundation. For our query assistant, that foundation is its ability to understand language in context. This all starts with <strong>embeddings</strong>, which act as the assistant’s <strong>“memory.”</strong></p><h4>The Power of Embeddings</h4><p>Embeddings transform words and phrases into high-dimensional vectors, allowing our assistant to process the meaning of each sentence. By using embeddings, our assistant doesn’t just see words — it understands them, in context. And for this essential part, we turned to <strong>Ollama</strong>.</p><h4>Setting Up with Ollama Embeddings</h4><p>In the get_embedding_function.py script, we establish our assistant’s memory by loading OllamaEmbeddings. Here, we define the nomic-embed-text model from Ollama, which gives our assistant the power to make sense of all the information it will need to answer questions.</p><pre># From get_embedding_function.py<br>from langchain_ollama import OllamaEmbeddings<br><br>def get_embedding_function():<br>    embeddings = OllamaEmbeddings(model=&quot;nomic-embed-text&quot;)<br>    return embeddings</pre><h3>2. Building the Assistant’s Knowledge Base</h3><p>With our assistant’s memory set, it’s time to give it a brain — somewhere to store information and reference it when answering queries. This is where the populate_database.py script comes in, laying the foundation of the assistant’s knowledge base.</p><h4>Loading Documents</h4><p>Every assistant needs to study, and in our case, we’re feeding it documents stored in PDF format. Using <strong>PyPDFDirectoryLoader</strong>, we load all relevant PDFs into the assistant’s brain.</p><pre># From populate_database.py<br>from langchain_community.document_loaders import PyPDFDirectoryLoader<br><br>def load_documents():<br>    document_loader = PyPDFDirectoryLoader(&quot;data_brihaspathi&quot;)<br>    return document_loader.load()</pre><h4>Breaking It Down with Text Splitters</h4><p>Our assistant has a lot to remember, so we use the RecursiveCharacterTextSplitter to break each document into smaller, manageable chunks. This allows the assistant to quickly retrieve and understand individual pieces of information.</p><pre>from langchain_text_splitters import RecursiveCharacterTextSplitter<br><br>def split_documents(documents):<br>    text_splitter = RecursiveCharacterTextSplitter(<br>        chunk_size=800,<br>        chunk_overlap=80<br>    )<br>    return text_splitter.split_documents(documents)</pre><h4>Storing Knowledge with Chroma</h4><p>We then store these chunks in a <strong>Chroma</strong> database, which acts as the assistant’s long-term memory. Each chunk is given a unique ID so that the assistant can later identify which document and section to reference.</p><p>With each chunk, our assistant builds a library of knowledge. Every fact, figure, and story is cataloged and waiting to be recalled.</p><h3>3. Responding to Customer Queries in Real Time</h3><p>With memory and knowledge in place, it’s time for our assistant to go live and start answering questions. The query_data.py script is where our assistant comes to life, using Chroma to fetch information and Ollama’s LLMs to form coherent, context-rich responses.</p><h4>Searching the Knowledge Base</h4><p>When a customer asks a question, our assistant starts by performing a similarity search across its database, thanks to Chroma. The assistant retrieves the most relevant chunks, giving it context to formulate a meaningful response.</p><pre># From query_data.py<br>from langchain_chroma import Chroma<br><br>def query_rag(query_text):<br>    embedding_function = get_embedding_function()<br>    db = Chroma(persist_directory=&quot;chroma&quot;, embedding_function=embedding_function)<br>    results = db.similarity_search_with_score(query_text, k=5)</pre><h4>Crafting a Contextual Answer</h4><p>Next, the assistant uses the ChatPromptTemplate to format its response based on the context it just retrieved. By setting up a structured prompt, we ensure that each answer is clear and relevant.</p><pre>from langchain.prompts import ChatPromptTemplate<br><br>PROMPT_TEMPLATE = &quot;&quot;&quot;<br>Answer the question based only on the following context:<br><br>{context}<br><br>---<br><br>Answer the question based on the above context: {question}<br>&quot;&quot;&quot;<br><br>def format_prompt(context_text, question_text):<br>    prompt_template = ChatPromptTemplate.from_template(PROMPT_TEMPLATE)<br>    return prompt_template.format(context=context_text, question=question_text)</pre><h4>Using Ollama’s Mistral Model for Responses</h4><p>Finally, our assistant invokes Ollama’s Mistral model to create a polished response. With a blend of memory, context, and language capabilities, the assistant produces answers that are both accurate and engaging.</p><pre>from langchain_community.llms.ollama import Ollama<br><br>model = Ollama(model=&quot;mistral&quot;)<br>response_text = model.invoke(prompt)<br>print(&quot;Response:&quot;, response_text)</pre><blockquote>Each query is a chance for our assistant to shine, drawing on its well-curated memory and delivering an answer that’s just as good as a human representative.</blockquote><h3>4. Impact on Sales and Customer Satisfaction</h3><p>By delegating routine questions to our assistant, our sales team can finally breathe easy. Repetitive queries no longer pile up, and customers get instant answers, reducing wait times and improving satisfaction.</p><p>This query assistant has become a true sidekick for our sales team, handling the frontlines while they focus on higher-value interactions and closing deals. It’s efficient, effective, and brings real value to our business operations.</p><h3>Conclusion: The Future of AI-Driven Support</h3><p>As our assistant continues to learn and adapt, we’re excited about the possibilities. With Ollama and open-source LLMs, the sky’s the limit. We’re already planning the next phase, where our assistant will become even more integrated, learning from each interaction to provide better responses with every query.</p><blockquote>I’ve outlined the key functions tailored to this use case, but consider them a foundation. These functions are open for you to adapt and elevate your own applications in creative, meaningful ways.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abe10ba7fabb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Edge-ucating AI : Cutting the weight, Keeping the wisdom]]></title>
            <link>https://medium.com/@sahasra007k/edge-ucating-ai-cutting-the-weight-keeping-the-wisdom-c0a4527d5280?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0a4527d5280</guid>
            <category><![CDATA[model-optimization]]></category>
            <category><![CDATA[edge-ai]]></category>
            <category><![CDATA[quantization]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 12:43:09 GMT</pubDate>
            <atom:updated>2025-03-05T09:40:19.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>EDGE-ucating AI : Cutting the <strong>weight</strong>, Keeping the wisdom</h3><h4>AI at Your Fingertips — Cloud-Free, Pocket-Sized Brilliance</h4><blockquote>Imagine a world where your phone, watch, or even coffee machine isn’t just smart — it’s genius. No cloud, no lag — just instant, on-the-spot brilliance right in your hand. That’s on-device AI: powerful, lightweight intelligence that doesn’t need a cloud to shine.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-1MGhdk8E_oS-OdIMHufA.png" /></figure><h3>In this blog, we’ll explore the ‘Edge-ucation’ of AI</h3><p>Imagine jotting down notes with your Galaxy Ultra’s pen, and it instantly converts your handwriting into text — no waiting, no loading. That’s on-device AI reducing latency, giving you real-time results right on the screen. Or picture the Galaxy Ultra’s smart camera recognizing your pet’s face, adjusting settings on the spot to capture their cuteness perfectly. With on-device AI, efficiency is the name of the game, processing every snap and scribble right there on your phone instead of reaching out to the cloud. It’s faster, more efficient, and cuts down on those pesky data costs. And here’s the cherry on top: all that data, from your quick notes to those adorable pet photos, stays safe on your device. Privacy preservation? Check. The Galaxy Ultra isn’t just a smartphone — it’s a brilliant, responsive assistant in your pocket, showing the magic of on-device AI at work every day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3klc0dWGTUmZc8MSlsmmw.png" /></figure><p>When a picture is taken, 20+ AI models work in harmony within 100ms to deliver a stunning shot, capturing every detail and enhancing clarity — all while keeping it true to reality. From optimizing lighting and balancing colors to sharpening details and reducing noise, these models team up to create that perfect photo, instantly and seamlessly. The result? A snapshot that’s as vibrant as the moment itself, crafted by the power of on-device AI.</p><p>Also if you have come across Samsung Ballie, it is a rolling AI powerhouse, seamlessly handling home tasks with the charm of an on-device genius. It autonomously roams the house, connecting to appliances and adjusting settings without any cloud help. Ballie adapts to your routine — playing workout videos, adjusting lighting, sending pet updates, and even setting the perfect soundtrack for relaxation or productivity. It’s like having a personal assistant that knows your habits and makes life smoother, one roll at a time.</p><p><strong><em>P.S.: After all this Ballie and Galaxy Ultra admiration, Samsung, if you’re listening… I’m ready for that sponsorship! 😛</em></strong></p><p>It’s amazing to think how on-device AI is now going <strong>multimodal</strong>, combining vision, sound, touch, and more into one seamless experience. Imagine a model that can see, hear, and understand — right from the device in your hand! The possibilities are endless when you can mix <strong>multiple modalities</strong>.</p><blockquote><strong>Ever wondered what powers this magic?</strong> Here’s the twist: fitting massive AI smarts into tiny devices takes serious skill. It’s all about ‘cutting the weight while keeping the wisdom’ — using clever tricks like <strong>Model optimizations</strong> to transform bulky models into lean, efficient powerhouses without sacrificing intelligence.</blockquote><p>One such technique is <strong>Quantization,</strong> used in AI to reduce the size and complexity of a model by lowering the precision of the numbers it uses. Instead of processing data in high-precision formats (like 32-bit floating-point), quantization reduces this to lower-precision formats (like 8-bit integers).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*yP8uZaMKzUkmMJLuVNCY9w.png" /></figure><p>This streamlined model requires less memory and computational power, making it faster and more energy-efficient — perfect for running AI on devices with limited resources, like smartphones and IoT devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*TCNcS7YLYn0e7YMMqWgbLQ.png" /></figure><p>Downscaling from <strong>FP32</strong> to <strong>FP16</strong> or <strong>INT8</strong> enables AI models to be <strong>smaller, faster, more energy-efficient, and cost-effective.</strong></p><p>Here,</p><ul><li><strong>Scale</strong>: A factor used in quantization to map the floating-point values to integers, determining how much each integer step represents in the original range.</li><li><strong>Zero Point</strong>: The integer value that represents zero in the quantized range, ensuring that small values close to zero in floating-point are accurately represented in the integer format.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*cvmTNsvzDUwyfqqSXjLUZA.png" /></figure><p>Using the <strong>scale</strong> and <strong>zero point</strong>, the original high-precision floating-point values are mapped to integers in the INT8 range, allowing the model to store and compute with lower precision without significant accuracy loss. This makes the model more memory-efficient and faster to run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*mtPHeG8WiGDMwZkv7YnNQw.png" /><figcaption>The <strong>quantize</strong> and <strong>de-quantize</strong> operations, which are essential parts of the <strong>quantization process</strong>used to reduce the size and computational requirements of AI models.</figcaption></figure><h3>1. Quantize Operation</h3><p>This operation converts a high-precision floating-point number to a lower-precision integer.</p><p><strong>In the Image</strong>:</p><ul><li>The original value is 12.5, a floating-point number.</li><li>The <strong>scale factor</strong> is 2.35, which is used to map the floating-point value to the integer range.</li><li>The operation here is: Round(12.5 / 2.35) - 0, where:</li><li>12.5 / 2.35 gives approximately 5.32.</li><li>Rounding 5.32 results in 5.</li><li><strong>Zero Point</strong> is 0, so there’s no further adjustment.</li><li>This results in a <strong>quantized integer value</strong> of 5.</li></ul><p><strong>Purpose</strong>: Quantization is used to simplify the data representation, making the model more compact and computationally efficient. By converting floating-point numbers to integers, we significantly reduce the memory footprint and speed up calculations, making it suitable for on-device AI where resources are limited.</p><h3>2. De-Quantize Operation</h3><p>This operation converts the integer value back to an approximate floating-point representation.</p><p><strong>In the Image</strong>:</p><ul><li>The quantized integer value is 5.</li><li>To de-quantize, the operation is: (5 + 0) * 2.35, where:</li><li>We add the <strong>zero point</strong> (0), which does not affect the result in this case.</li><li>Multiplying by the <strong>scale factor</strong> 2.35 gives 11.75.</li><li>This results in an approximate floating-point value of 11.75, which is close to the original 12.5.</li></ul><p><strong>Purpose</strong>: De-quantization allows us to approximate the original high-precision values when needed. Although there’s a slight loss of precision (from 12.5 to 11.75), this small difference is usually acceptable, especially in applications where exact precision isn’t critical.</p><blockquote><strong><em>However, simplifying a model’s precision isn’t without its downsides — this is where quantization error comes into play.</em></strong></blockquote><p><strong>Quantization error</strong> is the <strong>difference between the original high-precision value</strong> (like a 32-bit floating-point) and the <strong>approximate value</strong> after it has been quantized to a lower precision (like 8-bit integer).</p><h3>Why Quantization Error Occurs</h3><p>Quantization reduces the precision of numbers, typically by mapping a continuous range of values to a smaller, discrete set of values. This process introduces a small <strong>rounding error</strong> because the quantized value is only an approximation of the original.</p><p>For example:</p><ul><li>If a floating-point number 12.5 is quantized to an integer using a scale factor 2.35, it may end up as 5 in the quantized range.</li><li>When de-quantized, this value might be 11.75, which is close to 12.5 but not exactly the same.</li><li>The quantization error here is 12.5 - 11.75 = 0.75.</li></ul><blockquote><strong>Quantization error</strong> is the price we pay for making models smaller and more efficient, but with careful quantization techniques, it can be minimized to maintain high model accuracy.</blockquote><p>Now, let’s dive into the different types of quantization that make models more efficient: <strong>weight quantization</strong> and <strong>activation quantization</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tmCQBYtWeIyzlG5c8h-SQ.png" /></figure><p>Here are two primary methods of quantization that make deployment more flexible: <strong>Post-Training Quantization</strong> and <strong>Quantization-Aware Training</strong></p><h3>Post-Training Quantization (PTQ)</h3><p><strong>What It Is</strong>: PTQ is a technique where quantization is applied <strong>after the model has been fully trained</strong>. It converts the weights and activations of the trained model to a lower precision (e.g., from FP32 to INT8) without further training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*ikJuqGsl70OCguXloCo1iw.png" /></figure><p><strong>Significance</strong>:</p><ul><li><strong>Simplicity</strong>: PTQ is straightforward to apply and requires no retraining, making it quick and easy to deploy.</li><li><strong>Efficiency</strong>: It’s widely used when a small reduction in model accuracy is acceptable for a significant gain in efficiency.</li><li><strong>Use Case</strong>: Ideal for deploying models on resource-limited devices when minor accuracy loss is acceptable.</li></ul><h3>Quantization-Aware Training (QAT)</h3><p><strong>What It Is</strong>: QAT is a technique where the model is <strong>trained with quantization in mind</strong>. During training, the model simulates low-precision calculations (like INT8) so that it learns to adjust for the precision loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*-asQyJET1jyxARouBxlwvg.png" /></figure><p><strong>Significance</strong>:</p><ul><li><strong>Higher Accuracy</strong>: Since the model adapts to quantization effects during training, it usually retains more accuracy compared to PTQ.</li><li><strong>Precision Control</strong>: QAT is preferred when maintaining high accuracy is critical, especially in complex models and sensitive applications.</li><li><strong>Use Case</strong>: Ideal for applications that demand high accuracy and can afford the extra training time.</li></ul><blockquote>In GenAI,<strong> Quantized LoRA (QLoRA)</strong> is a technique that combines <strong>quantization</strong> and <strong>Low-Rank Adaptation (LoRA)</strong> to make large language models more efficient. By applying <strong>4-bit quantization</strong> to the model and only fine-tuning a small subset of parameters, QLoRA drastically reduces memory and computational needs.</blockquote><p>Companies like Apple, Google, Samsung, Qualcomm, and NVIDIA have mastered the art of bringing AI to life on-device. They achieve this by pairing <strong>model quantization</strong> with highly optimized runtimes — each carefully tailored to their hardware. With runtimes like <strong>Core ML</strong> (Apple), <strong>TensorFlow Lite</strong> (Google), <strong>ONNX Runtime</strong> (Samsung, Qualcomm), and <strong>TensorRT</strong> (NVIDIA), these companies can harness the full power of their devices.</p><p>But AI needs more than just software smarts. Enter the <strong>NPU (Neural Processing Unit)</strong> — specialized hardware designed specifically to handle the intense matrix operations of deep learning, making real-time AI on mobile and edge devices possible. And it’s not just NPUs — these runtimes come with flexible backends, letting you tap into the <strong>CPU, GPU, or NPU</strong> as needed, making AI faster, more responsive, and power-efficient.</p><p>The magic lies in knowing which computational resources to use and when. With the right balance of CPU, GPU, and NPU, modern devices can deliver smooth, intelligent experiences at your fingertips. In on-device AI, understanding these resources is essential — each one unlocks a new level of optimization for speed, energy efficiency, and performance.</p><h4>Quantization isn’t just useful for mobile and cloud-based AI — it’s transforming the capabilities of edge devices as well</h4><p>Edge devices like <strong>Raspberry Pi</strong> and <strong>NVIDIA Jetson boards</strong> leverage quantization to efficiently run AI models, even for demanding tasks like <strong>video analytics</strong>. By reducing model precision (e.g., from 32-bit floats to 8-bit integers), quantization lowers memory usage and power consumption, enabling faster inference on limited hardware. This makes real-time, on-device AI possible for applications such as <strong>image recognition</strong>, <strong>object detection</strong>, and <strong>video analytics</strong> in robotics, surveillance, and IoT. With frameworks like <strong>TensorRT</strong> on Jetson for GPU acceleration and <strong>ONNX Runtime</strong> or <strong>TensorFlow Lite</strong> on Raspberry Pi, quantized models bring high-performance AI to edge devices, making them powerful tools for processing video feeds directly on-site.</p><h3>The Road Ahead</h3><p>Quantization is reshaping the possibilities of on-device AI, from our everyday smartphones to robust edge devices like Raspberry Pi and NVIDIA Jetson. By streamlining complex models without losing their ‘wisdom,’ quantization allows AI to operate faster, smarter, and more efficiently than ever before. As advancements in hardware and specialized runtimes continue, we’re only scratching the surface of what on-device AI can achieve.</p><blockquote><em>In every stride toward efficiency, there’s a quiet cost, a small trade-off of precision — a gentle reminder that every breakthrough comes with a price.🙌🏻</em></blockquote><p><em>Stay tuned as on-device AI continues to evolve, bringing intelligence closer to where we need it most — right in our hands😉</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0a4527d5280" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond 2D]]></title>
            <link>https://medium.com/@sahasra007k/beyond-2d-4912eeea03dc?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4912eeea03dc</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[stereo-vision]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Sat, 26 Oct 2024 11:11:29 GMT</pubDate>
            <atom:updated>2025-03-05T09:42:03.459Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ever wondered how machines perceive depth??</h4><p><em>In a world dazzled by Generative AI, where everything from poetry to pixels is synthesized on demand, it’s easy to forget one crucial thing — machines still need to see the world to understand it. Enter stereo vision, a classic technique that, while lacking the glitz of generative models, quietly powers the technologies we depend on most. So, while everyone’s caught up in the magic of machines ‘</em><strong><em>imagining</em></strong><em>’ things, let’s talk about how they actually see — because sometimes, the best revolutions are the ones that are already right in front of us. 😉</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pMkq-Nh7q5OXJ6IFX2aDmA.png" /></figure><blockquote>Though each eye captures but a flat, two-dimensional scene, the mind weaves depth from difference, crafting a layered, living world. This marvel of blending two distinct perspectives into a single vision, conjuring depth from divergence, is the art we call <strong>stereo vision</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOigp-xnviae7TBLCea-QA.png" /></figure><blockquote><strong>Triangulation </strong>in computer vision is the process of identifying a point in 3D space from its projections onto two or more images.</blockquote><p>To determine the depth of point <strong>S</strong> in a 3D image, we identify two corresponding pixels, <strong>L</strong> and <strong>R</strong>, in the left and right 2D images. Knowing the relative positioning and distance between the cameras, the system calculates depth <strong>d</strong> through <strong>triangulation</strong>. The human brain performs a similar process, using S<strong>tereopsis</strong> to perceive depth and 3D shapes.</p><p>Yes 2D is okay, but it limits what you can achieve. Shifting to 3D opens up possibilities with depth maps, point clouds, and 3D bounding boxes, allowing for more advanced applications and insights. So, with 3D vision, you can do — Monocular depth estimation, 3D reconstruction, Generate bird’s-eye views, Fuse camera images with LiDAR or RADAR data (sensor fusion) and many more …</p><p>Let’s say you have 2 cameras. We call that a “stereo” setup. Thanks to these stereo images, and thanks to triangulation and geometry, we can build a depth map. And from this depth map, we can use geometry to retrieve a 3D point cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIMrPY1KZJeb0HE2MJKtjw.gif" /><figcaption>Do notice how the dark pixels mean “far” and the white pixels mean “close”.</figcaption></figure><h4>Alright, so what’s a Depth Map?</h4><p>A <strong>depth map</strong> and <strong>disparity</strong> are closely related concepts in stereo vision that help computers perceive depth in a scene:</p><ul><li>A <strong>depth map</strong> is an image where each pixel encodes the distance from the camera to the object at that pixel’s location. In this map, darker pixels represent objects that are farther away, while brighter pixels indicate objects that are closer.</li><li><strong>Disparity</strong> is the difference in position of corresponding points in two stereo images (left and right views). Since nearby objects have a greater shift (or disparity) between these images than distant ones, disparity serves as a key measure to estimate depth.</li></ul><p>In stereo vision, disparity values are calculated first from two images, and then these values are converted into a <strong>depth map</strong>, where each pixel gives the actual distance from the camera.</p><p>Here’s a small code to create depth maps :</p><pre>import cv2<br>import numpy as np<br>import glob<br><br># Load all left and right images<br>left_images = sorted(glob.glob(&#39;left_images/*.png&#39;))<br>right_images = sorted(glob.glob(&#39;right_images/*.png&#39;))<br><br># Check if both sets have the same number of images<br>if len(left_images) != len(right_images):<br>    raise ValueError(&quot;The number of left and right images do not match.&quot;)<br><br># Set up the stereo matcher<br>stereo = cv2.StereoBM_create(numDisparities=64, blockSize=15)<br><br># Explanation:<br># numDisparities: The range of disparities to search; must be a multiple of 16. Higher values allow the algorithm to <br># detect greater depth differences, useful for scenes with distant and close objects, but they also increase processing time.<br># blockSize: The size of the block window used for matching. Larger values increase robustness to noise but can <br># reduce detail. Here, 15 is chosen for a balance between detail and noise reduction.<br><br># Loop through each pair of images<br>for left_img_path, right_img_path in zip(left_images, right_images):<br>    # Read images<br>    left_image = cv2.imread(left_img_path, cv2.IMREAD_GRAYSCALE)<br>    right_image = cv2.imread(right_img_path, cv2.IMREAD_GRAYSCALE)<br><br>    # Compute the disparity map<br>    disparity_map = stereo.compute(left_image, right_image)<br><br>    # Explanation:<br>    # disparity_map: This is the raw disparity map, where each pixel’s value represents the disparity <br>    # (horizontal shift) between the left and right images. Larger disparity values typically indicate closer objects.<br><br>    # Normalize for visualization<br>    depth_map = cv2.normalize(disparity_map, None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX)<br>    depth_map = np.uint8(depth_map)<br><br>    # Explanation:<br>    # Normalization: Converts disparity values into a range that can be visually interpreted (0-255 grayscale).<br>    # This step is essential for displaying the depth map, as it makes distance differences more visible.<br><br>    # Display the depth map<br>    cv2.imshow(&#39;DepthMap&#39;, depth_map)<br>    cv2.waitKey()  <br><br># Cleanup<br>cv2.destroyAllWindows()</pre><blockquote><em>Note : Here, the left and right images are captured from slightly different angles, giving the depth perception necessary for 3D understanding, just as our eyes do in binocular vision.</em></blockquote><h4>With a depth map in hand, we’ve laid the foundation for everything next-level:</h4><p>Precise 3D mapping, smarter navigation, robust object detection, and immersive AR experiences. In practice, 3D object detection can now be achieved by combining these maps with machine learning models like YOLO3D or PointNet, which are trained to detect objects in 3D space. Libraries like OpenCV, PyTorch, and Open3D play a crucial role in building and visualizing these detections, turning flat perception into actionable depth and opening the door to true spatial understanding.</p><blockquote><em>With a depth map, we’re not just seeing in 3D — we’re opening up a new realm of possibilities. Stereo vision empowers machines to map, navigate, and interact with the world as if they truly see it. It’s the quiet hero, adding depth to our devices and redefining the future, one layer at a time.</em></blockquote><blockquote><strong><em>Also,</em></strong><em> Here’s a recent state-of-the-art </em><a href="https://arxiv.org/pdf/2404.06605"><em>RoadBEV paper</em></a><em> for timeless and impactful insights into stereo vision’s applications.</em></blockquote><p><em>Feel free to reach out if you’re interested in research collaborations 😊 — I’m an aspiring data scientist eager to explore new challenges in computer vision and beyond!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4912eeea03dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Through the Eyes of Algorithms]]></title>
            <link>https://medium.com/@sahasra007k/through-the-eyes-of-algorithms-7b1757f4d835?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b1757f4d835</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Fri, 25 Oct 2024 11:56:05 GMT</pubDate>
            <atom:updated>2025-03-05T09:42:45.804Z</atom:updated>
            <content:encoded><![CDATA[<h4>How CNNs Empower Machines with Vision 👀?!</h4><p><em>What if algorithms could see? In this deep dive, we explore the fascinating world of Convolutional Neural Networks (CNNs) and how they empower machines with the gift of sight. From understanding the structure of pixels to decoding complex visual patterns, discover how these digital ‘eyes’ reshape the way machines interpret and understand the world around us and why they’re the neural network that never gets tired of staring at pixels — one convolution at a time.</em></p><p><strong>I know, I know — another <em>long ass</em> post about CNNs? But wait! Before you roll your eyes</strong>, I promise this one dives deeper, uncovering the hidden brilliance of how these neural networks actually teach machines to see the world 🫣</p><p>Why “<strong>Deep Learning</strong>,” you ask? It’s called that because, much like our own consciousness, the network learns through layers of understanding — peeling back one layer at a time. Each hidden layer, like the depths of our thoughts, refines its knowledge by learning from previous errors. Just as humans evolve through their mistakes, these networks are designed to emulate the brain’s power to grow wiser with every misstep, diving deeper into insight.</p><h3>A Neural Odyssey: From Pixels to Perception</h3><p>While diving into the world of CNNs, I found myself asking some serious questions. You know, the kind that keep you up at night, like:</p><ul><li><strong>Learned weights</strong> — wait, how exactly do they learn if they’re seeing the image for the first time? 🤔</li><li><strong>Number of filters</strong> — okay, but where are these filters even defined? Are they just hanging out somewhere in the code? 🧐</li></ul><p>The random beginnings — So, when CNN filters encounter an image for the first time, the filter weights start off as random values or are initialized using techniques like <strong>Xavier or He initialization</strong>. These filters don’t yet know what patterns to detect — they simply apply random operations to the input data…</p><blockquote><strong>He initialization</strong> <em>works better for layers with ReLu activation and</em> <strong>Xavier initialization</strong><em> works better for layers with sigmoid activation.</em></blockquote><pre>[ 0.2, -0.1, 0.4 ]<br>[ 0.0, -0.3, 0.6 ]<br>[ -0.5, 0.1, 0.3 ]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*om0s6gkbuI-GdgUzff0s7A.gif" /></figure><p>The result is a set of seemingly arbitrary feature maps. These maps might capture random patches of darkness, brightness, or even just noise, but at this stage, they have no meaning.</p><h4>Randomness with a Purpose to Expertise</h4><p>Why start with random weights, though? Wouldn’t it make more sense to give the filters some predefined patterns to detect, like edges or textures, right from the start?</p><p>At first, the filters are naive. They don’t know what an edge looks like, or how to distinguish between the fur of a cat and the whiskers of a dog. But after many iterations of training, these filters become highly specialized. Early filters learn to detect low-level features, such as:</p><p><strong>Edges</strong>: Horizontal, vertical, or diagonal lines that define the boundaries of objects and <strong>Textures</strong>: Patterns that differentiate smooth surfaces from rough ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tU5Re-hym0MsrblLFAdnaw.png" /></figure><p>As the network goes deeper, the filters in later layers learn more abstract and complex features, such as:</p><p><strong>Shapes</strong>: Rounded edges, corners, or specific object parts like eyes, faces, or car wheels and <strong>Objects</strong>: Entire objects like faces, animals, or vehicles are detected by the deeper layers.</p><h3>Filters, but Not the Instagram Kind</h3><h4>What is Filters (Kernels)?</h4><p>Filters are small matrices (typically 3x3, 5x5, 7x7 or similar sizes) of learnable weights that scan over the input image to extract specific features like edges, textures, and patterns.</p><ol><li><strong>Filters/Kernels as Small Matrices:</strong><br>A filter might look like this:<br>[ 0.1 -0.2 0.3 ]<br>[ -0.1 0.5 -0.4 ]<br>[ 0.2 -0.3 0.6 ]<br>Each filter detects a particular feature in the input image, and CNNs usually have multiple filters in each layer.</li><li><strong>Convolution Operation:</strong><br>The convolution operation slides these filters over the image, calculating the dot product at each position. This process results in an activation map, highlighting where certain features (like edges or textures) are found in the image.</li><li><strong>Number of Filters (A User-Defined Choice):</strong><br>The number of filters in each layer is a hyperparameter chosen by the user. For instance, a layer may have 32 filters, each producing its own feature map, giving a better understanding of the image’s patterns.<br>As you go deeper into the network, the number of filters typically increases, allowing the CNN to capture more complex features.</li><li><strong>Learned Weights:</strong><br>The filter weights are learned during training. Initially random, they are adjusted through backpropagation, so they become specialized in detecting features relevant to the task.</li></ol><p>The number of filters in a CNN architecture is a <strong>hyperparameter</strong> and is <strong>defined by the user</strong> when designing the network.</p><ul><li>Each <strong>convolutional layer</strong> in the CNN has a <strong>specific number of filters</strong>, which can vary depending on the layer.</li><li>Common choices for the number of filters in a layer are <strong>32</strong>, <strong>64</strong>, <strong>128</strong>, <strong>256</strong>, etc., but the number can be set to any value based on the architecture’s design and the complexity of the task.</li></ul><h3>Example:</h3><p>In a typical CNN architecture:</p><ul><li><strong>First Convolutional Layer</strong>: It may have <strong>32 filters</strong> (e.g., 3x3 filters), meaning the layer will output 32 different feature maps and the <strong>Second Convolutional Layer</strong>: It may have <strong>64 filters</strong>, producing 64 feature maps.</li><li>As the network goes deeper, the number of filters generally increases to capture more complex features.</li></ul><blockquote><strong>Key Point:</strong> <strong>You define the number of filters</strong> when building the architecture. The more filters you have, the more features the network can extract, but this also increases computational cost.</blockquote><p>So, the number of filters is <strong>not fixed</strong> and varies by layer, and it’s a decision you make when designing the CNN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWSk83hg6wnBk6FmapvuPA.png" /><figcaption>Visual representation of CNN</figcaption></figure><p><em>CNNs use a few clever techniques to keep things efficient. </em><strong><em>Receptive fields</em></strong><em> limit each neuron to look at just a small region of the image, while </em><strong><em>zero-padding</em></strong><em> adds extra pixels around the edges to maintain the output size. The </em><strong><em>depth</em></strong><em> of a convolutional layer refers to how many filters are used to extract different features, and </em><strong><em>stride</em></strong><em> controls how far the filter moves over the image. Finally, </em><strong><em>parameter sharing</em></strong><em> ensures that the same weights are used across the image, reducing the number of parameters and making the network more efficient. Together, these tricks let CNNs handle complex images without overwhelming the system!</em></p><h3>The Surprising Power of Early Layers</h3><p>Here’s something most people don’t realize: CNNs often extract much of their power from the <strong>early layers</strong>. These layers detect simple patterns like edges and gradients, but it turns out that these seemingly simple patterns are incredibly <strong>discriminative</strong>. Studies show that even when you remove deeper layers or replace them with simpler architectures, CNNs can still perform well because the early layers have already captured the most essential information.</p><p>Why? Because these initial filters are adept at capturing <strong>low-level features</strong> like texture and contrast, which lay the foundation for everything that comes next.</p><ul><li><strong>Early filters</strong> might capture simple features like edges and textures.</li><li><strong>Deeper filters</strong> might detect more complex shapes like eyes, ears, or even whole objects like cars.</li></ul><h3>But with great power comes a few pitfalls 🤔</h3><p>While CNNs are powerful, they have their flaws. One of the lesser-known challenges is that CNNs sometimes find <strong>shortcuts</strong> to solve a task rather than truly understanding what they’re supposed to recognize. This is known as <strong>texture bias</strong>. CNNs have a surprising tendency to focus on textures over shapes, which can lead to errors in classification when texture changes but the object shape stays the same. For instance, a CNN might recognize a fur texture as a “cat,” even if the shape is distorted.</p><h3>Crafting a CNN: More Art Than Science 😈</h3><p>Building a CNN isn’t just stacking layers randomly — it requires thoughtful design. A common approach is to alternate <strong>convolutional layers</strong> with <strong>pooling layers</strong> and sometimes stack multiple convolutional layers before each pooling layer. Using <strong>small filters</strong> like 3x3 may seem simple, but as you stack layers, neurons “see” larger parts of the image, allowing for more complex feature detection with fewer parameters.</p><p>However, CNNs can get <strong>memory-hungry</strong>, especially with large images like 227x227. A single pass through 64 filters can generate <strong>millions of activations</strong> and gobble up memory. To manage this, you can either <strong>resize your images</strong> or use larger strides and filters to shrink feature maps faster. Keep your input sizes <strong>divisible by two</strong> and apply <strong>zero-padding</strong> to maintain dimensions.</p><p><em>So, while CNNs can see, their “vision” might not always work the way we expect it to. They don’t naturally generalize to recognize shapes as we do — they latch onto what’s most statistically consistent across the data. This makes </em><strong><em>data augmentation</em></strong><em> (like rotation, flipping, and color adjustment) essential to push CNNs beyond their biases.</em></p><h3>From Fuzzy Blobs to Masterpieces: CNNs Leveling Up Their Vision</h3><p>What’s actually happening inside the <strong>convolutional layers</strong> of a CNN? Let’s dive into the fascinating process that transforms raw pixels into meaningful features. When a <strong>filter</strong> slides over a region of the image (say a <strong>3x3 patch of pixels</strong>), it multiplies each pixel value by the corresponding weight in the filter. Then, it sums up the results. This single number, called <strong>neuron activation</strong>, tells us how strongly this filter “fired” for that particular region.</p><p>This <strong>dot product operation</strong> produces a <strong>feature map</strong>, which highlights where the filter detected certain patterns, like edges or textures. Early on, these patterns might look like <strong>fuzzy blobs</strong>, barely recognizable as anything meaningful. But as the network deepens, the filters learn to recognize more complex features, progressing from these abstract smudges to fully detailed shapes. It’s like going from a rough pencil sketch to a detailed drawing.</p><p>What’s even more intriguing is how the <strong>feature maps</strong> generated by earlier layers become the input for the next layer’s convolutions. This stacking of layers allows the network to build up a deeper understanding, detecting <strong>high-level features</strong>like circles, squares, or even entire objects (think eyes, faces, or cars) in later layers.</p><h3>The Power of Pooling: Reducing Complexity While Keeping Essentials</h3><p>While <strong>convolutional layers</strong> are busy detecting patterns, <strong>pooling layers</strong> step in to make things more efficient by reducing the size of the data. Their job? To shrink the feature maps and cut down on the number of parameters the model needs to juggle, all while lightening the computational load. The most common type, <strong>max-pooling</strong>, looks at small regions (like a 2x2 patch) and keeps only the most important value — the <strong>VIP pixel</strong> — while discarding the rest. This operation reduces the feature map’s size by 75%, but it keeps the <strong>depth</strong> (number of channels) intact, ensuring the network doesn’t lose crucial information as it simplifies the data.</p><p>Of course, max-pooling can be a little <strong>destructive</strong> — it tosses out a lot of data in favor of keeping only the maximum value. That’s why max-pooling typically sticks to a <strong>small 2x2 kernel</strong> with a <strong>stride of 2</strong> (basically, how far it jumps between regions). In some cases, you’ll see <strong>overlapping pooling</strong>, where the filter is a bit bigger (3x3), but it still slides by 2 pixels, allowing for a little overlap.</p><p>Now, max-pooling may be the crowd favorite, but there are other options too. <strong>Average pooling</strong> plays nice by taking the <strong>average</strong> of values in each region instead of the maximum. And then there are more advanced techniques like <strong>L1/L2 normalization</strong> for those who like to get fancy. But let’s be honest — max-pooling is the go-to because it just works, keeping things fast and efficient without overcomplicating the process.</p><blockquote>CNNs Aren’t Just About Vision,Here’s something mind-bending: while CNNs are famous for their use in image classification, they’re also being adapted for non-vision tasks like <strong>time-series analysis</strong> and <strong>graph data</strong>. In time-series data, CNNs can extract local patterns in the temporal dimension, and with graph convolutional networks, they’re being used to model relationships in graphs (like social networks or molecular structures).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uI4yFeX4fH3paCt2bArV7Q.png" /><figcaption>A typical CNN is like a blend of art and science, where <strong>convolutional layers</strong> are stacked with <strong>ReLU activations</strong>, layer after layer, before finally passing through a <strong>pooling layer</strong> to simplify the data</figcaption></figure><h3>The Final Touch: Predictions</h3><p>At the end of a CNN’s journey through layers of convolutions and pooling, we reach the <strong>fully connected layers</strong>. This is where the neural network takes all the information it’s gathered and makes its best guess about what it’s “seeing.” And just like an art critic staring at a masterpiece, it assigns a label. “This,” it confidently declares, “is a <strong>snake</strong>.” Or a <strong>human</strong>. Or maybe even an <strong>alien</strong>, depending on what it’s been trained to recognize. If the CNN’s been trained well, this is where it confidently declares whether it’s seeing a <strong>cup of artisanal coffee, an intergalactic spaceship</strong>, or a <strong>pair of retro roller skates</strong>.</p><p><strong>Cross-entropy loss</strong> (for classification) compares the predicted probability distribution (e.g., the model’s guess that an image is 80% likely to be a futuristic skyscraper) with the true distribution (e.g., the label says the image is 100% a luxury yacht. This difference between the predicted and true probabilities helps guide the network to adjust its filters and weights.</p><p><strong>Backpropagation</strong> ensures that every mistake made by the network is a learning opportunity 😌. The network adjusts its filters and weights after every wrong prediction, gradually becoming more accurate over time. With enough training, these networks become visual wizards, capable of recognizing anything from <strong>handwritten poetry to galaxies far, far away</strong></p><h4>Fully Connected Layers and Classification:</h4><ol><li><strong>Flattening the Data:</strong><br>After the convolutional and pooling layers have extracted features, the resulting feature maps are flattened into a 1D vector. This vector serves as the input to the fully connected layers, where the classification happens.</li><li><strong>Fully Connected Layers (Dense Layers):</strong><br>These layers connect every neuron to every other neuron in the next layer. They take the learned features and perform the final classification, predicting the label for the image (e.g., “lipstick,” “ashtray,” etc.).</li><li><strong>Output:</strong><br>The final layer outputs class probabilities, with the highest probability representing the predicted class.</li></ol><p>But here’s where the magic happens: <strong>the learning.</strong> Every time the CNN gets it wrong, it learns from its mistakes. It tweaks its filters, adjusts its layers, and tries again. With enough training, these networks become incredibly accurate, turning them into visual wizards capable of recognizing anything from handwritten digits to galaxies far, far away.</p><h3>Are CNNs Perfect? Not Quite. They Struggle with Global Context</h3><p>While CNNs excel at <strong>local feature extraction</strong>, they often struggle with capturing the <strong>global context</strong> of an image efficiently. This is because the filters only look at small patches at a time. As you move deeper into the network, you eventually capture more global information, but by then, a lot of detail might be lost.</p><p>So, this is why recent innovations like <strong>Vision Transformers</strong> have started gaining attention — they don’t rely on small local patches but treat the image as a sequence of patches and learn the relationships between those patches in a global, non-local way.</p><h3>Beyond Vision: The Future of CNNs</h3><p>So yes, I get it. CNNs may seem like old news. But when you peel back the layers (pun intended)😛, you realize just how intricate, creative, and downright <strong>visionary</strong> these neural networks truly are. From <strong>group-equivariant CNNs</strong> (which are learning to recognize patterns under rotations and scaling) to <strong>hybrid models </strong>like <strong>Vision Transformers</strong>, the future of CNNs is still wide open.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b1757f4d835" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Objects, Assemble! Object Detection Gets a Transformer Upgrade ]]></title>
            <link>https://medium.com/@sahasra007k/objects-assemble-object-detection-gets-a-transformer-upgrade-1215258d170e?source=rss-162822c2bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/1215258d170e</guid>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Sahasra_7k]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 09:42:07 GMT</pubDate>
            <atom:updated>2024-10-17T09:42:07.571Z</atom:updated>
            <content:encoded><![CDATA[<h4>From Anchors to Attention: A New Chapter in Object Detection</h4><p>Picture a bustling city street, with cameras perched on lampposts and buildings, tirelessly scanning for the unexpected. From recognizing a wandering pedestrian to tracking a passing car, the task of object detection has long relied on the sharp eyes of <strong>Convolutional Neural Networks (CNNs)</strong>. But as cities get busier and the need for smarter surveillance grows, a new player steps into the frame: <strong>Transformers</strong>.</p><p>Gone are the days when object detection systems needed carefully engineered <strong>anchor boxes</strong> and multi-stage architectures. Today, we’re venturing into a realm where objects seem to assemble themselves in full view — enter <strong>DETR (DEtection TRansformers)</strong>, a breakthrough that reimagines how machines detect objects. With this upgrade, the future of computer vision just got a serious makeover.</p><h3>The Transformer Revolution: From Words to Vision</h3><p>Transformers, once dominant in <strong>NLP</strong>, now apply their <strong>attention mechanism</strong> to detect objects in images, revolutionizing <strong>computer vision</strong></p><p>The <a href="https://arxiv.org/pdf/2005.12872v3">DETR paper</a>, published by Facebook AI, answers that question. It takes the same transformer architecture and applies it to object detection, skipping the anchor boxes and region proposals that traditional CNN-based models rely on. Instead, DETR uses <strong>attention</strong> to locate objects and decide what’s worth looking at.</p><p><strong>Why does this matter?</strong> In short, transformers are breaking free from language and starting to <strong>reconstruct visual data</strong> with better efficiency and accuracy. This shift opens up entirely new possibilities for real-time object detection and simplifies the entire process.</p><h3>A New Blueprint: How DETR Works</h3><h4>Building Blocks: From CNNs to End-to-End Simplicity</h4><p>So how does DETR work? Imagine trying to build a model with no pre-defined concepts of where objects might be. Instead of relying on manually defined anchor boxes — which are like predetermined “search zones” — DETR asks the transformer to figure out where objects are by itself. The transformer encoder processes the image, and the decoder works with object queries to pinpoint and classify objects in an end-to-end manner.</p><p>This approach changes the rules. Traditional models like Faster R-CNN were like hunters: tracking objects based on a pre-designed map. In contrast, DETR is like an investigator, piecing together the clues to find objects based on learned patterns rather than guesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06VX7KrVv2txAtnfHAcs9Q.png" /></figure><p>In the image above, <strong>DETR</strong> predicts object detections in parallel by combining a CNN backbone with a transformer, using bipartite matching during training to uniquely assign predictions to ground truth boxes. Unmatched predictions are classified as “no object”.</p><h4>Object Queries: The Sherlock Holmes of Detection</h4><p>In the world of DETR, object queries act as the detectives. Instead of being spoon-fed <strong>“anchor locations,”</strong> these queries look across the entire image, asking questions like, “Where are the important objects?” and “What are they?” By removing the need for proposals or sliding windows, the entire system becomes simpler, more elegant, and completely end-to-end.</p><h3>Attention, Please! Why the DETR Mechanism Shines</h3><p>At the heart of the transformer lies its secret weapon: multi-head attention. This allows the model to focus on multiple areas of the image simultaneously, gathering context from different regions. Each “attention head” zooms in on a specific part of the image and then collaborates with other heads to build a bigger picture.</p><p>The transformer decoder — the same mechanism used in language translation — turns out to be a perfect fit for vision. With attention heads scanning every inch of the image, DETR can detect occluded objects, focus on key areas, and avoid redundant detections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DP27515-FHbQqy-rF5OFRQ.png" /></figure><p>In the above image, <strong>DETR</strong> uses a CNN backbone to create a 2D representation of the input image, which is flattened and passed through a transformer encoder along with positional encodings. A fixed number of <strong>object queries</strong> are processed by the transformer decoder, and each output is passed through a feed-forward network to predict the class and bounding box or “no object” for each query</p><h4>Zooming In: The Magic of Multi-Head Attention</h4><p>It’s as though each attention head is an <strong>eye in the sky</strong>, ensuring nothing escapes its gaze. Whether it’s identifying cars on a freeway or tracking a basketball on a court, DETR’s attention heads ensure that no object is left behind.</p><h3>Key Ablations and Findings:</h3><p>DETR’s development involved a series of <strong>ablation studies,</strong></p><ul><li><strong>Number of Encoder Layers</strong>: Global <strong>self-attention</strong> helps disentangle objects. Removing encoder layers drops <strong>AP</strong>(Average Precision) by <strong>3.9 points</strong>, especially affecting large objects.</li><li><strong>Number of Decoder Layers</strong>: <strong>Auxiliary losses</strong> are applied at each decoding stage, More decoder layers improve performance, with an <strong>+8.2/9.5 AP increase</strong> from the first to the last layer. Initial layers benefit from <strong>Non-Maximum Suppression (NMS)</strong> to reduce duplicate predictions, but this becomes unnecessary in deeper layers.</li><li><strong>Feed-Forward Networks (FFN)</strong>: Removing FFNs significantly drops performance (<strong>-2.3 AP</strong>), showing their critical role in predictions.</li><li><strong>Positional Encodings</strong>: Output encodings (object queries) are essential, while removing spatial encodings only results in a minor AP drop of <strong>1.3 points</strong>.</li></ul><blockquote><strong>Auxiliary losses</strong> are additional losses applied at intermediate stages of a model to improve training stability and enhance performance.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnYeBVXnj-MPTcT82tvQnQ.png" /><figcaption>Encoder self-attention helps separate individual instances, with predictions made by the baseline <strong>DETR</strong> model on validation set images</figcaption></figure><h3>What’s New? The Perks and Challenges of DETR</h3><h4>The Good, The Fast, and the Computationally Hungry</h4><p>DETR’s end-to-end training means there’s no need for the complex post-processing that old-school models require. This makes the model more straightforward, less prone to error, and adaptable. But every new breakthrough comes with its trade-offs. While DETR simplifies object detection, its training time can be longer due to its demand for compute resources.</p><h4>Prediction Feed-Forward Networks (FFNs) in DETR</h4><p>The <strong>Feed-Forward Network (FFN)</strong> in <strong>DETR</strong> is a small neural network with 3 layers. It predicts:</p><p><strong>Bounding Box Coordinates</strong>: The center, height, and width of the object in the image and <strong>Class Labels</strong>: Using a softmax function to classify detected objects.</p><p>Since DETR predicts a fixed number of bounding boxes (N), some slots may not contain an object. For these, a special <strong>“no object” (∅)</strong> class is used, similar to how traditional models handle background regions.</p><h4>Comparision with Faster R-CNN</h4><ul><li><strong>Training Setup</strong>: DETR is trained with <strong>Adam</strong> optimizer, long schedules, and <strong>dropout</strong>, while Faster R-CNN uses <strong>SGD</strong>with minimal augmentation and no dropout.</li><li><strong>Enhancements for Fair Comparison</strong>: Faster R-CNN was strengthened by adding <strong>generalized IoU</strong> to the box loss, using <strong>random crop augmentation</strong>, and extending the training schedule, which improved results by <strong>1–2 AP</strong>.</li><li><strong>Performance</strong>: Both models have <strong>41.3M parameters</strong>, but DETR excels at <strong>large object detection</strong> (+7.8 APL) while it struggles with <strong>small objects</strong> (-5.5 APS).</li><li><strong>ResNet-101 Backbone</strong>: Using a more powerful ResNet-101 backbone, both models show <strong>comparable results</strong> on the COCO validation subset..</li></ul><h4>Big Gains, Small Objects: The DETR Dilemma</h4><p>While DETR shines in many areas, DETR can be <strong>competitive</strong> with Faster R-CNN in overall performance, but still lags in small object detection can still pose a challenge. This is where research is heading next. Deformable DETR addresses this limitation by allowing attention to focus on finer details in small objects, making transformers even more versatile in the vision space.</p><h3>Transformers at Work: Real-World Applications</h3><h4>From Pixels to Reality: DETR’s Use Cases</h4><p>So, what can DETR do outside the lab? Its applications are vast and growing. In the world of autonomous driving, DETR’s ability to detect multiple objects in real time makes it a perfect match for safety-critical environments. In surveillance, the model can spot anomalies faster than traditional systems, reducing the burden on human operators.</p><h4>From Streets to Screens: How DETR is Driving the Future</h4><p>Whether it’s ensuring pedestrian safety or powering the next-gen security systems, DETR’s flexibility offers a glimpse of how transformers will revolutionize more than just language processing.</p><h3>The Road Ahead for Transformers in Vision</h3><h4>Breaking New Ground: The Future of Object Detection</h4><p>As transformers evolve, the field of computer vision is bound to change rapidly. What started with DETR has already evolved into Deformable DETR, and there are countless other models on the horizon that will take these concepts even further. With time, transformers may become the go-to choice for object detection in all industries, from healthcare to retail.</p><h3>Conclusion: Assembling the Future with DETR</h3><p>This approach achieves comparable results to an optimized Faster R-CNN baseline on the challenging COCO dataset. In addition, <strong>it achieves significantly better performance on large objects than Faster R-CNN</strong>, likely thanks to the processing of global information performed by the self-attention.</p><p>The age of <strong>transformers</strong> in vision has only just begun. With <strong>DETR</strong> leading the charge, the potential for simplified, real-time object detection is limitless.</p><p><strong>So, what’s next?!</strong> <strong>Stay tuned, because as transformers continue to assemble</strong>, <strong>the world of computer vision will never look the same.</strong> 😉</p><p><em>Please do refer to my previous blogs, on </em><a href="https://medium.com/@sahasra007k/attention-attention-7279146b5596"><em>Attention mechanism</em></a><em> and </em><a href="https://medium.com/@sahasra007k/beyond-words-and-images-exploring-the-role-of-transformers-in-text-and-vision-14222f4740cc"><em>Transformers</em></a></p><p><strong><em>Note:</em></strong><em> This blog provides insights from cutting-edge research papers to highlight key innovations in object detection and computer vision</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1215258d170e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>