<?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 Dedeepya Lekkala on Medium]]></title>
        <description><![CDATA[Stories by Dedeepya Lekkala on Medium]]></description>
        <link>https://medium.com/@deepyachowdary?source=rss-1635f95d7aa3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jyYJs2GasPihhLzUqPLPAw.jpeg</url>
            <title>Stories by Dedeepya Lekkala on Medium</title>
            <link>https://medium.com/@deepyachowdary?source=rss-1635f95d7aa3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:11:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deepyachowdary/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[Embeddings: The Mathematics Behind Language Models (Part 1)]]></title>
            <link>https://medium.com/@deepyachowdary/embeddings-the-mathematics-behind-language-models-part-1-e24e9780d777?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e24e9780d777</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 15:18:56 GMT</pubDate>
            <atom:updated>2025-09-06T15:20:59.059Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last post, we explored the <a href="https://medium.com/@deepyachowdary/the-journey-of-language-models-9e0088d8e53b">journey of language models </a>— how they evolved from simple statistical methods to powerful transformer-based architectures. But this raises an important question: <em>when we type words or sentences, how do these models actually understand them?</em></p><p>Computers don’t “see” words the way humans do — to them, text is just raw symbols. To make sense of language, we need to turn these symbols into numbers. That’s where <strong>embeddings</strong> come in.</p><p>Embeddings are mathematical representations of words, sentences, or even documents. They allow language models not just to process text, but to <strong>capture meaning, context, and similarity</strong> — the key ingredients behind modern NLP and LLMs.</p><p>In this post (Part 1 of the series), we’ll start from the basics — <strong>One-Hot vectors, Bag of Words, and TF-IDF</strong> — and see why they fall short, paving the way for dense, learned embeddings that power today’s neural networks and transformers.</p><h3>Why Do We Need Embeddings?</h3><p>When we type words or sentences, computers don’t really <em>understand</em> them. For a machine, text is just a sequence of symbols. So, to make language machine-readable, we need a way to convert words into numerical form.</p><h3>1. The naive way: One-Hot Encoding</h3><p>One of the earliest methods was <strong>one-hot vectors</strong>. Imagine we have a vocabulary of 5 words:</p><p>[“apple”, “banana”, “cat”, “dog”, “king”]</p><p>We represent each word as a binary vector where only one position is “hot” (1) and the rest are zeros:</p><ul><li>apple → [1, 0, 0, 0, 0]</li><li>banana → [0, 1, 0, 0, 0]</li><li>cat → [0, 0, 1, 0, 0]</li></ul><p><strong>Quick Implementation in Python</strong></p><pre>import numpy as np<br><br>vocab = [&quot;apple&quot;, &quot;banana&quot;, &quot;cat&quot;, &quot;dog&quot;, &quot;king&quot;]<br>word_to_index = {word: i for i, word in enumerate(vocab)}<br><br>def one_hot_encode(word, vocab_size=len(vocab)):<br>    vector = np.zeros(vocab_size)<br>    vector[word_to_index[word]] = 1<br>    return vector<br><br>print(one_hot_encode(&quot;apple&quot;))</pre><p>But here’s the problem:</p><ul><li>These vectors are <strong>sparse</strong> (mostly zeros).</li><li>They don’t capture <strong>meaning</strong> (to the machine, “apple” and “banana” are as unrelated as “apple” and “king”).</li><li>The vectors are huge for large vocabularies (imagine 100,000 words → a 100k-dimensional vector).</li></ul><p><strong>Beyond One-Hot: Need for Meaning</strong></p><p>To go further, we want vectors that capture relationships:</p><ul><li><em>“apple”</em> should be close to <em>“banana”</em> (both are fruits).</li><li><em>“king”</em> should relate to <em>“queen”</em> in a meaningful way.</li></ul><p>But before we get there, let’s see another early idea: instead of encoding words one by one, what if we try to represent an entire <strong>sentence</strong>?</p><h3>2. Bag of Words (BoW)</h3><p>The idea is simple: just <strong>count how many times each word appears</strong> in the sentence.</p><p>Let’s take two sentences:</p><ol><li><em>“I love dogs”</em></li><li><em>“I love cats and dogs”</em></li></ol><p>Vocabulary: [“I”, “love”, “dogs”, “cats”, “and”]</p><pre>| Sentence             | I | love | dogs | cats | and |<br>| -------------------- | - | ---- | ---- | ---- | --- |<br>| I love dogs          | 1 | 1    | 1    | 0    | 0   |<br>| I love cats and dogs | 1 | 1    | 1    | 1    | 1   |</pre><p>So each sentence becomes a vector:</p><ul><li>“I love dogs” → [1, 1, 1, 0, 0]</li><li>“I love cats and dogs” → [1, 1, 1, 1, 1]</li></ul><p><strong>Quick Implementation in Python</strong></p><pre>from sklearn.feature_extraction.text import CountVectorizer<br><br>sentences = [&quot;I love dogs&quot;, &quot;I love cats and dogs&quot;]<br>vectorizer = CountVectorizer()<br>X = vectorizer.fit_transform(sentences)<br><br>print(vectorizer.get_feature_names_out())<br>print(X.toarray())</pre><p>But Here’s the Problem with BoW</p><ul><li><strong>Word order is lost</strong> → “dog bites man” and “man bites dog” look identical.</li><li><strong>Sparse vectors again</strong> → larger vocabulary = longer, mostly-zero vectors.</li><li><strong>No meaning captured</strong> → “dog” and “puppy” are just different columns, even though they’re related.</li></ul><p>Clearly, BoW is an improvement over one-hot, but it still treats words as raw counts. Every word is considered equally important — but in real text, that’s not true.</p><h3>3. TF-IDF (Term Frequency–Inverse Document Frequency)</h3><p>BoW treats all words equally, but not all words are equally important. For example, “the” and “is” appear everywhere, while words like “Python” or “quantization” are much more informative.</p><p>That’s where <strong>TF-IDF</strong> comes in. It weighs words by importance by combining two ideas:</p><ul><li><strong>Term Frequency (TF):</strong> How often does a word appear in a document?</li><li><strong>Inverse Document Frequency (IDF):</strong> How rare is this word across all documents?</li></ul><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*LktxoQZHQtLhSppNkvkgcQ.png" /></figure><p>Where:</p><ul><li>t = term (word)</li><li>d = document</li><li>N = total number of documents</li><li>DF(t) = number of documents containing term t</li></ul><p>Let’s break it down:</p><p><strong>TF (Term Frequency):</strong></p><ul><li>How often does a word appear in the current document?</li><li>Example: In <em>“I love dogs”</em>, the word <em>“dogs”</em> appears once → TF = 1.</li></ul><p><strong>IDF (Inverse Document Frequency):</strong></p><ul><li>How unique is this word across all documents?</li><li>If a word appears in <em>every</em> document, it’s not very informative.</li><li>If a word appears in just one or two documents, it’s more special.</li></ul><p>The log part:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*fONG2EAiwYhWOqHkvYi_GQ.png" /></figure><p>makes common words (<em>“the”, “is”</em>) get lower weights, while rare words (<em>“Python”</em>, <em>“Coding”</em>) get higher weights.</p><p>Suppose we have 3 documents:</p><ol><li><em>“I love dogs”</em></li><li><em>“I love cats and dogs”</em></li><li><em>“Cats are cute”</em></li></ol><ul><li>The word <em>“dogs”</em> appears in 2 out of 3 documents → IDF will be <strong>lower</strong>.</li><li>The word <em>“cats”</em> appears in 2 documents as well → medium IDF.</li><li>A word like <em>“cute”</em> appears in only 1 document → <strong>higher IDF weight</strong>.</li></ul><p>So TF-IDF highlights <em>“cute”</em> as more important in document 3, compared to filler words like <em>“I”</em> or <em>“love”</em> that appear everywhere.</p><p>Think of TF-IDF as saying:</p><blockquote>This word is important in this document <strong>if it appears a lot here</strong>, but <strong>not too much everywhere else</strong>.</blockquote><p><strong>Example:</strong></p><p>Suppose we have two sentences:</p><ol><li><em>“I love dogs”</em></li><li><em>“I love cats and dogs”</em></li></ol><p>Let’s compute TF-IDF using Python:</p><pre>from sklearn.feature_extraction.text import TfidfVectorizer<br><br>sentences = [&quot;I love dogs&quot;, &quot;I love cats and dogs&quot;]<br>vectorizer = TfidfVectorizer()<br>X = vectorizer.fit_transform(sentences)<br><br>print(vectorizer.get_feature_names_out())<br>print(X.toarray())</pre><p>Output :</p><pre>[&#39;and&#39; &#39;cats&#39; &#39;dogs&#39; &#39;love&#39; &#39;i&#39;]<br>[[0.    0.    0.707 0.5   0.5  ]<br> [0.577 0.577 0.408 0.408 0.408]]</pre><ul><li>In sentence 1, <em>“dogs”</em> has a higher weight than <em>“love”</em> or <em>“I”</em>.</li><li>In sentence 2, <em>“cats”</em> and <em>“and”</em> are given weight, but <em>“dogs”</em> gets less importance since it appears in both sentences.</li></ul><p>This way, TF-IDF captures which words are actually <strong>informative</strong>.</p><p><strong>Limitations of TF-IDF</strong></p><p>While TF-IDF improves on BoW, it still has drawbacks:</p><ul><li><strong>No context</strong> → “bank” (riverbank vs. money bank) gets the same vector.</li><li><strong>Still sparse</strong> → vectors are long for large vocabularies.</li><li><strong>No semantic meaning</strong> → “dog” and “puppy” are still unrelated.</li></ul><h3>The Next Step: Neural Embeddings</h3><blockquote>So the big question is: <strong>can we learn word vectors that actually capture meaning and context?</strong></blockquote><p>That’s exactly what neural embeddings do. Methods like <strong>Word2Vec, GloVe</strong>, and later <strong>Transformer-based embeddings</strong> place words in a continuous vector space where:</p><ul><li><em>“apple”</em> is close to <em>“banana”</em> (both are fruits)</li><li><em>“king” — “man” + “woman” ≈ “queen”</em></li></ul><p>Instead of hand-crafted math, neural networks learn these representations directly from data.</p><p>In my next post, We’ll dive into <strong>Word2Vec, GloVe, and contextual embeddings like BERT</strong> to see how they transformed NLP forever.</p><p>Stay tuned — and happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e24e9780d777" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Journey of Language Models]]></title>
            <link>https://medium.com/@deepyachowdary/the-journey-of-language-models-9e0088d8e53b?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e0088d8e53b</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[language-model]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 14:02:26 GMT</pubDate>
            <atom:updated>2025-09-06T15:26:16.977Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Language is at the heart of human communication— it helps us to share ideas, emotions, and knowledge. Teaching machines to understand and generate human language has been a longstanding goal in artificial intelligence (AI). This has led to the development of <strong>language models</strong>, which have evolved from simple statistical tools to complex systems capable of generating human-like text.</p><p>In this post we’ll take a high-level look at the journey of language models — from early approaches to advanced Large language Models( LLMs), highlighting the main concepts along the way.</p><p><strong>What is a Language Model ?</strong></p><p>Language modeling is how machines learn to <strong>understand</strong> and <strong>generate</strong> human language. It’s the technology behind things like:</p><ul><li>Autocomplete on your phone</li><li>Chatbots like ChatGPT</li><li>Google Translate</li><li>Voice assistants like Alexa</li></ul><p>At its heart, a <strong>language model</strong> is a system that guesses the <strong>next word</strong> in a sentence.</p><p><strong>Example: </strong>If I say:</p><p><em>“The cat sat on the ___”<br>You might guess:<br>“mat”, “floor”, or “sofa”</em></p><p>A language model is trained to make these guesses by learning from lots of text — books, websites, articles, etc.</p><p><strong>Math Behind Language Models</strong><br>Let’s say a sentence has a few words: w1, w2, w3…,wn . The goal of a language model is to find the <strong>probability</strong> of the full sentence:</p><blockquote>P(w1,w2,….wn)</blockquote><p>Using <strong>chain rule</strong> from probability, we can break this down as:</p><blockquote>P(w1,w2,….wn) = P(w1) * p(w2 | w1) * p(w3 | w1,w2) * ….. * P(wn | w1, w2, w3,…..wn-1)</blockquote><p>This simply means :</p><ul><li>What’s the chance of the first word?</li><li>Then the second word <strong>given</strong> the first one,</li><li>Then the third word <strong>given</strong> the first two, and so on.</li></ul><p>This is what a language model learns — to predict the next word based on the words before it. That’s the core idea behind language modeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*LhOxgnP3J930Prv7qjylWw.png" /><figcaption><strong>History and Development of Language Models</strong></figcaption></figure><p><strong>1. Statistical Language Models</strong></p><p>In the 1990s, the language models were designed using math to understand how likely a sentence is to appear in text. These are called <strong>Statistical Language Models (SLMs). </strong>The idea is to calculate the probability of a sentence by looking at each word and how it fits with the previous words.</p><blockquote>Let’s say we have the sentence:<br>“I am very happy”</blockquote><p>We want to find out how likely this sentence is. This is written as:</p><blockquote>P(I, am, very, happy)</blockquote><p>Using the chain rule from probability, we can break it down like this:</p><blockquote>P(I, am, very, happy) = P(I) × P(am | I) × P(very | I, am) × P(happy | I, am, very)</blockquote><p>This means:</p><p>First, how likely is the word “I”?</p><p>Then, how likely is “am” after “I”?</p><p>Then, how likely is “very” after “I am”?</p><p>Finally, how likely is “happy” after “I am very”?</p><p><strong>How do we calculate these probabilities?</strong></p><p>We use a method called Maximum Likelihood Estimation (MLE). It just means we count how often words appear together in real text.</p><p>So if we want the probability of a word wᵢ coming after previous words w₁, w₂, …, wᵢ₋₁, we use:</p><p>P(wᵢ | w₁, …, wᵢ₋₁) = Count(w₁, …, wᵢ) / Count(w₁, …, wᵢ₋₁)</p><p>This is like saying:</p><blockquote>“How often do all these words appear together?” divided by<br>“How often do just the first part of the sentence appear?”</blockquote><p>This approach forms the basis of <strong>n-gram models</strong> — where a word is predicted based on only a few words before it (like the last 2 or 3).</p><p><strong>2.Neural Language Models:</strong></p><p>Unlike statistical language Models, which rely heavily on counting word co-occurences, Neural Language Models generalize better by learning patterns in data through dense trainable word reperesentations(<strong>word embeddings</strong>) — that capture syntactic and semantic meaning. Methods like Word2Vec, GloVe, FastText are commonly used to learn these word embeddings such that words with similar meaning appear close in embedding space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*y5DgjG6oE5FeJ-DtWwA7Iw.png" /><figcaption><strong>Neural Language Model</strong></figcaption></figure><p>These models are typically implemented using neural network architectures such as <strong>feedforward networks</strong>, <strong>Recurrent Neural networks(RNNs)</strong>, <strong>Long Short-Term Memory(LSTM)</strong> networks.</p><p>These Neural Language Models(NLMs) can capture long-range dependencies and meanings far beyond what n-gram models can represent.</p><p><strong>3. Pre-trained Language Models</strong></p><p>Pretrained Language Models<strong>(PLMs) </strong>are powerful models trained on large amount of text data to understand how language works. This training helps the model to learn the core language patterns such as vocabulary, grammar, semantics, and even aspects of reasoning and world knowledge without needed any labelled answers. This phase is called pre-training.</p><p>After, pre-training the model can be adapted to specific downstream tasks like <strong>Machine Translation, Summarization, Question Answering , Sentiment Analysis etc</strong>, through more focused thraining phase called<strong> fine-tuning</strong>.</p><p>You can think of this like learning a language in school. In the beginning, you study grammar, vocabulary, and how to form sentences — this is like pre-training. Once you have a strong base, you can focus on a specific goal, like writing an essay, giving a speech, or passing a language test — this is like fine-tuning.</p><p><strong>Why Transformers ?</strong></p><p>The real breakthrough in PLMs came with the <strong>Transformer</strong> model, introduced in 2017. Before this, models like RNNs or LSTMs tried to understand language by reading one word at a time. But Transformers can read and understand <strong>all the words at once</strong> using a technique called <strong>self-attention</strong>.</p><blockquote>Let’s take a sentence as an example:<br> <strong>“The cat sat on the mat because it was tired.”</strong><br> Older models might struggle to understand what <em>“it”</em> refers to. But Transformers can look at the whole sentence at once and figure out that <em>“it”</em> means <em>“the cat”</em>.</blockquote><p>This makes them much better at understanding the meaning of complex sentences.</p><p>Because of this, Transformers became the backbone of famous PLMs like <strong>BERT</strong>, <strong>GPT</strong>, and <strong>RoBERTa</strong> — models that now are used in many AI applications.</p><p><strong>4. Large language Models</strong></p><p>Large Language Models (LLMs) are an advanced evolution of PLMs, trained on massive collections of text with tens or even hundreds of billions of parameters. Popular examples include<strong> GPT-3, GPT-4, PaLM, and LLaMA</strong>.</p><p>The main goal of LLMs is to help machines understand human instructions and respond in helpful, respectful ways. Training these models usually happens in two main steps:</p><ol><li><strong>Pre-training: </strong>In this step model learns language patterns from the data its being trained on (eg: wikipidea , websites, books etc)</li><li><strong>Alignment :</strong> Through techniques like <strong>Reinforcement Learning from Human Feedback (RLHF)</strong> — model is finetuned using feedback from humans to make sure it responds in a safe, helpful and responsible way.</li></ol><p>Unlike earlier models that were more task-specific, LLMs are general-purpose. With minimal or no additional training, they can switch between different tasks such as summarizing text, translating languages, answering questions, writing stories, and even generating code.</p><p>What makes LLMs special is their ability to learn from context. For example, GPT-3 can understand what you want just by looking at a few examples in the prompt — this is known as<strong> in-context learning</strong>. GPT-2, a smaller predecessor, could not do this effectively and need more training to do the same tasks.</p><p>For example,</p><blockquote>GPT-2: 1.5 billion parameters, trained on about 40GB of text.</blockquote><blockquote>GPT-3: 175 billion parameters, trained on around 570GB of text.</blockquote><p>This massive increase in model size and training data allows LLMs to perform tasks with greater fluency, accuracy, and flexibility — often matching or even exceeding human performance in certain benchmarks.</p><p><strong>Summary :</strong></p><p>From simple n-gram models to neural networks like RNNs and LSTMs, and eventually to Transformers and LLMs, the progress in language models shows how much we’ve come in teaching machines to understand and generate human language.</p><p>Each step has made these models smarter:</p><ul><li>N-gram models could predict the next word based on a few previous ones.</li><li>Neural models could remember longer sequences and learn better language patterns.</li><li>Transformers unlocked the ability to model global context with attention.</li><li>LLMs brought everything together — scale, context, and general-purpose intelligence — starting a new era of human-AI interaction.</li></ul><p>In my <a href="https://medium.com/@deepyachowdary/embeddings-the-mathematics-behind-language-models-part-1-e24e9780d777">next series of posts</a>, we’ll start uncovering the mathematics behind language models. We’ll begin with embeddings — the building blocks that allow machines to understand meaning and similarity in language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e0088d8e53b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Data Simpler with Principal Component Analysis(PCA)]]></title>
            <link>https://medium.com/@deepyachowdary/making-data-simpler-with-principal-component-analysis-pca-20a910a449d6?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/20a910a449d6</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[dimensionality-reduction]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Thu, 25 Jan 2024 12:24:53 GMT</pubDate>
            <atom:updated>2024-02-03T08:22:28.543Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://medium.com/@deepyachowdary/feature-selection-vs-feature-extraction-2fd95308a9bd">previous post </a>we’ve already looked at techniques like Feature Extraction and Feature Selection.Now, let’s understand <strong>Principal Component Analysis (PCA)</strong>, a method that standsout in simplifying complex datasets and retaining essential information.</p><p>Let’s Imagine our data as a vast sea with many waves and details. Feature Extraction and Feature Selection are like tools to understand these waves. and think of PCA as a special compass guiding us through this sea of complex data.</p><h3>What is PCA?</h3><p>Principal Component Analysis, or PCA, is a method to reduce the complexity of large datasets by identifying the most crucial features. The primary objective of PCA is to transform data from a higher-dimensional space to a lower-dimensional space while preserving the inherent relationships and patterns within the data.</p><h4>Exploring the Core of PCA</h4><p>Now, you might be wondering: “If PCA transforms data to a lower dimension, won’t there be a loss of information? What’s the point?”</p><p>Indeed, transitioning from a higher-dimensional space to a lower one in PCA involves a potential loss of information. But let’s look into what PCA achieves despite this trade-off.</p><p>PCA doesn’t just aim to decrease dimensionality; its main purpose is to discover the important patterns of the data. By selecting the most crucial features, or principal components, PCA ensures that we retain the maximum variability within the dataset.</p><p>PCA accomplishes this by projecting higher-dimensional data onto a new coordinate system where the axes are orthogonal to each other. Imagine you have a 5-dimensional dataset — PCA introduces a set of new dimensions (as many as the original dimensions), and it selectively chooses a few of these new dimensions or axes that explain the most variation in the data.</p><blockquote>In simpler terms, think of PCA as a guide in a photo studio. Imagine you have a photo with many colors and details, representing your data. Now, instead of using all the colors, PCA is like the guide recommending few crucial shades that retain the essence of the picture.It’s not about throwing away colors but about choosing the most important ones that define the main themes and patterns in the image.</blockquote><h3>Mathematics behind PCA</h3><p>Given a dataset X with n samples and d dimensions, PCA aims to find a unit vector U that, when the data is projected onto it, maximizes the variance.</p><p><strong>Notation:</strong></p><ul><li><strong>X: </strong>Dataset</li><li><strong>U:</strong> Unit vector representing a direction</li><li><strong>Var(XU): </strong>Variance of the data when projected onto U</li></ul><p><strong>Optimization Problem:</strong> The goal of PCA is to find a unit vector U that maximizes Var(XU), subject to the constraint that the length of U is 1 (|U|=1).</p><p>By solving the constrained problem using Lagrange Multiplier, we get <strong><em>SU</em>=<em>λU</em></strong> .</p><p>Here, <em>S</em> is the covariance matrix of <em>X</em>, <em>U</em> is the eigenvector of <em>S</em>, and <em>λ</em> is an eigenvalue of <em>S</em>. So, what does this solution mean?</p><blockquote>In simpler terms, it implies that the variance of the projected data would be maximum when the unit vector <em>U</em> is the eigenvector of the covariance matrix <em>S</em> of the data.</blockquote><p><strong>Eigenvalues and Eigenvectors: </strong>Think of your dataset as a landscape, and PCA as identifying crucial mountains (eigenvalues) and the directions of these mountains (eigenvectors).</p><ul><li><strong>Eigenvalues (λ):</strong> Signify the importance of corresponding eigenvectors. Higher values mean more crucial directions capturing data variability.</li><li><strong>Eigenvectors (u): </strong>Indicate directions where data varies the most. Each eigenvector is associated with a specific eigenvalue</li></ul><p><strong>Calculation</strong></p><p>Let’s assume the dataset <em>X</em> to be as follows and below are the steps PCA follows to determine the new coordinate axes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qHJzNqn136fI4_QzxQlxTg.png" /><figcaption>D Dimensional Dataset</figcaption></figure><p><strong>Step 1: Covariance Matrix (S):</strong></p><p>Calculate the covariance matrix <em>S</em> for the dataset X:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*g-FE1oPrnQV3z1K5TxewOw.png" /><figcaption>Covariance Matrix</figcaption></figure><p>Where ˉ<em>X</em>ˉ is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*R_W8KxRUP2aBArQOLnlzYA.png" /><figcaption>Mean Vector</figcaption></figure><p><strong>Step 2: Eigen Decomposition:</strong></p><p>Find the eigenvalues (<em>λ</em>) and eigenvectors (<em>u</em>) of the covariance matrix <em>S</em>: i.e <em>Su</em>=<em>λu</em></p><p><strong>Step 3: Selecting Principal Component:</strong> The eigenvalues represent the amount of variance explained by each eigenvector. PCA ranks these eigenvalues in descending order. The higher the eigenvalue, the more variance the corresponding eigenvector captures.</p><ul><li>PCA chooses the top k eigenvectors based on the desired level of varianc we want.</li><li>These chosen eigenvectors are the principal components that are used to project our data into a lower-dimensional space.</li></ul><blockquote>In simpler terms, let’s say our eigenvalues are [3.5, 1.8, 0.2], and the corresponding eigenvectors are [0.8, 0.5, 0.3], [0.2, 0.7, 0.6], and [0.5, 0.4, 0.8]. PCA chooses the top two eigenvectors with the highest eigenvalues (3.5 and 1.8) as principal components.</blockquote><p><strong>Step 4: Projection Matrix <em>XU</em>: </strong>The projection matrix <em>XU</em> is formed by stacking the selected eigenvectors horizontally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*ZeL2HgEAU77YIS7yIGF7BQ.png" /><figcaption>Projection Matrix</figcaption></figure><p><strong>Step 5: Projecting the Data: </strong>To transform the original data matrix X using the selected principal components, simply multiply X by the matrix formed from stacking these components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*spClqFqQP29b43ykurkKvg.png" /></figure><p>If <em>X</em> is our original dataset with dimensions [x₁, x₂, x₃], and if we have chosen the top two principal components eigenvector1​ and eigenvector2​, the transformed dataset (<em>X</em>new​) in the lower-dimensional space is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*psjFy1W849Fz3MJhuOuT-g.png" /></figure><ul><li>The new dataset <em>X</em>new​ in the lower-dimensional space retains the most significant information from the original data. It simplifies the dataset by focusing on the principal components that contribute the most to the overall variability.</li><li>In our example, instead of dealing with three features (x₁, x₂, x₃), we now have a simplified representation with two features (<em>X</em>new1​,<em>X</em>new2​).</li></ul><blockquote>So, in summary, PCA is a powerful tool that helps us simplify complicated data while retaining the essential information.</blockquote><p>Now, that we have seen the details of PCA, let’s look into its limitations despite its effectiveness.</p><h3>Limitations:</h3><p>Despite PCA’s effectiveness in simplifying data, there are a few things to be aware of while using PCA:</p><ol><li><strong>Outlier Sensitivity: </strong>PCA can besensitive to outliers. If your data has outliers, PCA might pay too much attention to them and give results that don’t truly represent the majority of your data.</li></ol><p><em>For example, consider a dataset of people’s salaries where the majority falls between $40,000 and $100,000, but there’s a single extreme outlier earning $10 million. In such a case, PCA might give more significance to this outlier, leading to a skewed representation of the overall salary distribution. This, in turn, can impact the identified patterns in the data</em>.</p><p><strong>2. Linear Assumption:</strong> PCA assumes that relationships between data points are straight lines.Where as it might not always be the case in the real world. When dealing with more complex relationships, PCA might not be the best fit.</p><p><em>It’s like expecting a GPS designed for straight roads to navigate a curvy mountain which will not always be the best fit.</em></p><p><strong>3. Not the Best for Non linear Data : </strong>For datasets with non-linear patterns, PCA might not be good choice .</p><p>So, when the assumptions of PCA fail, techniques like<strong> t-SNE</strong>, <strong>UMAP</strong>, <strong>Isomap</strong>, <strong>Autoencoders</strong>, <strong>LLE</strong>, and <strong>Random Projection</strong> can be used. These methods handle situations where PCA might struggle, providing more accurate results for complex data.</p><p><strong>Conclusion:</strong></p><p>So, in conclusion While PCA is a strong tool , there are always new techniques emerging in dimensionality reduction and explore more advanced approaches for specific situations.Sometimes, trying out different methods can make our data analysis even more insightful.</p><p><em>Stay Tuned &amp; Happy learning !!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20a910a449d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feature Selection Vs Feature Extraction]]></title>
            <link>https://medium.com/@deepyachowdary/feature-selection-vs-feature-extraction-2fd95308a9bd?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd95308a9bd</guid>
            <category><![CDATA[feature-extraction]]></category>
            <category><![CDATA[feature-selection]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[dimensionality-reduction]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Tue, 05 Sep 2023 07:33:32 GMT</pubDate>
            <atom:updated>2024-01-23T13:17:25.561Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>After data preprocessing, the next crucial step in any data analysis or machine learning project is handling the issue of high dimensionality. Real-world datasets often come with a variety of features, and while more data can be beneficial, it can also introduce challenges. High dimensionality can lead to increased computational demands, overfitting, and a decrease in model interpretability.</p><p>In this blog post, we will explore dimensionality reduction techniques, specifically focusing on two fundamental approaches: <strong>Feature Extraction</strong> and <strong>Feature Selection</strong>. These techniques play an important role in simplifying complex datasets, can help us extract valuable insights and build more robust predictive models.</p><p><strong>What is Dimensionality Reduction?</strong></p><p>Dimensionality Reduction is the process of systematically reducing the number of features in a dataset while retaining the important information.It reduces the challenges posed by the high-dimensional datasets.When we say “<strong>high dimensionality</strong>,” we are referring to datasets with a large number of features or variables.</p><p><strong>The Need for Dimensionality Reduction</strong></p><p>Imagine working with a dataset that has hundreds or even thousands of features. The complexity of such data can lead to several issues:</p><ol><li><strong>Increased Computational Demands:</strong> Processing and analyzing high-dimensional data can be computationally expensive and time-consuming. It may even exceed the capabilities of our hardware.</li><li><strong>Overfitting:</strong> In high-dimensional spaces, machine learning models may become more complex, fitting the noise rather than the underlying patterns in the data. This phenomenon, known as <strong>overfitting</strong>, can severely impact a model’s predictive power.</li><li><strong>Loss of Interpretability: </strong>As the number of features increases,models become less interpretable. It becomes harder to pinpoint which features are most influential in making predictions.</li></ol><h3>Techniques of Dimensionality Reduction:</h3><p><strong>Feature Extraction: </strong>Feature extraction involves extracting valuable information from the initial feature set to generate a new, reduced feature space. Its main objective is to compress data while retaining the most important information.</p><p>Let’s think about working with pictures of people’s faces. Each picture has lots of tiny details, like how bright or dark each pixel is. Imagine having thousands of these details for each face — it’s like having too much information.</p><p>Now, if you want to teach a computer to recognize these faces, dealing with all those thousands of details for each face is really hard and takes a lot of computer power and, not all of those details are important for recognizing faces.</p><p>So, here’s where Feature Extraction helps:</p><ul><li>Feature Extraction is like a smart tool that looks at all those tiny details in the pictures and picks out a few really important things.</li><li>Feature Extraction makes the pictures simpler but still keeps the important stuff that helps the computer recognize faces.</li><li>It’s like making a shortcut to understand faces better without all the complex details.</li></ul><p>Some common techniques used for feature extraction are <strong>Principal Component Analysis (PCA) </strong>and <strong>Linear Discriminant Analysis (LDA)</strong>.</p><p><strong>Feature Selection: </strong>Instead of creating new features, Feature Selection focuses on choosing a subset of the existing features that contribute most significantly to the problem. This process eliminates irrelevant or redundant features while preserving the important ones.</p><p>Imagine you’re creating a health app for smartwatches. These watches can track many health things like heart rate, temperature, sleep, steps, and more.</p><p>Here’s how Feature Selection applies in this scenario:</p><ul><li>The app collects lots of health info, like heart rate, temperature, sleep, and steps. Each piece of info is like a building block.</li><li>Instead of using all the building blocks, Feature Selection is like picking only the most important ones. It chooses things like heart rate and sleep because they tell us lot about a person’s health.</li><li>Now, your app only looks at heart rate and sleep, so it’s simpler to use and understand simplifying the analysis process.</li></ul><p>Types of Feature Selection Methods:</p><ol><li>Filter Methods</li><li>Wrapper Methods</li><li>Embedded Methods</li><li>Greedy Feature Selection Algorithms</li><li>Recursive Feature Elimination with Cross-Validation (RFECV)</li><li>Sequential Feature Selection Methods</li></ol><p><strong>Choosing between Feature Selection and Feature Extraction</strong></p><p>Usually the choice depends on your specific dataset, problem, and goals. Below are the steps that can help you decide.</p><p><strong>Choose Feature Extraction when:</strong></p><ol><li>If you believe that there might be meaningful combinations of existing features that can capture essential patterns or relationships in your data, go for Feature Extraction. It’s useful when the original features may not adequately represent the underlying structure of the data.</li><li>If you’re dealing with extremely high-dimensional data, and reducing dimensionality is a top priority, Feature Extraction, like Principal Component Analysis (PCA) or Linear Discriminant Analysis (LDA), can be effective in compressing data while retaining key information.</li><li>Feature Extraction involves transforming the data into a new feature space, which may not have a direct interpretation in the original domain. If you’re comfortable with this transformation and are focused on improved model performance, this approach can be beneficial.</li></ol><p><strong>Choose Feature Selection when:</strong></p><ol><li>If it’s really important to keep your data’s original meaning and not change it too much, Feature Selection is the way to go. It allows you to keep the most relevant features while discarding the rest.</li><li>Feature Selection is like finding the best parts in a book without rewriting the whole story. It’s fast because it doesn’t create new features like Feature Extraction. So, if you don’t have a lot of time or your computer isn’t super powerful, go for Feature Selection.</li><li>If you suspect that some of your data doesn’t really matter or is just repeating what other data says, Feature Selection helps get rid of it. This makes your models simpler and better because they focus on what’s really useful</li><li>Feature Selection often results in models that are easier to explain and interpret.This is important in fields like healthcare or finance, where people need to know why a decision was made.</li></ol><p>In summary, the right feature selection method depends on your unique problem, dataset, and the type of model you’re using.Some methods are better suited for linear models, while others work well with tree-based models or high-dimensional data. It’s often best to try out different techniques and see which one works best for your specific task.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd95308a9bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Different Activation Functions]]></title>
            <link>https://medium.com/@deepyachowdary/understanding-different-activation-functions-6aed5ed1c785?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aed5ed1c785</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[mathematical-equations]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 06:31:39 GMT</pubDate>
            <atom:updated>2023-08-15T06:39:44.894Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://medium.com/@deepyachowdary/power-of-activation-functions-a-beginners-guide-to-neural-network-building-blocks-f911f9451ec5">previous post</a> , we looked into significance of activation functions in neural networks and explored why nonlinearity is the secret ingredient that gives these networks their remarkable capabilities.In this post lets deep dive into various activation functions.</p><p>Let’s begin by exploring the key properties of Activation Functions</p><ol><li><strong>Nonlinearity: </strong>This is the most fundamental property, activation functions introduce nonlinearity into the network. This is important because real-world relationships and patterns are rarely linear. Nonlinear activation functions enable neural networks to capture complex structures and solve complex problems.</li><li><strong>Range: </strong>Activation functions have specific output ranges that affect how information is propagated through the network. Some functions produce outputs between 0 and 1 (Sigmoid, Tanh), while others span from 0 to infinity (ReLU) or from -1 to 1 (Tanh).</li><li><strong>Monotonicity:</strong> A monotonic activation function either strictly increases or strictly decreases as input values change. This property ensures that as inputs change, the neuron’s output moves in a consistent direction.</li><li><strong>Continuity: </strong>A continuous activation function produces smooth and continuous changes in output as inputs change slightly. This property helps in smooth gradient computations during backpropagation.</li><li><strong>Differentiability:</strong> Differentiability is essential for gradient-based optimization algorithms like backpropagation. Activation functions that are differentiable across their domain allow gradients to be computed for weight updates during training.</li><li><strong>Sparsity: </strong>Some activation functions promote sparsity by having their outputs be zero for a large portion of input space. This can be beneficial in reducing the complexity of neural networks.</li><li><strong>Computationally Efficient:</strong> When we’re dealing with deep networks, we want things to happen quickly. Activation functions that can be calculated easily, without needing complex math, are like shortcuts that speed up our network’s learning process. So, simpler calculations mean our neural network gets smarter faster.</li></ol><p>Now, lets get into different activation functions and how they differ in practice.</p><ol><li><strong>Binary Step Function:</strong></li></ol><ul><li>The Binary Step function is like a decision-maker and is the simplest activation function.</li><li>If the input is above a certain threshold, it outputs 1; otherwise, it outputs 0.</li></ul><pre>The Binary Step function can be mathematically represented as <br><br>f(x) = 1, if x &gt;= 0<br>f(x) = 0, if x &lt; 0</pre><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def binary_step_function(x):<br>    if x &gt;= 0:<br>        return 1<br>    else:<br>        return 0<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = [binary_step_function(x) for x in input_values]<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Binary Step Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Binary Step Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*l_ApGfxU3Jq_dn7toUzvsA.png" /></figure><ul><li>While creating a binary classifier binary activation function are generally used. But, binary step function cannot be used in case of multiclass classification in target carriable.</li><li>The gradient of the binary step function is zero i.e if we calculate the derivative of f(x) with respect to x, it is equal to zero.</li><li>The Binary Step function can be use in very simple scenarios where decisions are binary, like basic logic gates or simple threshold-based classifiers.</li><li>But its inability to capture complex patterns make it less suitable to the real-world problems.</li></ul><p><strong>2. Linear Function:</strong></p><ul><li>The linear activation function is directly proportional to the input.</li><li>The main drawback of the binary step function was that it had zero gradient because there is no component of x in binary step function.</li><li>In order to remove that, linear function can be used.</li></ul><pre>Mathematically Linear Activation function is given by<br><br>F(x) = ax<br><br>Here, &#39;a&#39; is a constant that determines the slope of the line.<br>If &#39;a&#39; is positive, the line goes up as input increases; <br>If &#39;a&#39; is negative, the line goes down.</pre><ul><li>The derivative of the Linear activation function is not zero, but it’s just a constant value. This means that during the backpropagation step, which is how neural networks learn, the weights and biases get updated using the same constant value.</li><li>This doesn’t lead to much improvement because the because the neural network would not improve the error due to the same value of gradient for every iteration. Also, the network will not be able to identify complex patterns from the data.</li></ul><p><strong>No Learning Complexity:</strong></p><p>Imagine you’re trying to learn from a book that only has one sentence, repeated over and over. You won’t gain much knowledge because there’s no complexity to learn from. Similarly, the Linear function’s constant gradient doesn’t help neural networks identify complex patterns in data. It’s like trying to understand a painting with only one color — you’ll miss all the details.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def linear_activation_function(x, c=1):<br>    return c * x<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = linear_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Linear Activation Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Linear Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*u4D4QEmbq3ZPZr8Q6F7C_Q.png" /></figure><p><strong>3. Sigmoid Activation Function:</strong></p><ul><li>The Sigmoid AF is sometimes referred to as the <strong>logistic function </strong>or <strong>squashing function</strong> .</li><li>The Sigmoid is a non-linear AF used mostly in feedforward neural networks.</li></ul><p><strong>Mathematical Expression:</strong></p><pre>The Sigmoid function is written as:<br><br>f(x) = 1 / (1 + e^(-x))<br><br>Here, &#39;e&#39; is a special number (around 2.71828) and &#39;x&#39; is the input value.</pre><ul><li>Sigmoid function is continuously differentiable and a smooth S-shaped function.</li><li>The derivative of the function is: f’(x) = 1-sigmoid(x)</li><li>It’s great for scenarios where you need to measure things in terms of <strong>probabilities.</strong> For instance, if you want to know the likelihood of a image containing a dog, Sigmoid gives you a number between 0 (not a dog) and 1 (definitely a dog).</li></ul><p><strong>Vanishing Gradient Problem:</strong></p><p>Now, imagine you’re teaching a robot to dance. Every time it does a dance move, you give feedback to improve. But what if the robot starts moving like a snail whenever you say “nice job”? That’s what happens with Sigmoid. When inputs get really big or really small, the dance (or gradient) becomes so slow that learning almost stops. This is known as the “vanishing gradient” problem.</p><p>The vanishing gradient problem makes it a bit unsuitable for deep networks.However, its used when you need outputs between 0 and 1.</p><p><strong>Not Zero Centered:</strong></p><p>The Sigmoid activation function isn’t “zero-centered.” What this means is that even when the input is zero, the output isn’t centered around zero — it’s shifted to one side.</p><p>Imagine you’re training a neural network to recognize objects in images. If the Sigmoid’s output is always biased towards one direction, it might impact the network’s ability to distinguish between different objects, even when they’re similar.</p><p>Additionally, this absence of being centered around zero leads to another issue: the <strong>“dying” gradient problem</strong>. When gradients are multiplied layer by layer during training, they can become very small if the output is shifted away from zero.This makes it difficult for the network to learn effectively, can slow down the learning process of the network.</p><p>Modern activation functions, like the <strong>Rectified Linear Unit (ReLU)</strong>, have become more popular due to their ability to address the challenges faced by Sigmoid.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def sigmoid_activation_function(x):<br>    return 1 / (1 + np.exp(-x))<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = sigmoid_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Sigmoid Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*f89V8BTW3NL66BDugit20A.png" /></figure><p><strong>4. Tanh</strong></p><ul><li>The tanh function is also known as hyperbolic tangent function.</li><li>The Tanh function takes any input, big or small, and transforms it into a value between -1 and 1.</li></ul><p><strong>Mathematical Expression</strong></p><pre><br>Mathematically, the Tanh activation function can be expressed as:<br><br>f(x) = (e^x - e^(-x)) / (e^x + e^(-x))<br><br>Here, &#39;e&#39; is Euler&#39;s number (around 2.71828), and &#39;x&#39; is the input value.</pre><ul><li>It’s like Sigmoid function, but it has one advantage: it’s <strong>zero-centered</strong>. This means that when the input is 0, the output is also 0.This property can be beneficial when dealing with data that has a mean of zero, as it helps in the efficient learning of both positive and negative features.</li><li>However, like Sigmoid, Tanh also faces the “<strong>vanishing gradient</strong>” problem. As you travel deep into the network, the gradients become small, affecting learning. But because Tanh is zero-centered, it’s better at handling certain situations.</li><li>Tanh doesn’t work well with sparse data — data that mostly contains zeros and just a few non-zero values. Think of it like a bunch of tiny toy cars, some red and some blue. Imagine putting these cars through the Tanh .The small cars, whether a bit positive (+0.1) or a bit negative (-0.1), tend to get really close to zero.</li><li>Now, if those little cars actually carried important information then that can be a problem.It’s like misplacing these special cars among the others, making it harder for the neural network to notice and use them effectively.This becomes especially troublesome when you’re handling data that’s scattered and not closely grouped.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def tanh_activation_function(x):<br>    return np.tanh(x)<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = tanh_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Tanh Activation Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Tanh Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Jk5NhEnNjJ9RtlFIoUPcnw.png" /></figure><p><strong>5. ReLU</strong></p><ul><li>ReLU stands for rectified linear unit and is a non-linear activation function which is widely used in neural network.</li><li>It offers the better performance and generalization in deep learning compared to the Sigmoid and tanh activation functions .</li><li>It is a piecewise activation function that returns the input as the output if it is positive; otherwise, it returns 0.</li></ul><p><strong>Mathematical Expression:</strong></p><pre>The ReLU function can be shown as<br><br>f(x) = max(0, x)<br><br>Here, &#39;x&#39; is the input value, and the function returns &#39;x&#39; <br>if &#39;x&#39; is positive and returns 0 if &#39;x&#39; is negative.</pre><ul><li>It eliminates the vanishing gradient problem observed in the earlier types of activation function by forcing the all the negative values to be 0.</li><li>ReLU is mostly used in the hidden parts of deep neural networks, along with other Activation Functions.</li><li>One really good thing about using ReLU is that it’s fast in calculations. It doesn’t need to do hard math like exponentials or divisions.</li><li>It’s even better than other functions because it doesn’t activate all the neurons at once. Instead, only some of them work together. Sometimes, the gradient is zero, and that’s a reason why weights and biases don’t change during training.</li><li>Even though ReLU is awesome, it has a small downside. It can try too hard and remember too much leading to overfitting, especially compared to the sigmoid function. To fix this,pleople use the <strong>Dropout technique</strong>.</li><li>It also suffers from a problem called <strong>“dying ReLU” </strong>where some neurons can become permanently inactive.</li></ul><p>Imagine you have a group of friends who lose interest in a game and never want to play again. Similarly, ReLU has neurons that become inactive during training and stay that way, reducing the network’s effectiveness in learning. This is the <strong>“dying ReLU” </strong>problem.</p><p>To address this limitation, different versions of ReLU, such as Leaky ReLU, Parametric ReLU (PReLU), and Exponential Linear Units (ELU) were introduced.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def relu_activation_function(x):<br>    return np.maximum(0, x)<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = relu_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;ReLU Activation Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;ReLU Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Fik4h8o9jRp6GDjQfQXkgw.png" /></figure><p><strong>6. Leaky ReLU:</strong></p><ul><li>Leaky ReLU works almost like ReLU. But, When a number is negative, instead of turning it completely off, it introduce some small negative slope to the ReLU.</li></ul><p><strong>Mathematical Expression:</strong></p><pre>The Leaky ReLU function can be shown as<br><br>f(x) = x if x &gt; 0<br>f(x) = ax if x &lt;= 0 (where a is a small positive constant)<br><br>Here, &#39;x&#39; is the input value, and &#39;a&#39; is a small positive number, like 0.01.</pre><ul><li>Unlike the regular ReLU, which encounters dead neuron issues, Leaky ReLU addresses the “dying ReLU” problem with the introduction of an alpha parameter. This parameter serves as a solution to prevent neurons from becoming inactive, ensuring that gradients are never completely zero during training.</li><li>The small alpha parameter in Leaky ReLU guarantees that even negative inputs contribute slightly to the output.</li><li>However, The value of the alpha(usually denoted by ‘α’) needs careful tuning. If it’s too small, it might not make a significant difference. If it’s too big, it could lead to a network that doesn’t learn well.</li><li>The performance of Leaky ReLU can vary depending on the dataset and the problem at hand. It might not always be the ideal choice for all scenarios. In some cases, using plain ReLU or other activation functions might yield better results.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def leaky_relu_activation_function(x, alpha=0.01):<br>    return np.maximum(alpha * x, x)<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = leaky_relu_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Leaky ReLU Activation Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Leaky ReLU Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*H3EgJjL3od3jK3zjsyWwOQ.png" /></figure><p><strong>7. Parametric ReLU:</strong></p><ul><li>The parametric ReLU known as PReLU is another variant of the ReLU.</li><li>Unlike the regular ReLU, which has a fixed slope for negative values, Parametric ReLU (PReLU) enables the network to learn and adjust this slope using a parameter (‘a’).</li></ul><p><strong>Mathematical Expression</strong></p><pre>PReLU&#39;s mathematical expression looks like this<br><br>f(x) = x if x &gt; 0<br>f(x) = ax if x &lt;= 0 (where &#39;a&#39; is a learnable parameter)<br><br>The &#39;x&#39; is the input value, and &#39;a&#39; is the parameter which is adjusted while training.</pre><ul><li>When the value of ‘a’ is initially set to 0.01, the function behaves similarly to the Leaky ReLU. However, in Parametric ReLU (PReLU), ‘a’ is not fixed; it’s a parameter that the network can adjust.</li><li>This adaptability allows the network to learn the most suitable value of ‘a’ during training, ensuring quicker and more effective convergence.</li><li>PReLU can be used when you want an activation function that’s adaptable and fine-tunes itself to your data.</li><li>PReLU is a great fit when your data has a mix of positive and negative values, and you need an activation function that handles both effectively.</li><li>It’s also beneficial if you’re aiming for faster and more efficient learning by enabling the network to learn the most suitable parameter value.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def prelu_activation_function(x, alpha=0.25):<br>    return np.where(x &gt; 0, x, alpha * x)<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = prelu_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Parametric ReLU Activation Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Parametric ReLU Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*_wYUvsULnsYIwebPGr4_Ug.png" /><figcaption>*</figcaption></figure><p><strong>8.ELU</strong></p><ul><li>ELU handles both positive and negative inputs, unlike ReLU.</li></ul><p><strong>Mathematical Expression:</strong></p><pre>f(x) = x if x &gt; 0 f(x) = α * (exp(x) - 1) if x ≤ 0<br><br>The &#39;x&#39; is the input value, and &#39;a&#39; is the parameter which is adjusted while training.</pre><ul><li>ELU prevents the “dying ReLU” problem by activating neurons even for negative values . This ensures that all neurons stay active and contribute to learning.</li><li>By including negative values, ELU allows the network to learn from a wider range of inputs. This can be advantageous in scenarios where different input patterns matter.</li><li>ELU is less sensitive to noise in the data. Learning from wider range of inputs, including both positive and negative values, enables ELU to distinguish between valuable information and noise. This contributes to improved stability and performance in various scenarios.</li><li>While ELU offers these benefits, its exponential calculations can be computationally more expensive compared to simpler functions like ReLU.</li><li>Additionally, determining the optimal ‘α’ value may require some experimentation, but it’s a necessary step to ensure ELU works optimally for your Neural Network and dataset.</li><li>ELUs provide quicker learning and better generalization than ReLU and Leaky ReLU, especially in networks with over five layers.</li><li>One limitation is that ELUs don’t center values at zero. To address this, the parametric ELU was introduced.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def elu_activation_function(x, alpha=0.5):<br>    return np.where(x &gt; 0, x, alpha * (np.exp(x) - 1))<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = elu_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Exponential Linear Unit (ELU)&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Exponential Linear Unit (ELU)&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*xA_NJh2ut6CbCUXog9ZeKw.png" /></figure><p><strong>9.Swish</strong></p><ul><li>The Swish function is an activation function that was proposed by researchers at Google in 2017.</li><li>It is designed to combine the advantages of the Rectified Linear Unit (ReLU) and Sigmoid activation functions.</li></ul><p><strong>Mathematical Expression:</strong></p><pre>The Swish function is defined as follows<br><br>f(x) = x * sigmoid(x)<br><br>Here, &#39;x&#39; is the input to the function, and &#39;sigmoid&#39; represents the sigmoid activation function, which squashes input values between 0 and 1.</pre><ul><li>Swish is like a mix of two types of functions. It looks at the input number ‘x’. If ‘x’ is positive, it makes the number bigger in a smooth way. If ‘x’ is negative, it makes the number smaller, but not too much.</li><li>This mix of making things bigger and smaller gives Swish its special behavior that’s different from other functions</li><li>Swish offers smoothness similar to functions like sigmoid and tanh, contributing to stable learning during training.</li><li>It often gives more accurate results compared to other functions like ReLU.</li><li>For positive numbers, it acts like one thing (ReLU), and for negative ones, it behaves differently (like Sigmoid). This ability helps it handle different kinds of tasks and find different patterns in the data.</li><li>However, Swish comes with a few disadvantages:it’s computationally slower, sensitive to initial weights. Using the right techniques to set the initial weights is important for smooth and good learning.</li><li>Swish’s speed can change based on the computer it’s using. It might work fast on one computer but not as well on another. Thinking about the computer’s capabilities and performance is important when using Swish in real-life situations.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def swish_activation_function(x):<br>    return x * sigmoid_activation_function(x)<br><br>def sigmoid_activation_function(x):<br>    return 1 / (1 + np.exp(-x))<br><br># Generate a range of input values<br>input_values = np.linspace(-10, 10, 100)<br>output_values = swish_activation_function(input_values)<br><br># Plotting<br>plt.plot(input_values, output_values, label=&#39;Swish Function&#39;)<br>plt.xlabel(&#39;Input&#39;)<br>plt.ylabel(&#39;Output&#39;)<br>plt.title(&#39;Swish Activation Function&#39;)<br>plt.legend()<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*mg30FSwOoCc8pU8n8UbChQ.png" /></figure><p><strong>10. Softmax</strong></p><ul><li>The Softmax activation function is often used in the final layer of a neural network when dealing with multi-class classification problems.</li><li>It takes a set of numerical values as input and transforms them into probabilities that sum up to 1. This makes it suitable for predicting the probability of an input belonging to each class in a classification task.</li></ul><pre>The mathematical expression for the Softmax function for an input vector &#39;x&#39; is as follows<br><br>softmax(x_i) = exp(x_i) / sum(exp(x_j)) for all j<br><br>Where &#39;i&#39; and &#39;j&#39; iterate over the elements of the input vector &#39;x&#39;.</pre><ul><li>The Softmax function takes a vector of real numbers as input and produces another vector of the same dimension as output.</li><li>For each input value ‘x’, the Softmax function calculates the exponent of ‘x’, and then it normalizes these exponentiated values by dividing them by the sum of all exponentiated values. This ensures that the output values represent probabilities.</li><li>In neural networks used for classification, the Softmax function is typically applied to the output layer.</li><li>It converts the raw scores or logits produced by the previous layers into probabilities. The class with the highest probability is then predicted as the final output class.</li><li>The primary strength of Softmax lies in its ability to handle multi-class classification problems where an input can belong to multiple mutually exclusive classes. By providing probabilities for each class, it captures the relationships between different classes and their interactions.</li><li>Softmax is best suited when you’re dealing with multi-class classification problems and need to assign probabilities to different classes.</li></ul><p>Additionally, Softmax has its disadvantages:</p><ul><li>It is<strong> sensitive to outliers</strong> in the input data. If the input values are extremely large or small, the exponential calculations involved in Softmax can lead to numerical instability and cause the function to produce unreliable results.</li><li>Softmax is sensitive to noisy or ambiguous training labels, leading to misclassification errors. This lack of robustness to label noise can affect the model’s performance and generalization capabilities.</li><li>It assumes that the classes are mutually exclusive and equally important. However, in scenarios with imbalanced class distributions, where some classes have significantly more samples than others, Softmax may not perform well. It can lead to biased predictions towards the majority class and result in poor performance for minority classes.</li></ul><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def softmax(x):<br>    e_x = np.exp(x - np.max(x))<br>    return e_x / e_x.sum()<br><br># Example input values<br>input_values = np.linspace(-10, 10, 100)  # Creating a range of input values<br><br># Applying Softmax to the input values<br>softmax_output = softmax(input_values)<br><br># Plotting the Softmax output<br>plt.figure(figsize=(8, 5))<br>plt.plot(input_values, softmax_output, label=&quot;Softmax Output&quot;)<br>plt.xlabel(&quot;Input Values&quot;)<br>plt.ylabel(&quot;Probability&quot;)<br>plt.title(&quot;Softmax Activation Function&quot;)<br>plt.legend()<br>plt.grid(True)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*NXu2KfbN8GZ1AZC33W19LQ.png" /></figure><p>Now, that we have understood different activation functions , their advantages and limitations its important to note that there’s no universal activation function that suits every problem.</p><p>Activation functions are essential components in machine learning, each with its own distinct characteristics. However, the effectiveness of these functions often relies on the context, data, and specific challenges. It’s not about finding the single “best” function, but rather understanding when and how to use them effectively.</p><p>As you explore different activation functions, keep in mind that trying out various options is essential for constructing your models, acquiring insights, and successfully addressing real-world challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aed5ed1c785" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power of Activation Functions: A Beginner’s Guide to Neural Network Building Blocks]]></title>
            <link>https://medium.com/@deepyachowdary/power-of-activation-functions-a-beginners-guide-to-neural-network-building-blocks-f911f9451ec5?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f911f9451ec5</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[non-linear-function]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 16:27:21 GMT</pubDate>
            <atom:updated>2023-08-17T16:58:22.799Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the last sixty years, the field of machine learning, a subset of artificial intelligence, has experienced rapid growth. Research in this field has gained momentum, extending its reach into various dimensions of human existence.</p><p>Machine learning is a field of study that uses the statistics and computer science principles, to create statistical models, that predict and infer outcomes. These models are sets of mathematical relationships between the inputs and outputs of a given system. The learning process is the process of estimating the models parameters such that the model can perform the specified task .For machines, this learning process give the ability to learn without being programmed explicitly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pC8OgLypKux5mb9j.jpg" /><figcaption><strong>Components of Artificial Intelligence</strong></figcaption></figure><p>At the heart of machine learning lies <strong>Artificial Neural Networks (ANN),</strong> computer programs inspired by the workings of the human brain. These ANNs are called networks because they are composed of different functions , which gathers knowledge by detecting the relationships and patterns in data using past experiences known as training examples.These networks are capable of learning from data, making predictions, and solving complex tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*OvD9nIp7Dx4OZX5fmYXEZw.png" /><figcaption><strong>Neural Network</strong></figcaption></figure><p>Now, let’s explore a fundamental question: <strong><em>Why do neural networks need activation functions</em></strong>?”</p><p>Imagine you’re navigating a maze, but you can only move in straight lines. No turns, no twists — just forward and backward. That’s what neural networks without activation functions would be like — limited to linear movements in the world of data.Neural Network without an activation functions acts as a <strong>Linear Regression Model </strong>with limited performance.But in reality, data is full of twists, turns, and complex relationships. That’s where activation functions step in.</p><p>Picture a painter being forced to use a straightedge for every curve — the result would be far from reality. Similarly, without activation functions, neural networks can only capture straight-line patterns, leaving the complex details of data unexplored.It’s like trying to paint a rainbow with just one color.</p><p><strong><em>THE NEED FOR NON-LINEARITY IN NEURAL NETWORKS</em></strong></p><p>Those functions which have degree more than one and have a curvature when plotted are known as <strong>Non-linear functions</strong>. Neural Networks are also known as <strong>Universal Function Approximators </strong>which, means that they can compute and learn any function provided to them. Any imaginable process can be represented as a functional computation in Neural Networks.</p><p>Thus, we need to apply an activation function to make the network dynamic and add the ability to it to extract complex and complicated information from data .Hence, by adding non linearity with the help of non-linear activation functions to the network, we are able to achieve non-linear mappings from inputs to outputs.</p><p><strong>Mathematical Magic of Activation Functions:</strong></p><p>Now that we’ve known the importance of non-linearity and the role activation functions play in neural networks, it’s time to delve into the mathematical core of these functions.</p><p>Imagine you have a dataset with input features represented by the vector X. The linear model computes the output f(x) by combining these features with their respective weights, and then adding a bias term.</p><p>Mathematically, this can be represented as<strong> f(x) = w^T x + b</strong></p><ul><li>f(x) is the output of the linear model for a given input x.</li><li>w is the weight vector, signifying the importance of each input feature.</li><li>w^T denotes the transpose of the weight vector, allowing for the dot product with the input vector x.</li><li>x represents the input feature vector.</li><li>b is the bias term, providing an extra constant to the output.</li></ul><p>Visually, this can be visualized as a straight line or plane in the input feature space.</p><p>However, linear models are limited to capturing simple relationships between variables. They can’t handle complex patterns or complex data relationships that often exist in the real world. That’s where activation functions come into play.</p><p>The Activation Functions are <strong>transfer functions</strong> that are applied to the outputs of the linear models to convert these linear inputs to non-linear outputs. The non-linear output after the application of the Activation Function is given by <strong>y = α(w1 x1 + w2 x2 + .. + wn xn + b)</strong> where α is the activation function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*ATPRaXyyLzH1rZdRoNl-YA.png" /><figcaption>Typical Biological Neuron</figcaption></figure><p>To visualize this transformation, consider a typical deep learning model which shows the three layers that make up a DL based system with some focus on the positions of activation functions, represented by the dark shaded region in the respective blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*MHmxCC1IHZKXw4Cqv4URYw.png" /><figcaption><strong>Block Diagram of Deep Learning based System</strong></figcaption></figure><p>The input layer accepts the data for training the neural network which comes in various formats from images, videos, texts, speech, sounds, or numeric data, while the hidden layers detect the local the patterns and features in data from the previous layers.The output layer presents the network classifications or predictions, with associated probabilities</p><p>The location of an Activation Function (AF) within a network structure depends on its role. When placed after the hidden layers, the AF converts learned linear mappings into non-linear forms for further propagation. In the output layer, it helps in making predictions.</p><p><strong>Types of Activation Functions</strong></p><p>Some of the main important Activation Functions are</p><ol><li>Binary Step Function</li><li>Linear</li><li>Sigmoid</li><li>Tanh</li><li>ReLU</li><li>Leaky ReLU</li><li>Parametrized ReLU</li><li>Exponential Linear Unit</li><li>Swish</li><li>SoftMax</li></ol><p><strong>Choosing the Right Activation Function</strong></p><p>When it comes to choosing the right activation function for a neural network,there is no thumb rule for selecting any activation function but the choice of activation function is context dependent, i.e it depends on the task that is to be accomplished.</p><p>Different Activation Functions have both advantages and dis-advantages of their own and it depends on the type of system that we are designing.</p><ul><li>For <strong>classification problems</strong>, a combination of <strong>sigmoid functions</strong> gives better results.</li><li>Due to <strong>vanishing gradient problem</strong> i.e. gradient reaching the value zero, <strong>sigmoid and tanh functions are avoided.</strong></li><li><strong>ReLU </strong>function is the most widely used function and performs better than other activation functions in most of the cases.</li><li>If there are dead neurons in your network, then you can use the leaky ReLU function.</li><li>If there are <strong>dead neurons</strong> in your network, then you can use the L<strong>eaky ReLU</strong> function.</li><li><strong>ReLU </strong>function has to be used only in the <strong>hidden layers </strong>and not in the outer layer.</li></ul><p>Think of neural networks as trying out various brushstrokes to craft a beautiful painting. Explore various activation functions and see how they affect your model’s performance. The key is to find the perfect combination that makes your network shine.</p><p>In my <a href="https://medium.com/@deepyachowdary/understanding-different-activation-functions-6aed5ed1c785">upcoming post</a>, we’ll take a closer look at each of the different activation functions, diving into their mathematical expressions and understanding how they influence neural network behavior.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f911f9451ec5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Occupancy Networks]]></title>
            <link>https://medium.com/@deepyachowdary/demystifying-occupancy-networks-3923363b2b51?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3923363b2b51</guid>
            <category><![CDATA[3d-computer-vision]]></category>
            <category><![CDATA[3d-shape-representation]]></category>
            <category><![CDATA[occupancy-networks]]></category>
            <category><![CDATA[3d-shape-reconstruction]]></category>
            <category><![CDATA[implicit-function]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 07:14:42 GMT</pubDate>
            <atom:updated>2023-08-05T07:14:42.268Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:- </strong>In my <a href="https://medium.com/@deepyachowdary/from-pixels-to-3d-shapes-an-overview-of-3d-data-representations-90c57f85a900">previous post</a>, we delved into various 3D data representations. We saw the shortcomings of traditional approaches and the demand for advanced methods to precisely capture the complexities of 3D objects. Now, lets dive into the way we represent 3D shapes — Occupancy Networks.</p><p><strong>Introducing Occupancy Networks :-</strong></p><p>Occupancy Networks, a advancement in 3D shape representation, were introduced by Mescheder and their team in their detailed paper titled: ‘<strong><em>Occupancy Networks: Learning 3D Reconstruction in Function Space.</em></strong>’ Their innovative research formed the basis for using <strong>implicit functions</strong>, for capturing complex 3D shapes. Now, you might be curious about implicit functions. Let’s explore this concept together.</p><p><strong>Decoding Implicit Function:-</strong></p><p>Imagine a 3D object, such as a car, not drawn by its outline, but as a collection of points. Implicit functions help us decide if a certain point is inside or outside this object. This “yes” or “no” information is like puzzle pieces, where each piece says if it fits a certain spot. As you put these pieces based on their “yes” or “no” answers in the right spots, they create the complete shape and that’s how implicit functions work — they build the 3D shape bit by bit by deciding if each point belongs to the shape or not.</p><p>Occupancy Networks use these implicit functions to build the whole 3D shape bit by bit, just by figuring out if each point belongs to the shape or not.</p><p><strong>Understanding the Architecture of Occupancy Networks:</strong></p><p>At the heart of Occupancy Networks lies the concept of implicit functions. One of the key questions you might be wondering about is how these networks actually learn those implicit functions we talked about earlier.</p><p>To put it simply, Occupancy Networks employ a neural network structure. This structure consists of layers and nodes, much like the human brain. However, unlike processing images or conventional data, these neural networks (referred to as implicit functions) are specialized in learning the connections between 3D points and their occupancy status.</p><p>Occupancy Networks (ONet) adopt a unique architecture inspired by the Variational Autoencoder (VAE) framework. Just as a VAE comprises an encoder and a decoder, an ONet also involves a specific structure for its learning process.</p><p><strong>Encoder: </strong>In the ONet framework, the encoder extracts meaningful information from the input 3D point cloud. Similar to a VAE’s encoder, this processes the point cloud data and transforms it into a latent representation. This representation is like a summary of the main characteristics.</p><p>Think about it like this: If you were explaining how a friend looks to someone, you’d mention the important things that stand out, like their eyes, nose, and mouth. You wouldn’t talk about every tiny spot on their skin.Similarly, ONet’s encoder figures out what’s unique and essential about the shape and captures it in this compact latent representation.</p><p><strong>Decoder: </strong>The decoder in an Occupancy Network (ONet) works much like the decoder in a Variational Autoencoder (VAE). It takes the learned latent representation and uses it to understand the 3D shape. But here’s the interesting part: ONet’s decoder doesn’t rebuild the shape exactly as it was. Instead, it makes guesses about whether each point in the recreated space is inside the shape or not.</p><p>So, ONet’s decoder doesn’t create new shape. It’s like a puzzle master who tells which pieces should go inside the puzzle to complete it, without actually showing the full picture. This approach helps ONet effectively understand how the 3D shape is constructed by just focusing on whether each point contributes to the interior of the shape.</p><blockquote>To understand the technical aspect, consider a function that takes an observation x ∈ X as input and has a function from p ∈ R³ to R as output. Alternatively, this function can be represented by a function that takes a pair (p, x) ∈ R³ × X as input and gives a real number as output. This latter representation can be parameterized by a neural network fθ, which takes the pair (p, x) as input and produces a real number representing the probability of occupancy: fθ : R³ × X → [0, 1]. Such a neural network is named <strong>“Occupancy Network”.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V20FDhutlii0E6EfAWkKAg.png" /><figcaption><strong>Occupancy Network Architecture</strong></figcaption></figure><p><strong>The Learning Process: Training the Network:</strong></p><p>Now, let’s look into how the network learns. Learning involves training the network using a dataset of labeled 3D points. These points come with occupancy labels that indicate if they’re “inside” or “outside” of the shape.</p><p>During training, the network processes this data,adjusting its internal parameters to predict point occupancy based on their characteristics. It’s like teaching the network to recognize patterns in the data. The network’s core function is understanding the implicit function that defines the shape’s boundary, existing in a complex space.</p><p>Mathematically, think of this function as a decision boundary. The network fine-tunes its parameters to accurately position points on either side of this boundary, determining if they’re part of the shape or not. Through this learning process, the network gains the ability to understand the complex details of 3D shape boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*96apI3CCH88-u0eL0PHcog.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*qQDGoLE2ihTLKiehLLilUA.gif" /><figcaption><strong>Implicit Function(Occupancy Network)</strong></figcaption></figure><p><strong>Understanding the Loss Function of Occupancy Networks:</strong></p><p>The loss function in Occupancy Networks plays a key role in determining how well the network’s predictions align with the actual occupancy values of each point within the 3D shape.</p><p>The objective of the loss function is to measure the disparity between the predicted occupancies and the ground truth occupancies provided in the dataset. In simpler terms, it calculates how much the network’s predictions deviate from the actual “inside” or “outside” labels of each point.</p><p>During the training process, the network’s aim is to minimize this loss value. This optimization process involves adjusting the network’s internal parameters, enabling it to make increasingly accurate predictions about each point’s occupancy .</p><p>The loss function used in Occupancy Networks is made up of two key parts: the <strong>Kullback-Leibler (KL) Divergence term </strong>and the <strong>Binary Cross-Entropy (BCE) Loss</strong>. The KL Divergence term checks how close the distribution produced by the network is to the desired distribution. On the other hand, the BCE Loss checks how well the predicted labels match the actual labels.</p><p>Mathematically, the loss function combines these parts</p><p><strong>L(θ, ψ) = 1 / |B| * ∑[ hXK ∑[L(fθ(pij, zi), oij) + KL(qψ(zi | (pij, oij)j=1:K) || p0(zi))] ]</strong></p><p>Here, <strong>L(fθ(pij, zi), oij) </strong>represents the BCE Loss term, and <strong>KL(qψ(zi | (pij, oij)j=1:K) || p0(zi)) </strong>denotes the KL Divergence term.</p><p>By iteratively minimizing the loss function through techniques like gradient descent, the network learns to enhance its predictive capabilities to better capture the boundaries of 3D shapes, ultimately resulting in more precise and reliable representations.</p><p><strong>Generalization: </strong>The important aspect of this learning process is that once the network has trained on a diverse dataset, it can generalize its understanding to new, unseen data. This means it can accurately predict the occupancy of points in shapes it has never encountered before.</p><p><strong>Real world Applications and Impact</strong></p><p>Now that we’ve explored the architecture, learning process, and loss function let’s take a quick look at how they’re used in real life. These networks are being used in robotics, medical imaging, and even video games. They’re useful because they give accurate and efficient way to represent complicated 3D shapes.</p><blockquote>For instance, Tesla, a prominent name in the realm of self-driving cars, employs Occupancy Networks to enhance its perception systems. These networks helped Tesla’s vehicles in accurately recognizing and understanding the shapes of objects and obstacles in their surroundings, contributing to safer and more efficient autonomous driving experiences.</blockquote><p>In a nutshell, Occupancy Networks are shaping the future of 3D representation. From self-driving cars to video games, they’re revolutionizing how we understand complex objects. With their impact growing, these networks are set to reshape our world. Stay tuned for more exciting developments!</p><p><strong><em>References:- </em></strong><a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Mescheder%2C+L">Lars Mescheder</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Oechsle%2C+M">Michael Oechsle</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Niemeyer%2C+M">Michael Niemeyer</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Nowozin%2C+S">Sebastian Nowozin</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Geiger%2C+A">Andreas Geiger</a> : <a href="https://doi.org/10.48550/arXiv.1812.03828"><em>Occupancy Networks: Learning 3D Reconstruction in Function Space</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3923363b2b51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Pixels to 3D Shapes: An Overview of 3D Data Representations]]></title>
            <link>https://medium.com/@deepyachowdary/from-pixels-to-3d-shapes-an-overview-of-3d-data-representations-90c57f85a900?source=rss-1635f95d7aa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/90c57f85a900</guid>
            <category><![CDATA[3d-visualization]]></category>
            <category><![CDATA[3d-representation]]></category>
            <category><![CDATA[occupancy-networks]]></category>
            <category><![CDATA[3d-vision]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Dedeepya Lekkala]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 10:21:25 GMT</pubDate>
            <atom:updated>2023-08-05T06:56:16.806Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered how computers perceive and understand the three-dimensional world around us? From recognizing objects to reconstructing scenes,3D computer vision plays a crucial role in various applications. But how do computers represent and reason about complex 3D shapes? In this blog let’s explore the magic behind how computers perceive and reason about complex 3D shapes.</p><p>At the heart of this fascinating field lies 3D computer vision, a specialized branch of computer vision that focuses on understanding and processing three-dimensional visual data from the real world. By analyzing depth, shape, and spatial relationships in images and videos, 3D computer vision enables computers to interpret the 3D structure of objects and scenes with remarkable precision and accuracy.</p><p>Deep Learning architectures have demonstrated impressive capabilities in analyzing 2D data, but the same success was not easily replicated in the 3D domain. One of the key reasons behind this disparity was the considerable demand for a large amount of training data, which was particularly challenging to obtain for 3D tasks.</p><p>Advancements in structured-light 3D scanners, time-of-flight cameras, and other affordable 3D-data acquisition devices have led to a significant increase in the availability of 3D data. These advancements have brought about a wealth of information about the full geometry of 3D objects and scenes, empowering the field of 3D computer vision</p><p>Raw 3D data captured by different scanning devices come in different forms that vary in both, the structure and the properties. 3D data is categorized mainly into two main families:- <strong><em>Euclidean-structured data </em></strong>and <strong><em>non-Euclidean data</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*7kI1BVyBlcz220lRUExk6Q.png" /><figcaption><strong>Various 3D Representations</strong></figcaption></figure><p><strong>Euclidean data</strong></p><p>Euclidean-structured data in the context of 3D computer vision refers to representations with a well-defined grid structure, where properties such as a global parametrization and a common system of coordinates are preserved.</p><p>These properties make extending the already-existing 2D DeepLearning approaches to 3D data a straightforward task, where the convolution operation is kept the same as 2D. 3D Euclidean data is more suitable for analyzing rigid objects where the deformations are minimal.</p><p>For example, in medicine, MRI scans use 3D Euclidean grids to analyze complex anatomical structures. In robotics and manufacturing, voxel data is commonly used to model and simulate rigid objects. The main 3D data representations that fall under this category are as follows :-</p><p><strong>a) Descriptors :- </strong>Shape descriptors are like simplified representations of 3D objects used to describe their geometric or topological characteristics. They capture information about the object’s shape, surface, texture, and more. These descriptors can be broadly classified into two categories:</p><ol><li><strong><em>Global Descriptors:</em></strong></li></ol><ul><li>Global descriptors give a brief but informative description of the entire 3D object.</li><li><strong>Example:</strong> Imagine describing a house’s overall shape, including its roof, walls, and windows.</li></ul><p>2. <strong><em>Local Descriptors:</em></strong></p><ul><li>Local descriptors focus on smaller parts or patches of the 3D object, providing more detailed information.</li><li><strong>Example:</strong> Instead of describing the whole house, local descriptors might highlight specific features like the front door or chimney.</li></ul><p>Shape descriptors help computers recognize objects, find similarities between shapes, and enable efficient processing of complex 3D data.</p><p><strong>b) RGB-D data:- </strong>3D data represented as RGB-D images has gained popularity due to sensors like Microsoft’s Kinect. RGB-D data combines 2D color information (RGB) with depth information (D) to give a 2.5D view of the captured 3D object.</p><p>For example, think of it as having a photo of a colorful object along with a depth map that shows how far each part of the object is from the camera.</p><p>These RGB-D images are both cost-effective and powerful, making them useful for various tasks. For example, it helps in recognizing objects by their appearance, predicting object poses, reconstructing scenes, and finding corresponding points in different views. This makes RGB-D data essential tool in the exciting world of 3D computer vision.</p><p><strong>c) 3D Data Projections:- </strong>Representing 3D data through projections involves transforming 3D objects into 2D grids with specific features.</p><p>For example, imagine projecting a 3D object onto a flat surface, creating a 2D representation. This projected data retains important characteristics of the original shape.</p><p>Common projections include spherical and cylindrical representations, which are rotation-invariant around their main axis. However, for complex 3D computer vision tasks like dense correspondence (matching points between objects), these projections may not be ideal due to potential information loss during the process.</p><p><strong>d) Volumetric Data :-</strong>Volumetric data uses voxels to create a regular grid in three-dimensional space, describing how the 3D object is distributed within the scene.</p><p>For example, Imagine voxels as tiny cubes that stack together to form the shape of an object in three-dimensional space.</p><p>Voxel-based representation is simple and can encode information about the 3D shape and its viewpoint. However, it has limitations. It represents both occupied and non-occupied parts of the scene, which requires a lot of memory storage. This makes voxel-based representation unsuitable for high-resolution data, where memory efficiency becomes crucial.</p><p><strong>e) Multi-view data:- </strong>3D data can be represented by combining several 2D images captured from different viewpoints of the same object. Think of it like taking pictures of an object from various angles. This representation helps reduce noise, deal with incomplete data, handle occlusions, and address lighting issues.</p><p>To learn from these 2D images and reconstruct the 3D shape, a function is used to model each view separately. Then, all the functions are optimized together to represent the complete 3D shape. It’s like putting together puzzle pieces from different pictures to understand the entire 3D scene.</p><p><strong>Non-Euclidean Data</strong></p><p>The second type of 3D data representation is non-Euclidean data. Unlike Euclidean data, it doesn’t have a global parametrization or a common coordinate system.</p><p>Also, non-Euclidean data lacks the simple structures and doesn’t follow a straightforward vector space pattern, making it challenging to directly apply 2D deep learning methods.</p><p>This means we need specialized approaches to effectively handle non-Euclidean data in the context of deep learning. Some common examples of non-Euclidean data include point clouds, 3D meshes, and graphs.</p><p><strong>a) 3D Point Clouds:-</strong>A point cloud is an unstructured collection of 3D points that approximates the shape of an object. It’s considered non-Euclidean data because it lacks a global structure and doesn’t follow a straightforward coordinate system.</p><p>However, point clouds can be seen in two ways: as unstructured sets of 3D points (non-Euclidean) or as small subsets with global coordinates and invariance to transformations (Euclidean). The choice depends on whether we focus on their global or local features.</p><p>For complex tasks like recognition and matching, we treat point clouds as non-Euclidean data because most learning techniques aim to capture global features.</p><p>Despite being easy to capture using technologies like Kinect and structured light scanners, processing point clouds can be challenging due to their lack of structure and ambiguity in surface information.</p><p><strong>b) 3D meshes and graphs :- </strong>3D meshes are widely used to represent 3D shapes. They consist of faces (polygons) and vertices, describing how the mesh exists in 3D space. While the local geometry follows a grid-like structure (Euclidean), the global aspects lack well-defined Euclidean properties.</p><p>Learning 3D meshes is a challenge due to their irregular nature, making it difficult to apply deep learning methods directly. They often encounter noise, missing data, and resolution issues as well.</p><p>Another way to represent 3D meshes is by using graphs, where nodes represent vertices, and edges indicate connectivity. Analyzing graph spectral properties has paved the way for innovative approaches, such as defining convolution-like operations on graphs or meshes converted to graphs.</p><p>For example, imagine you want to create a 3D model of a human face using a mesh representation. The mesh is like a network of triangles and points that form the surface of the face in 3D space. While the individual triangles and points follow regular rules (Euclidean), understanding the entire mesh as a whole is more challenging because it’s irregular and lacks clear overall properties. To tackle this complexity, we have graph-based methods, which allow us to study and analyze the facial features in 3D space with greater efficiency.</p><p><strong><em>Limitations of Traditional 3D Representations</em></strong></p><p>Traditional explicit representations like point clouds, meshes, and voxels have been widely used for many years. One of the primary challenges with explicit representations is their inefficiency in handling complex and deformable 3D shapes. They often struggle with accurately capturing complex details and dealing with incomplete or noisy data.</p><p>For example, representing a human face as a point cloud or a mesh might work well for basic shape approximation, but it falls short when it comes to accurately capturing facial expressions, fine wrinkles, or minute details that define an individual’s unique appearance.</p><p>Similarly, voxel-based representations suffer from high memory requirements, making them impractical for representing high-resolution or large-scale 3D scenes.</p><p><strong><em>Next Up: Exploring Occupancy Networks — Architecture, Mathematics, and Applications!</em></strong></p><p>As traditional 3D representations showed their limitations, the demand for more powerful and robust techniques arose, leading to the emergence of advanced methods like Occupancy Networks. In my upcoming post, we’ll look into their architecture, mathematical foundations, and real-world applications. Stay tuned to uncover the magic behind Occupancy Networks and their impact on 3D shape representation!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90c57f85a900" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>