<?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 Sreyan Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Sreyan Ghosh on Medium]]></description>
        <link>https://medium.com/@sreyan2000?source=rss-61465f0747f7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3-RGAWnfyV4l4k0A</url>
            <title>Stories by Sreyan Ghosh on Medium</title>
            <link>https://medium.com/@sreyan2000?source=rss-61465f0747f7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 20 Jun 2026 09:36:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sreyan2000/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[Denoising Autoencoders Explained]]></title>
            <link>https://medium.com/vitmas/denoising-autoencoders-explained-695ed3cdcaba?source=rss-61465f0747f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/695ed3cdcaba</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[autoencoder]]></category>
            <category><![CDATA[vitmas]]></category>
            <category><![CDATA[denoising-autoencoder]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Sreyan Ghosh]]></dc:creator>
            <pubDate>Wed, 14 Oct 2020 12:16:53 GMT</pubDate>
            <atom:updated>2020-10-14T12:16:53.834Z</atom:updated>
            <content:encoded><![CDATA[<p>Deep Learning Demystified</p><h3><strong>Denoising Autoencoders Explained</strong></h3><p>Autoencoders, a term popularized by the numerous online courses on Deep Learning. But what are they? Are they actually of any use? Here, I make an effort to clarify all those doubts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T77TvfOEwWlf-VQx" /><figcaption>Photo by <a href="https://unsplash.com/@elijahsad?utm_source=medium&amp;utm_medium=referral">Elijah O&#39;Donnell</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For anyone who has been acquainted with Deep Learning for a few months, the term autoencoder has surely caught their attention. Most industrial tasks require one to be familiar with the encoder-decoder architecture and here, autoencoders surely do not go amiss. This is an area still under improvement and research for solving the unsupervised learning problem but currently has very particular use cases.</p><p>But not all of you will be having the same level of experience as people who have been around DL for some time, so I will try my best to “keep things simple” if there is anything as such.</p><p>Imagine this. You are taking a walk in the park when two people on a motorcycle snatch the gold necklace off your neck. A common incident, right? Could happen to anyone. In fact, it is so common that in 2018, in Delhi, 18 cases of chain snatching were reported per day. In most of the cases, the culprit is on a vehicle. Vehicles can be tracked down using the license plate number, right? Not if the CCTV camera meant to be there for our safety produces images in which the numbers are barely legible. This issue of clarity is something that has rendered hundreds of footages inadmissible in court and has resulted in the culprit getting off scot-free.</p><p>Enter denoising autoencoders (DAE). After passing the image of the bike’s plates through this model, we can very well expect a legible result. Stacking these DAEs results in something called <strong>a super-resolution generator.</strong> That in essence is taking a low-res image and making a high-res image out of it. Refer to this link for a demonstration with code: <a href="https://keras.io/examples/vision/super_resolution_sub_pixel/">https://keras.io/examples/vision/super_resolution_sub_pixel/</a></p><p>Today I will tell you a bit about how DAEs work and then go through some important things while dealing with the code and leave you with a notebook on how to denoise images.</p><p>So, what are Denoising Autoencoders? <strong>The DAE is an autoencoder that receives a corrupted data point as input and is trained to predict the original uncorrupted data point as the output</strong>. We introduce a corruption process C(x̄ | x) which represents a conditional distribution over corrupted samples x̄, given a data sample x. The autoencoder then learns a <strong>reconstruction distribution</strong> Pᵣₑ𝒸ₒₙₛₜᵣᵤ𝒸ₜ (x | x̄) estimated from training pairs (x, x̄), as follows:</p><p>1. Sample a training example x from the training data.</p><p>2. Sample a corrupted version x̄ from C(x̄ | X = x).</p><p>3. Use (x, x̄) as a training example for estimating the autoencoder reconstruction distribution Pᵣₑ𝒸ₒₙₛₜᵣᵤ𝒸ₜ(x | x̄) = P𝒹ₑ𝒸ₒ𝒹ₑᵣ (x | h) with h the output of the encoder.</p><p>f(x̄) and P𝒹ₑ𝒸ₒ𝒹ₑᵣ typically defined by a decoder g(h).</p><p>The last few lines must have been a whirlwind for quite a few of you. If it was not, then voila, you already know how DAEs work. For the people for whom it was, fret not. I was in your position not too long ago. Compare this to YouTube videos! Your training data is the 144p video frame and the target data is the 1080p video frame. So even if your model errs a bit on the way, you will be getting a 540p video. Upgrade!</p><p>So how do we create this DAE? I will be leaving the link to the notebook on my Github so check it out. I will go through some of the core aspects of the DAE in the article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b72644de0a9154d880bdcd544d74f27/href">https://medium.com/media/2b72644de0a9154d880bdcd544d74f27/href</a></iframe><p>The above snippet is for the creation of the convolutional autoencoder class. The dataset which we are manipulating is the <strong>Fashion MNIST dataset</strong>. We add a random value to each pixel in the dataset, effectively adding noise to the dataset. Coming back to our autoencoder class, we are able to see 2 convolutional layers in the encoder and 3 in the decoder. Keeping the fancy names aside, effectively the purpose of this “<em>encoder-decoder</em>” structure is to map a general relation between a noisy and a clear image.</p><p>Next, we compile the model and train it using the “fit” method. We have defined our class in such a way that it inherits the methods of the <strong>Tensorflow Model</strong> class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b5265e3933331a9fbec5ad3fce6ddca/href">https://medium.com/media/2b5265e3933331a9fbec5ad3fce6ddca/href</a></iframe><p>I would like to encourage all of you to code alongside reading this so that if you face any problems you can rectify them without having to search for where the error is happening and what is the logic for the code you are writing.</p><p>Please feel free to refer to my Github repository for any kind of assistance in this matter:<strong> </strong><a href="https://github.com/sreyan-ghosh/tensorflow_files/blob/master/Others/autoencoders_tf.ipynb"><strong>https://github.com/sreyan-ghosh/tensorflow_files/blob/master/Others/autoencoders_tf.ipynb</strong></a></p><p>It would also be a pleasure to connect with you all on LinkedIn: <a href="https://www.linkedin.com/in/sreyan-ghosh-b0722a18b/"><strong>https://www.linkedin.com/in/sreyan-ghosh-b0722a18b/</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=695ed3cdcaba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vitmas/denoising-autoencoders-explained-695ed3cdcaba">Denoising Autoencoders Explained</a> was originally published in <a href="https://medium.com/vitmas">VITMAS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Regularization Techniques in ML and DL]]></title>
            <link>https://medium.com/data-science/understanding-regularization-techniques-in-ml-and-dl-dd4669b613ac?source=rss-61465f0747f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd4669b613ac</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[regularization]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[simplicity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sreyan Ghosh]]></dc:creator>
            <pubDate>Tue, 05 May 2020 07:54:18 GMT</pubDate>
            <atom:updated>2020-05-07T17:35:37.861Z</atom:updated>
            <content:encoded><![CDATA[<h4>Insight into Regularization Techniques</h4><h4>A simple yet comprehensive outlook on techniques that reduce compute time and man-hours invested in training ML and DL models.</h4><figure><img alt="Always aim for the target however far away." src="https://cdn-images-1.medium.com/max/1024/0*ogkgEfiLGTE6uw67" /><figcaption>Photo by <a href="https://unsplash.com/@josephgardnerphotography?utm_source=medium&amp;utm_medium=referral">Joe Gardner</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>The overview:</strong></p><p>Now, as industries start to accept “Artificial Intelligence” as an important part of predicting their company’s success, the techniques of Machine Learning and Deep Learning are making their way into the job profile list of companies. But it is often seen that the actual decision-makers in a company (the people calling the shots: CxOs) have a very misguided notion of what these techniques can do and how their company can be benefitted. ML is often seen as a technology that has the potential to solve any and all industrial problems as per the people who don’t fully comprehend ML’s truth. The following picture makes the current state of ML quite clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R04OL4kfJjna_UgI" /></figure><p>This is not satire but a quite accurate understanding of ML. It is the un-hardcoded ability of computers to predict events while a set of precursor events is provided. I will try to keep this blog as non-math as possible but here I would like to include the fact that ML, in its essence, is the act of predicting the functional relation F between x and y given multiple such equations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/102/1*wDMn64AF2iNtseOkdeqfLw.png" /></figure><p>But many a time, it is seen that even after training a model and achieving an acceptable training accuracy, when the model is employed to work on the test cases, it fails miserably.</p><p>This happens due to the phenomenon of overfitting or making the function over-approximate the training data. This leads the model, instead of understanding the generic idea of how to solve the problem, to rote the training data. The following picture makes it clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/0*UinUofCKRuVd5Np5" /></figure><p>The real function is a sinusoid (green) and we are trying to predict it from the data given. Till the third figure, we see the model learning very well. It is an almost perfect approximation of the function even though all data points are not satisfied. But as training continues, we see the function molding itself to fit all data points and taking a form quite different from what is desired. This is overfitting. Where the training loss is taken to zero but the test loss rises</p><p><strong>Understanding Bias-Variance Tradeoff and the need for Regularization:</strong></p><p><strong>Bias</strong> is mathematically, the difference between the expected value and the actual value of the of the function. We won’t be going into the underlying statistics of bias but I will responsibly, leave you with a scary looking equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*4e9Z-KRq8MlsEkM55vAu2A.png" /></figure><p>To make things clear, the bias of a simple, linear model is high and that of a complex, multidimensional model, is low. This is because a complex model is better at fitting all the training data.</p><p><strong>Variance</strong> is the change in prediction accuracy of an ML model between training data and test data. Error due to variance is the amount by which the prediction, over one training set, differs from the expected value over all the training sets. In other words, how far are the values of the different predictions from each other as per the model. Another equation follows to scare you, folks, off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*IrqoLEPdaaNrCH_wk96UIA.png" /></figure><p>A simple model has a low variance whereas a complex one has a high variance.</p><p>The following graph can be used to establish the concepts of Bias and Variance clearly. The left end of the graph is the zone with high bias as both the training and the testing error are high. This is the zone of underfitting or the zone where the model has not learned enough.</p><p>The right end of the model is an area of high variance where the training error is low and but the testing error is high. This is the zone of overfitting, where we see that even though the model has achieved a high training accuracy, and it seems like the model is near perfect, it performs poorly on test data. This is a sheer waste of computational power and the engineer’s time.</p><p>The middle zone, where both the bias and variance are low, even though not the lowest possible is the best possible zone for a model. The act of achieving this state of model training is known as <strong>Bias-Variance Tradeoff.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1fMeJEwkZtaq9mF_" /></figure><p>There are various methods using which we can achieve Bias Variance Tradeoff. These methods or techniques are known as <strong>Regularization Techniques</strong>.</p><p>Some common ones are:</p><ul><li>L2 Regularization</li><li>Early Stopping</li><li>Dataset Augmentation</li><li>Ensemble methods</li><li>Dropout</li><li>Batch Normalization</li></ul><p><strong>L2 Regularisation:</strong></p><p>Keeping things as simple as possible, I would define L2 Regularization as “a trick to not let the model drive the training error to zero”. If only things were that simple…</p><p>During training a model, we have continuous updating of the various variables (weights and biases; w &amp; b) which try to predict our original function. This update takes place based on an “update rule” like Gradient Descent (which we won’t talk about). This update rule depends on the “loss function” which is a function of these variables. If things are getting complicated, bear with me. Our aim is to minimize this “loss function”. And that’s quite intuitive isn’t it? In any profitable industrial situation, you strive to minimize the loss. Simple, init?</p><p>So, we minimize the loss function during training. What is special about the L2 technique is that instead of minimizing the training loss, we minimize a different version of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*Z7ZAd1mWkTy-h0pGaxw5ww.png" /></figure><p>The first term in the equation above us is the ‘loss term’ or the term that measures how well the model fits the data. The last term is the “log of the likelihood of the Gaussian distribution of the weights” by the math folks. This measures the model complexity. For us, laymen, it is the sum of squares of all the feature weights (w). Here again, responsibly, I leave you with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*QeaqokdLKOMNMtjO47FrdQ.png" /></figure><p>This model complexity is quantified by the L2 technique. In this, the feature weights close to zero aren’t affected as much by the transformation, but the outliers have a huge impact. And the more the value of the above term, the more we see the increase in bias and decrease in variance. From the above graph, it is evident that at the end of the training, the bias is very low and the variance is high. So, if we were to increase in the bias and decrease the variance, we would effectively be reaching somewhere in the ‘good model’ zone of the graph. So now, we have a good model! Yay!</p><p><strong>Early Stopping:</strong></p><p>This is, by far, the simplest regularization technique (well all of them are, but you wouldn’t believe me, would you). This process involves recording the values of the variables (w &amp; b) at the minimum loss value. While going through the training process, we record the values of w &amp; b, at which we obtain the least validation error. We <strong>stop training</strong> when we see the validation error rising again. This is a very useful procedure but the downside to it is, during training very deep neural networks or very complex models, this utilizes a lot of processing power during the writing and rewriting the minimum values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/0*gVSqXbxIYpf_lzeP" /></figure><p><strong>Dataset Augmentation:</strong></p><p>Training a model to a good prediction state is only possible when we have a lot of data to train it on. In other words, it is quite easy to drive the training error to zero if the data is too less. Let’s take the example of training a neural network on image classification. Say we have 1000 images to train the model on. Wouldn’t it be better if we had say, 3000 images to train it on? Without procuring extra data, we can easily “augment” the current images and create “new” ones. These are not in fact, new to us, but to the model, it is as new as they come.</p><p>So what is <strong>augmentation</strong>? It is the act of artificially generating new data from the already available data by introducing certain variances in it while retaining the original labels. These variances depend on the type of data we are dealing with. For audio, speeding up the sample or introducing some background noise is an augmentation technique. This doesn’t change the label value. For text, we can replace a word by its synonyms and not change its conveying message. For images, we can change the viewing angle, the zoom, the lighting, and other techniques that change the image but retain its label. Here’s some cuteness to cancel out your boredom from reading this blog and make image augmentation clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*euzSfezmr-Sn0Bw1" /></figure><p>So, when we now have more data to feed our model, which makes it more difficult for it to memorize the entire thing and therefore, the training error isn’t driven to zero. Kinda like your history test, init?</p><p><strong>Ensemble Methods:</strong></p><p><strong>Ensemble methods</strong> are meta-algorithms that combine several machine learning techniques into one predictive model in order to decrease variance, bias, or improve predictions.</p><p>The above paragraph is Google’s definition of Ensemble Methods, and I’ll try to break it down for you. In this technique, we employ multiple model architectures to predict an output, be it classification or regression. Let’s say models A, B and C are given the task of classifying a dog: Model A says it’s a cat, but B and C say it’s a dog. So if we are to believe what the majority says, we arrive at the correct output, but if we were to trust the output of the first model, we would have erred. Similarly with regression, or value prediction. We take the weighted average of the predictions given the 3 models to arrive at our final output. This decreases the chance of an error and improves accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*j8y0JXYXj8A37SNA" /></figure><p>The interesting part about this is we needn’t spend resources on 3 models as well. We could train on the same model 3 times with different batches of the data. That would serve the purpose as well. But you get the idea, don’t you?</p><p><strong>Dropout:</strong></p><p>Dropout is also classified in the category of an ensemble method. But I, for fun, think it to be the reverse of that. In ensemble methods you ‘ask’ the opinion of other models to arrive at a conclusion but here, it is basically silencing other contributors. Let me make it clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*3s9DdHatGVmHUe-v" /></figure><p>This is a very simple neural network whose purpose is to be a True/False classifier. Look at the output layer (green). It has 2 blobs, one that gives the probability that the output is True and the other False. The sum of the two values: you guessed it: 1! Aren’t you smart? XD.</p><p>The idea here is to make you understand that these ‘blobs’ are called <strong>nodes</strong>. Each of these nodes has a ton of complex calculations happening inside them. Remember the stuff I was talking about in L2 Regularization? It all happens here. So these nodes are the actual contributors to the output.</p><p><strong>Dropout</strong> involves turning off certain nodes randomly. This changes the architecture of the model and the way information flows through the nodes. Doing this makes the model a more robust predictor. The model has to predict the same outputs with some of its contributors turned off. That’s like saying you need to get through your quiz without your topper friends being around. You gotta learn. Get it? XD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1LoG9CBJLWjytUCi" /></figure><p><strong>The Conclusion:</strong></p><p>So that sums up my blog on regularization techniques. I intentionally did not provide you with information on Batch Normalization as that would have required me to give you the entire process of training a neural network and that would have gone against the main idea behind this blog: keeping things simple.</p><p>If you are itching to know how to code these on Python using PyTorch, refer to the following repository on GitHub. The batchnorm_dropout.ipynb file will be of interest. I will be uploading TensorFlow files on another repo as well, to have the code on both these frameworks.</p><p><a href="https://github.com/sreyan-ghosh/pytorch_files">https://github.com/sreyan-ghosh/pytorch_files</a></p><p>I’ve had an amazing time writing this out for you folks and I hope you could take away something from this. If you liked it, leave a clap. If you didn’t you probably would’ve left the page long back. And if you have any queries, please feel free to comment down there. I’ll be looking forward to clearing your doubts.</p><p>I love making new friends, so here is my LinkedIn ID. Please connect if you wanna chat or even if you don’t. XD.</p><p><a href="https://www.linkedin.com/in/sreyan-ghosh-b0722a18b/">https://www.linkedin.com/in/sreyan-ghosh-b0722a18b/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd4669b613ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/understanding-regularization-techniques-in-ml-and-dl-dd4669b613ac">Understanding Regularization Techniques in ML and DL</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>