<?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 Mudit on Medium]]></title>
        <description><![CDATA[Stories by Mudit on Medium]]></description>
        <link>https://medium.com/@muditrastogi?source=rss-299aa2161239------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*biIwRoaFLcfnogMuqD60Mw.png</url>
            <title>Stories by Mudit on Medium</title>
            <link>https://medium.com/@muditrastogi?source=rss-299aa2161239------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:57:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muditrastogi/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[GANs Series : Hinge Loss -A Practitioner’s Perspective After 7 Years in the Trenches]]></title>
            <link>https://medium.com/@muditrastogi/gans-series-hinge-loss-a-practitioners-perspective-after-7-years-in-the-trenches-0c8f7bfa7d09?source=rss-299aa2161239------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c8f7bfa7d09</guid>
            <dc:creator><![CDATA[Mudit]]></dc:creator>
            <pubDate>Thu, 05 Mar 2026 13:35:59 GMT</pubDate>
            <atom:updated>2026-03-05T13:35:59.241Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative Adversarial Networks (GANs) have evolved rapidly since their introduction. Over the years, the community has experimented with various loss functions to stabilize training and improve generation quality. One loss function that has consistently proven effective — especially in modern GAN architectures — is <strong>Hinge Loss</strong>.</p><p>Having worked with GANs for several years across research prototypes and production-grade pipelines, I’ve seen firsthand how the choice of loss function can dramatically influence training stability, convergence speed, and output fidelity. In this post, we’ll explore <strong>Hinge Loss in GANs</strong> from both a conceptual and practical perspective — useful whether you’re just starting with GANs or refining large-scale generative systems.</p><h3>Why Loss Functions Matter in GANs</h3><p>A GAN consists of two neural networks competing in a minimax game:</p><ul><li><strong>Generator (G):</strong> Produces synthetic data from random noise.</li><li><strong>Discriminator (D):</strong> Distinguishes real data from generated data.</li></ul><p>The challenge is that GAN training is notoriously unstable. Early GANs used <strong>binary cross-entropy loss</strong>, but this often caused issues such as:</p><ul><li>Vanishing gradients</li><li>Mode collapse</li><li>Slow convergence</li></ul><p>Researchers began experimenting with alternative objectives, including <strong>Wasserstein loss</strong>, <strong>Least Squares loss</strong>, and eventually <strong>Hinge Loss</strong>, which became popular in high-performance architectures like <strong>spectral normalized GANs</strong> and <strong>BigGAN-style models</strong>.</p><h3>What Is Hinge Loss?</h3><p>Hinge loss originates from <strong>margin-based learning</strong>, commonly used in Support Vector Machines.</p><p>Instead of forcing the discriminator to output probabilities, hinge loss encourages <strong>margin separation</strong> between real and fake samples.</p><p>For a discriminator output (D(x)):</p><h3>Discriminator Loss</h3><p>L_D = E_{x ~ p_data}[max(0, 1 − D(x))] + E_{z ~ p_z}[max(0, 1 + D(G(z)))]</p><p>Interpretation:</p><ul><li>Real samples should produce <strong>D(x) ≥ 1</strong></li><li>Fake samples should produce <strong>D(G(z)) ≤ -1</strong></li></ul><p>If these conditions are satisfied, the loss becomes <strong>zero</strong>, meaning the discriminator already has sufficient margin.</p><h3>Generator Loss</h3><p>Generator Loss:</p><p>L_G = -E_{z ~ p_z}[D(G(z))]</p><p>The generator tries to <strong>increase the discriminator score</strong> of fake samples so they look real.</p><h3>Intuition Behind Hinge Loss</h3><p>From practical experience, hinge loss improves GAN behavior because it introduces a <strong>margin-based objective</strong> rather than probability matching.</p><p>Key benefits:</p><ol><li><strong>Stronger gradients when needed</strong></li><li><strong>Stops over-penalizing already-correct predictions</strong></li><li><strong>Encourages confident discriminator decisions</strong></li></ol><p>In simpler terms:</p><ul><li>If the discriminator is already correct with enough margin → <strong>no further penalty</strong></li><li>If not → <strong>strong correction signal</strong></li></ul><p>This prevents unnecessary gradient updates that often destabilize GAN training.</p><h3>Implementation Example (PyTorch)</h3><p>Here is a simplified implementation of hinge loss in GAN training.</p><pre>import torch<br>import torch.nn.functional as F<br># Discriminator hinge loss<br>def discriminator_loss(real_logits, fake_logits):<br>    loss_real = torch.mean(F.relu(1.0 - real_logits))<br>    loss_fake = torch.mean(F.relu(1.0 + fake_logits))<br>    return loss_real + loss_fake<br># Generator hinge loss<br>def generator_loss(fake_logits):<br>    return -torch.mean(fake_logits)</pre><p>Training step example:</p><pre># Train discriminator<br>real_logits = D(real_images)<br>fake_images = G(z).detach()<br>fake_logits = D(fake_images)<br>d_loss = discriminator_loss(real_logits, fake_logits)<br>d_loss.backward()<br>optimizer_D.step()<br># Train generator<br>fake_images = G(z)<br>fake_logits = D(fake_images)<br>g_loss = generator_loss(fake_logits)<br>g_loss.backward()<br>optimizer_G.step()</pre><p>This setup is widely used in modern GAN frameworks.</p><h3>Practical Observations from Real Projects</h3><p>After experimenting with multiple GAN variants, several patterns emerge when using hinge loss:</p><h3>1. Training Stability Improves</h3><p>Compared to BCE loss, hinge loss tends to <strong>reduce discriminator saturation</strong>.</p><p>This keeps gradients useful for the generator longer.</p><h3>2. Works Extremely Well with Spectral Normalization</h3><p>Hinge loss pairs naturally with:</p><ul><li>Spectral normalization</li><li>Large batch GAN training</li><li>High-resolution generators</li></ul><p>This combination is now common in modern GAN pipelines.</p><h3>3. Faster Convergence in Many Cases</h3><p>In several image generation experiments (especially ≥128×128 resolution), hinge loss often reaches <strong>visually acceptable outputs faster</strong> than BCE-based GANs.</p><h3>Comparison With Other GAN Losses</h3><p>Loss TypeStabilityGradient QualityCommon UseBinary Cross EntropyLowOften vanishesOriginal GANLeast Squares LossModerateSmooth gradientsImage-to-image tasksWasserstein LossHighStrong theoretical groundingResearch &amp; large models<strong>Hinge LossHigh</strong>Strong marginsModern GAN architectures</p><p>Hinge loss often offers a <strong>great balance between simplicity and performance</strong>.</p><h3>When Should You Use Hinge Loss?</h3><p>In practice, hinge loss works best when:</p><ul><li>Training <strong>image GANs</strong></li><li>Using <strong>spectral normalization</strong></li><li>Building <strong>high-capacity discriminators</strong></li><li>Working with <strong>large datasets</strong></li></ul><p>If you’re experimenting with GAN architectures today, hinge loss is often one of the <strong>best default choices</strong>.</p><h3>Common Pitfalls</h3><p>Even with hinge loss, GAN training can still fail.</p><p>Watch out for:</p><h3>Overpowering Discriminator</h3><p>If the discriminator becomes too strong, the generator may stop improving.</p><p>Mitigation:</p><ul><li>Reduce discriminator updates</li><li>Adjust learning rates</li><li>Apply regularization</li></ul><h3>Poor Data Scaling</h3><p>Ensure inputs are normalized properly (e.g., [-1,1]).</p><h3>Incorrect Loss Implementation</h3><p>A small mistake (like missing detach() during discriminator training) can break GAN training entirely.</p><h3>Final Thoughts</h3><p>After several years working with GAN pipelines, hinge loss remains one of the most <strong>practical and reliable objectives</strong> for adversarial training.</p><p>It strikes a sweet spot between:</p><ul><li>Mathematical simplicity</li><li>Strong gradient behavior</li><li>Real-world stability</li></ul><p>While newer approaches continue to emerge, hinge loss has proven itself across many high-performing GAN architectures.</p><p>If you’re building or experimenting with GANs today, it’s absolutely worth having hinge loss as part of your toolkit.</p><p><strong>Key takeaway:</strong><br>GAN performance often depends less on exotic architectures and more on <strong>stable optimization choices</strong> — and hinge loss is one of those deceptively simple techniques that can make a big difference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c8f7bfa7d09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How AI and Satellite image can help Agriculture Industry.]]></title>
            <link>https://medium.com/@muditrastogi/how-ai-and-satellite-image-can-help-agriculture-industry-83ee9bc8491f?source=rss-299aa2161239------2</link>
            <guid isPermaLink="false">https://medium.com/p/83ee9bc8491f</guid>
            <dc:creator><![CDATA[Mudit]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 16:56:06 GMT</pubDate>
            <atom:updated>2019-03-15T16:56:06.997Z</atom:updated>
            <content:encoded><![CDATA[<img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83ee9bc8491f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google CEO testify in front of House Judiciary Committee]]></title>
            <link>https://medium.com/@muditrastogi/google-ceo-testify-in-front-of-house-judiciary-committee-e2f902b621a6?source=rss-299aa2161239------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2f902b621a6</guid>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[usa]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Mudit]]></dc:creator>
            <pubDate>Wed, 12 Dec 2018 17:58:44 GMT</pubDate>
            <atom:updated>2018-12-12T17:58:44.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*R2mGivG0zXZw-pdv.jpg" /><figcaption>Sundar Pichai answered it. How?</figcaption></figure><p>On Tuesday 11th Dec 2018, CEO of World Largest Search Tech Giants Google Sundar Pichai was testified in front of leaders in the committee on the Data Collection Practices followed by Google. He was asked to testify for the company on some practices and activities followed by Google. Highly concerned yet technologically deprived leaders in the house shot questions to CEO on the election interference, political bias, privacy, data collection methods adopted by Google and on their market dominance to suppress competitors.</p><p>US House Judiciary Committee is concerned about the impact of the internet in the life of their country people. Earlier they gave intense pain to Mark Zuckerberg CEO of Facebook, Jack Dorsey CEO of Twitter by interviewing them on the implications their respective platform on US citizens, politics and government.</p><p>US Election was one of the most dramatic elections in the history of US. The CEO admitted while testifying that Russia was involved featuring ads in the Google Search Engine. He said Google has taken constructive measures to avoid such occurrence in the future.</p><p>The Republican representative from the panel questioned “Google’s political bias search results” citing the example of images of US President Donald Trump as results of Google search while searching for word idiot. CEO dodged the questions by explaining the basic facts on search engine works instead of giving measures to combat such social based bias results.</p><p>Another representative from the body shot a question to CEO on “the federal privacy law”.</p><p>Representative asked the CEO whether his location or movement is being tracked by Google now or not. Sundar Pichai explained the body that it is dependent upon users default settings of data sharing to the external application and as well as to Google. He also stressed upon that Google asks its user to do a privacy checkup occasionally.</p><p>Committee also confronted the CEO on the fact that 90% of the Internet traffic comes from Google search and most of the percentage of traffic to sites showing pirated contents comes from Google. Considering the amount of revenue loss faced by Government, Hollywood, and Businessperson, the committee asked the CEO to monitor these websites and refrain them to come to public access.</p><p>Pichai felt more heat when Committee interrogated him on Google’s Project DragonFly where is working on the censored search engine for China. To testify this, he said to the committee that about 100 employees are working on this project and in future, he will engage US lawmakers for policies on developing products for China.</p><p>The panel also put forward the worries of small competitors who are suppressed by tech giants like Google, Facebook, Twitter etc. Committee addressed to bring strong legislative law to check the practices adopted by these tech giants to maintain the monopoly.</p><p>Being concerned for citizens must be the priority of the government and it must testify all the group of company that is involved in the direct or indirect act that cost the user privacy, revenue loss and loss to the institution like government, federal, defense etc. A strong law must be drafted to preserve the rights to data to users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2f902b621a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ANALYSIS OF TWITTER DATA WITH MACHINE LEARNING TECHNIQUES]]></title>
            <link>https://medium.com/@muditrastogi/analysis-of-twitter-data-with-machine-learning-techniques-3f20599f2605?source=rss-299aa2161239------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f20599f2605</guid>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mudit]]></dc:creator>
            <pubDate>Thu, 24 May 2018 20:06:21 GMT</pubDate>
            <atom:updated>2018-05-24T20:26:37.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*ws00MDKycwgf-cOG_kwzYQ.jpeg" /><figcaption>Source : <a href="http://www.business2community.com/">Business2Community</a></figcaption></figure><p>Classification of data is an important aspect of getting vigorous knowledge and help to analyze and perform any further action. This article deals with how different Machine-Learning Techniques classify on features of time-windows of Twitter, a micro-blogging social media to determine whether or not these times-windows are followed by Buzz events.</p><blockquote><strong>DATA SET</strong></blockquote><p>The data can be downloaded from the UC Irvine Machine Learning Repository website under the topic <a href="https://archive.ics.uci.edu/ml/datasets/Buzz+in+social+media+">Buzz Prediction in Social Media</a>. Dataset is provided with 140707 record samples for training set and testing set, and their associated label of whether the event is <strong>BUZZING or NOT</strong> in that social network site. Each record has <strong>77 attributes (features)</strong> of real data types. This dataset was published using the UCI guidelines. Hence, examples were stored using a standard<strong> comma separated value (.csv) format</strong>. We were provided two label classes represented by 0 and 1. Here, <strong>0 represented Non-Buzzed Event and 1 represented Buzzed Event.</strong></p><blockquote><strong>METHODS</strong></blockquote><p>I used Gaussian Naïve Bayes classification as an introductory result to see what is achievable. More sophisticated techniques like SVM in addition with Principal Component Analysis (PCA) was used to see if improvements could be made in the classification test. I experimented with using different feature sets of each method.</p><p>First, using Naïve Bayes for getting baseline accuracy followed by SVM with different kernel linear, polynomial, and RBF. The result of different machine learning techniques has been studied and the result is framed on a table with pictorial representations of Machine learning Techniques w.r.t Accuracy at given algorithms.We get the results after applying the Machine Learning Algorithm to train the classifier using all the 77 attributes which are the 77 dimensions of the multidimensional array of data sets.</p><blockquote><strong>RESULT</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*gMoBKgQ1e6DxmEUMn5gtuQ.png" /><figcaption>Figure 1. Result of different kernel of Support Vector Machine (SVM) on Social Media Dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*aM2Rs72h1G-UTd-rqWZMTQ.png" /></figure><p>Comparison of accuracy before or after applying PCA (Principal Component Analysis)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*U8VDSEX5bGh3E43yrHXYBw.png" /></figure><p><strong>Green Dots represent the accuracy after PCA Blue Dots represent the accuracy before PCA</strong></p><p>X coordinate represents a machine learning technique, serial number 1: Naive Bayes 2: Linear 3: RBF 4: Polynomial (degree 4) Y coordinate represents the accuracy of algorithms out of 1.</p><blockquote><strong>Reference</strong></blockquote><ol><li><a href="http://www.ijesrt.com/issues%20pdf%20file/Archive-2016/July-2016/117.pdf">Mudit Rastogi*, Ankur Singh Bist ANALYSIS OF TWITTER DATA WITH MACHINE LEARNING TECHNIQUES</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f20599f2605" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GDAL — Geospatial Data Abstraction Library Installations in Windows]]></title>
            <link>https://medium.com/magentacodes/gdal-geospatial-data-abstraction-library-installations-in-windows-fbbcdb0a73b0?source=rss-299aa2161239------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbbcdb0a73b0</guid>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gdal]]></category>
            <dc:creator><![CDATA[Mudit]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 04:18:41 GMT</pubDate>
            <atom:updated>2018-04-12T04:18:41.095Z</atom:updated>
            <content:encoded><![CDATA[<p>GDAL is a translator library for raster and vector geospatial data formats that is released under an <a href="http://trac.osgeo.org/gdal/wiki/FAQGeneral#WhatlicensedoesGDALOGRuse">X/MIT</a> style <a href="http://www.opensource.org/">Open Source</a> license by the <a href="http://www.osgeo.org/">Open Source Geospatial Foundation</a>. As a library, it presents a <a href="http://gdal.org/gdal_datamodel.html">single raster abstract data model</a> and <a href="http://gdal.org/ogr_arch.html">single vector abstract data model</a> to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing.</p><p>Sometime installing GDAL in Windows can be pain and may lead to various issues. In Linux environment it is easier to install from source files and get your work done smoothly.</p><p>There are various way to install to install GDAL in Windows system (but you need to be awake while installing ).</p><ol><li><a href="https://trac.osgeo.org/gdal/wiki/OSGeo4W">OSGeo4W</a> is a binary distribution of a broad set of open source geospatial software for Win32 and Win64 environments (Windows XP, Vista, Windows 7, Windows 10). OSGeo4W includes GDAL/OGR, <a href="http://grass.itc.it/">​GRASS</a>, MapServer. <br>Installation instructions(you will require Internet connection while downloading): <br>a. Download the <a href="http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe">​32bit</a> or <a href="http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe">​64bit</a> OSGeo4W network installer.<br>b. Run the installer.<br>c. Select <em>Express Install</em>, and <em>Next</em>.<br>d. Pick one or more packages to install, and <em>Next</em>.<br>e. The selected packages and their required sub packages will be downloaded and installed automatically.</li></ol><p>This will download OSGEO4W command shell. To run gdal command anywhere you need to set <strong><em>C:\OSGEO4W\bin</em></strong> to environment path.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbbcdb0a73b0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/magentacodes/gdal-geospatial-data-abstraction-library-installations-in-windows-fbbcdb0a73b0">GDAL — Geospatial Data Abstraction Library Installations in Windows</a> was originally published in <a href="https://medium.com/magentacodes">magenta codes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>