<?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 Divam Gupta on Medium]]></title>
        <description><![CDATA[Stories by Divam Gupta on Medium]]></description>
        <link>https://medium.com/@divamgupta?source=rss-d955ffaf8a54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*0pLM5IT4vVacO0FweXDxFQ.png</url>
            <title>Stories by Divam Gupta on Medium</title>
            <link>https://medium.com/@divamgupta?source=rss-d955ffaf8a54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 06 Apr 2026 06:03:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@divamgupta/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[An Introduction to Pseudo-semi-supervised Learning for Unsupervised Clustering]]></title>
            <link>https://medium.com/data-science/an-introduction-to-pseudo-semi-supervised-learning-for-unsupervised-clustering-fb6c31885923?source=rss-d955ffaf8a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb6c31885923</guid>
            <dc:creator><![CDATA[Divam Gupta]]></dc:creator>
            <pubDate>Sat, 31 Oct 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-11-15T17:59:51.823Z</atom:updated>
            <content:encoded><![CDATA[<p>This post gives an overview of our deep learning based technique for performing unsupervised clustering by leveraging semi-supervised models. An unlabeled dataset is taken and a subset of the dataset is labeled using pseudo-labels generated in a completely unsupervised way. The pseudo-labeled dataset combined with the complete unlabeled data is used to train a semi-supervised model.</p><p>This is a re-post of the original post: <a href="https://divamgupta.com/unsupervised-learning/2020/10/31/pseudo-semi-supervised-learning-for-unsupervised-clustering.html">https://divamgupta.com/unsupervised-learning/2020/10/31/pseudo-semi-supervised-learning-for-unsupervised-clustering.html</a></p><p>This work was published in ICLR 2020 and the paper can be found <a href="https://openreview.net/pdf?id=rJlnxkSYPS">here</a> and the source code can be found <a href="https://github.com/divamgupta/deep_clustering_kingdra">here</a>.</p><h3>Introduction</h3><p>In the past 5 years, several methods have shown tremendous success in semi-supervised classification. These models work very well when they are given a large amount of unlabeled data along with a small amount of labeled data.</p><p>The unlabeled data helps the model to discover new patterns in the dataset and learn high-level information. The labeled data helps the model to classify the data-points using the learned information. For example, Ladder Networks can yield 98% test accuracy with just 100 data-points labeled and the rest unlabeled.</p><p>In order to use a semi-supervised classification model for completely unsupervised clustering, we need to somehow generate a small number of labeled samples in a purely unsupervised way. These automatically generated labels are called pseudo-labels.</p><p>It is very important to have good quality pseudo-labels used to train the semi-supervised model. The classification performance drops if there is a large amount of noise in the labels. Hence, we are okay with having less number of pseudo-labeled data points, given that the noise in the pseudo-labels is less.</p><p>A straightforward way to do this is the following:</p><ol><li>Start with an unlabeled dataset.</li><li>Take a subset of the dataset and generate pseudo-labels for it, while ensuring the pseudo-labels are of good quality.</li><li>Train a semi-supervised model by feeding the complete unlabeled dataset combined with the small pseudo-labeled dataset.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*cXRiXuUPs8c6R3Sf" /><figcaption>Image by Author</figcaption></figure><blockquote><em>This approach uses some elements of semi-supervised learning but no actual labeled data-points are used. Hence, we call this approach pseudo-semi-supervised learning.</em></blockquote><h3>Generating pseudo-labels</h3><p>Generating high-quality pseudo-labels is the trickiest and the most important step to get good overall clustering performance.</p><p>The naive ways to generate a pseudo-labeled dataset are</p><ol><li>Run a standard clustering model on the entire dataset and make the pseudo-labels equal to the cluster IDs from the model.</li><li>Run a standard clustering model with way more number of clusters than needed. Then only keep a few clusters to label the corresponding data-points while discarding the rest.</li><li>Run a standard clustering model and only keep the data-points for which the confidence by the model is more than a certain threshold.</li></ol><p>In practice, none of the ways described above work.</p><p>The first method is not useful because the pseudo labels are just the clusters returned by the standard clustering model, hence we can’t expect the semi-supervised model to perform better than that.</p><p>The second way does not work because there is no good way to select distinct clusters.</p><p>The third way does not work because in practice the confidence of a single model is not an indicator of the quality.</p><p>After experimenting with several ways to generate a pseudo-labeled dataset, we observed that consensus of multiple unsupervised clustering models is generally a good indicator of the quality. The clusters of the individual models are not perfect. But if a large number of clustering models assign a subset of a dataset into the same cluster, then there is a good chance that they actually belong to the same class.</p><p>In the following illustration, the data points which are in the intersection of the cluster assignments of the two models could be assigned the same pseudo-label with high confidence. Rest can be ignored in the pseudo-labeled subset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/0*wYBi8lj_Fzh6RjBc" /><figcaption>Image by Author</figcaption></figure><h3>Using a graph to generate the pseudo-labels</h3><p>There is a more formal way to generate the pseudo-labeled dataset. We first construct a graph of all the data-points modeling the pairwise agreement of the models.</p><p>The graph contains two types of edges.</p><ol><li>Strong positive edge — when a large percentage of the models think that the two data-points should be in the same cluster</li><li>Strong negative edge — when a large percentage of the models think that the two data-points should be in different clusters.</li></ol><p>It is possible that there is neither a strong positive edge nor a strong negative edge between the two data-points. That means that confidence of the cluster assignments of those data points is low.</p><p>After constructing the graph, we need to pick K mini-clusters such that data-points within a cluster are connected with strong positive edges and the data-points of different clusters are connected with strong negative edges.</p><p>An example of the graph is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/0*Kj2xvKNHCx0TcnFl" /><figcaption><em>Example of a constructed graph. Strong positive edge — green , Strong negative edge — red. Image by the Author</em></figcaption></figure><p>We first pick the node with the maximum number of strong positive edges. That node in circled in the example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*lILFwIHgTI9JpUlx" /><figcaption><em>The selected node is circled. </em>Image by Author</figcaption></figure><p>We then assign a pseudo-label to the neighbors connected to the selected node with strong positive edges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*lQPRc6i9khv0w-ZG" /><figcaption>Image by Author</figcaption></figure><p>Nodes which are neither connected with a strong positive edge nor a strong negative edge are removed because we can’t assign any label with high confidence:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/0*JqjrudhFBJkwZIGr" /><figcaption>Image by Author</figcaption></figure><p>We then repeat the steps K more times to get K mini-clusters. All data-points in one mini-cluster are assigned the same pseudo-label:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*uGO0UF0WWEBRkmkg" /><figcaption><em>The final pseudo-labeled subset. </em>Image by Author</figcaption></figure><p>We can see that a lot of data-points will be discarded in this step, hence it’s ideal to send these pseudo-labeled data points to a semi-supervised learning model for the next step.</p><h3>Using pseudo-labels to train semi-supervised models</h3><p>Now we have a pruned pseudo-labeled dataset along with the complete unlabeled dataset which is used to train a semi-supervised classification network. The output of the network is a softmaxed vector which can be seen as the cluster assignment.</p><p>If the pseudo labels are of good quality, then this multi-stage training yields better clustering performance compared to the individual clustering models.</p><p>Rather than having separate clustering and semi-supervised models, we can have a single model that is capable of performing unsupervised clustering and semi-supervised classification. An easy way to do this to have a common neural network architecture and apply both the clustering losses and the semi-supervised classification losses.</p><p>We decided to use a semi-supervised ladder network combined with information maximization loss for clustering. You can read more about different deep learning clustering methods <a href="https://divamgupta.com/unsupervised-learning/2019/03/08/an-overview-of-deep-learning-based-clustering-techniques.html">here</a>.</p><h3>Putting everything together</h3><p>In the first stage, only the clustering loss is applied. After getting the pseudo-labels, both clustering and classification losses are applied to the model.</p><p>After the semi-supervised training, we can extract more pseudo-labeled data points using the updated models. This process of generating the pseudo labels and semi-supervised training can be repeated multiple times.</p><p>The overall algorithm is as follows:</p><ol><li>Train multiple independent models using the clustering loss</li><li>Construct a graph modeling pairwise agreement of the models</li><li>Generate the pseudo-labeled data using the graph</li><li>Train each model using unlabeled + pseudo-labeled data by applying both clustering and classification loss</li><li>Repeat from step 2</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/0*LzJrYwVPcvnnIB6W" /><figcaption><em>Overview of the final system. </em>Image by Author</figcaption></figure><h3>Evaluation</h3><p>We want our clusters to be close to the ground truth labels. But because the model is trained in a completely unsupervised manner, there is no fixed mapping of the ground truth classes and the clusters. Hence, we first find the one-to-one mapping of ground truth with the model clusters with maximum overlap. Then we can apply standard metrics like accuracy to evaluate the clusters. This is a very standard metric for the quantitative evaluation of clusters.</p><p>We can visualize the clusters by randomly sampling images from the final clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/0*0r96Ukc-9HHXStVb" /><figcaption><em>Visualizing the clusters of the MNIST dataset. Source: original paper.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/0*x2tBBvrYywKOF1K9" /><figcaption><em>Visualizing the clusters of the CIFAR10 dataset. Source: original paper.</em></figcaption></figure><p>In this post, we discussed a deep learning based technique for performing unsupervised clustering by leveraging pseudo-semi-supervised models. This technique outperforms several other deep learning based clustering techniques. If you have any questions or want to suggest any changes feel free to contact me or write a comment below.</p><p><strong>Get the full source code from </strong><a href="https://github.com/divamgupta/deep-clustering-kingdra"><strong>here</strong></a></p><p><em>Originally published at </em><a href="https://divamgupta.com/unsupervised-learning/2020/10/31/pseudo-semi-supervised-learning-for-unsupervised-clustering.html"><em>https://divamgupta.com</em></a><em> on October 31, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb6c31885923" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/an-introduction-to-pseudo-semi-supervised-learning-for-unsupervised-clustering-fb6c31885923">An Introduction to Pseudo-semi-supervised Learning for Unsupervised Clustering</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>
        <item>
            <title><![CDATA[An Introduction to Virtual Adversarial Training]]></title>
            <link>https://medium.com/@divamgupta/an-introduction-to-virtual-adversarial-training-540e744cf227?source=rss-d955ffaf8a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/540e744cf227</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[semi-supervised-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Divam Gupta]]></dc:creator>
            <pubDate>Fri, 31 May 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-06-10T13:54:17.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnmGyQXt5u9Nr6ZAfiXYlw.png" /></figure><p>Virtual Adversarial Training is an effective regularization technique which has given good results in supervised learning, semi-supervised learning, and unsupervised clustering.</p><p>This is a re-post of the original post: <a href="https://divamgupta.com/unsupervised-learning/semi-supervised-learning/2019/05/31/introduction-to-virtual-adversarial-training.html">https://divamgupta.com/unsupervised-learning/semi-supervised-learning/2019/05/31/introduction-to-virtual-adversarial-training.html</a></p><p><strong>Get the source code used in this post from </strong><a href="https://gist.github.com/divamgupta/c778c17459c1f162e789560d5e0b2f0b"><strong>here</strong></a></p><p>Virtual adversarial training has been used for:</p><ol><li>Improving supervised learning performance</li><li>Semi-supervised learning</li><li>Deep unsupervised clustering</li></ol><p>There are several regularization techniques which prevent overfitting and help the model generalize better for unseen examples. Regularization helps the model parameters to be less dependent on the training data. The two most commonly used regularization techniques are Dropout and L1/L2 regularization.</p><p>In L1/L2 regularization, we add a loss term which tries to reduce the L1 norm or the L2 norm of the weights matrix. Small value of weights would result in simpler models which are less prone to overfitting.</p><p>In Dropout, we randomly ignore some neurons while training. This makes the network more robust to noise and variation in the input.</p><p>In neither of the two techniques mentioned, the input data distribution is taken into account.</p><h3>Local distributional smoothness</h3><p>Local distributional smoothness (LDS) can be defined as the smoothness of the output distribution of the model, with respect to the input. We do not want the model to be sensitive to small perturbations in the inputs. We can say that, there should not be large changes in the model output with respect to small changes in the model input.</p><p>In LDS regularization, smoothness of the model distribution is rewarded. It is also invariant of the parameters on the network and only depends on the model outputs. Having a smooth model distribution should help the model generalize better because the model would give similar outputs for unseen data-points which are close to data-points in the training set. Several studies show that making the model robust against small random perturbations is effective for regularization.</p><p>An easy way for LDS regularization is to generate artificial data-points by applying small random perturbations on real data points. After that encourage the model to have similar outputs for the real and perturbed data points. Domain knowledge can also be used to make better perturbations. For example, if the inputs are images, various image augmentation techniques such as flipping, rotating, transforming the color can be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*qoXCNxruRnRKIopu" /><figcaption>Example of input data transformation</figcaption></figure><h3>Virtual adversarial training</h3><p>Virtual adversarial training is an effective technique for local distribution smoothness. Pairs of data points are taken which are very close in the input space, but are very far in the model output space. Then the model is trained to make their outputs close to each other. To do that, a given input is taken and perturbation is found for which the model gives very different output. Then the model is penalized for sensitivity with the perturbation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/0*FfaGnuwgd8q9jKdT" /><figcaption>Step 1 : Generate the adversarial image</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/0*RMoLJdrf3BUuEk_5" /><figcaption>Step 2: Minimize the KL divergence</figcaption></figure><p>The key steps for virtual adversarial training are:</p><ol><li>Begin with an input data point <em>x</em></li><li>Transform <em>x</em> by adding a small perturbation <em>r</em>, hence the transformed data point will be <em>T(x) = x + r</em></li><li>The perturbation r should be in the adversarial direction — model output of the perturbed input T(x) should be different from the output of non-perturbed input. In particular, the KL divergence between the two output distributions should be maximum, while ensuring the L2 norm of <em>r</em> to be small. From all the perturbations <em>r,</em> let be the perturbation in the adversarial direction.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*Uo6TDd3ArEdGfiCg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*OwtvGrnVV__2BRUG" /></figure><p>After finding the adversarial perturbation and the transformed input, update the weights of the model such that the KL divergence is minimized. This would make the model robust towards different perturbations. The following loss is minimized via gradient descent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*2oM8e_6bUjYMuV45" /></figure><p>During the virtual adversarial training, the model becomes more robust against different input perturbations. As the model becomes more robust, it becomes harder to generate perturbations and a drop in the loss is observed.</p><p>This method can be seen as similar to generative adversarial networks. But there are several differences:</p><ol><li>Rather than having a generator to fool the discriminator, a small perturbation is added to the input, in order to fool the model in thinking they are two vastly different inputs.</li><li>Rather than discriminating between fake and real, the KL divergence between the model outputs is used. While training the model ( which is analogous to training the discriminator) we minimize the KL divergence.</li></ol><p>Virtual adversarial training can be thought of as an effective data augmentation technique where we do not need prior domain knowledge. This can be applied to all kinds of input distributions, hence useful for true “unsupervised learning”.</p><h4>How is virtual adversarial training different from adversarial training?</h4><p>In adversarial training, labels are also used to generate the adversarial perturbations. The perturbation is generated such that classifier’s predicted label <em>y’</em> becomes different from the actual label <em>y</em>.</p><p>In virtual adversarial training, no label information is used and the perturbation is generated using just the model outputs. The perturbation is generated such that output of the perturbed input is different from the model output of the original input ( as opposed to the ground truth label).</p><h3>Implementing virtual adversarial training</h3><p>Now we will implement basic virtual adversarial training using Tensorflow and Keras. The full code can be found <a href="https://gist.github.com/divamgupta/c778c17459c1f162e789560d5e0b2f0b">here</a></p><p>First, define the neural network in Keras</p><pre>network = Sequential()<br>network.add( Dense(100 ,activation=&#39;relu&#39; ,  input_shape=(2,)))<br>network.add( Dense( 2  ))</pre><p>Define the model_input , the logits p_logit by applying the input to the network and the probability scores p by applying softmax activation on the logits.</p><pre>model_input = Input((2,))<br>p_logit = network( model_input )<br>p = Activation(&#39;softmax&#39;)( p_logit )</pre><p>To generate the adversarial perturbation, start with random perturbation r and make it unit norm.</p><pre>r = tf.random_normal(shape=tf.shape( model_input ))<br>r = make_unit_norm( r )</pre><p>The output logits of the perturbed input would be p_logit_r</p><pre>p_logit_r = network( model_input + 10*r  )</pre><p>Now compute the KL divergence of logits from the input and the perturbed input.</p><pre>kl = tf.reduce_mean(compute_kld( p_logit , p_logit_r ))</pre><p>To get the adversarial perturbation, we need an r such that the KL-divergence is maximized. Hence take the gradient of kl with respect to r. The adversarial perturbation would be the gradient. We use the stop_gradient function because we want to keep r_vadv fixed while back-propagation.</p><pre>grad_kl = tf.gradients( kl , [r ])[0]</pre><p>Finally, normalize the norm adversarial perturbation. We set the norm of r_vadv to a small value which is the distance we want to go along the adversarial direction.</p><pre>r_vadv = make_unit_norm( r_vadv )/3.0</pre><p>Now we have the adversarial perturbation r_vadv , for which the model gives a very large difference in outputs. We need to add a loss to the model which would penalize the model for having large KL-divergence with the outputs from the original inputs and the perturbed inputs.</p><pre>p_logit_r_adv = network( model_input  + r_vadv )<br>vat_loss =  tf.reduce_mean(compute_kld( tf.stop_gradient(p_logit), p_logit_r_adv ))</pre><p>Finally, build the model and attach the vat_loss .</p><pre>model_vat = Model(model_input , p )<br>model_vat.add_loss( vat_loss   )<br>model_vat.compile( &#39;sgd&#39; ,  &#39;categorical_crossentropy&#39;  ,  metrics=[&#39;accuracy&#39;])</pre><p>Now let’s use some synthetic data to train and test the model. This dataset is two dimensional and has two classes. Class 1 data-points lie in the outer ring and the class 2 data-points lie in the inner ring. We are using only 8 data-points per class for training, and 1000 data-points for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/0*qVWxyU6F_slLdhmw" /><figcaption><em>The plot of the synthetic dataset on a 2D plane</em></figcaption></figure><p>Let’s train the model by calling the fit function.</p><pre>model.fit( X_train , Y_train_cat )</pre><h3>Visualizing model outputs</h3><p>Now, let’s visualize the output space of the model along with training and the testing data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*C_XQ0t6Gz9qUGrYl" /><figcaption><em>Model decision boundary with virtual adversarial training</em></figcaption></figure><p>For this example dataset, it is pretty evident that the model with virtual adversarial training has generalized better and its decision boundary lies in the bounds of the test data as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*9RWcL82o1baxABE3" /><figcaption><em>Model decision boundary without virtual adversarial training</em></figcaption></figure><p>For the model without virtual adversarial training, we see some overfitting on the training data-points. The decision boundary, in this case, is not good and overlapping with the other class.</p><h3>Applications of virtual adversarial training</h3><p>Virtual adversarial training has shown incredible results for various applications in semi-supervised learning and unsupervised learning.</p><p><strong>VAT for semi-supervised learning:</strong> Virtual adversarial training has shown good results in semi-supervised learning. Here, we have a large number of unlabeled data-points and a few labeled data points. Applying the vat_loss on the unlabeled set and the supervised loss on the labeled set gives a boost in testing accuracy. The authors show the superiority of the method over several other semi-supervised learning methods. You can read more in the paper <a href="https://arxiv.org/abs/1704.03976">here</a>.</p><p><strong>Virtual adversarial ladder networks</strong>: <a href="https://arxiv.org/abs/1507.02672">Ladder networks</a> have shown promising results for semi-supervised classification. There, at each input layer, random noise is added and a decoder is trained to denoisify the outputs at each layer. In virtual adversarial ladder networks, rather than using random noise, adversarial noise is used. You can read more in the paper <a href="https://arxiv.org/abs/1711.07476">here</a>.</p><p><strong>Unsupervised clustering using self-augmented training</strong>: Here the goal is to cluster the data-points in a fixed number of clusters without using any labeled samples. <a href="https://papers.nips.cc/paper/4154-discriminative-clustering-by-regularized-information-maximization">Regularized Information Maximization</a> is a technique for unsupervised clustering. Here the mutual information between the input and the model output is maximized. <a href="https://arxiv.org/abs/1702.08720">IMSAT</a> has extended the approach by adding virtual adversarial training. Along with the mutual information loss, the authors apply the vat_loss. They show great improvements after adding virtual adversarial training. You can read more in the <a href="https://arxiv.org/abs/1702.08720">paper</a> and my earlier <a href="https://divamgupta.com/unsupervised-learning/2019/03/08/an-overview-of-deep-learning-based-clustering-techniques.html">blog post.</a></p><h3>Conclusion</h3><p>In this post, we discussed an efficient regularization technique called virtual adversarial training. We also dived in the implementation using Tensorflow and Keras. We observed that the model with VAT performs better when there are very few training samples. We also discussed various other works which use virtual adversarial training. If you have any questions or want to suggest any changes feel free to contact me or write a comment below.</p><p><strong>Get the full source code from </strong><a href="https://gist.github.com/divamgupta/c778c17459c1f162e789560d5e0b2f0b"><strong>here</strong></a></p><h3>References</h3><ul><li><a href="https://arxiv.org/abs/1412.6572">Explaining and Harnessing Adversarial Examples</a></li><li><a href="https://arxiv.org/abs/1507.00677">Distributional Smoothing with Virtual Adversarial Training</a></li><li><a href="https://arxiv.org/abs/1704.03976">Virtual Adversarial Training: A Regularization Method for Supervised and Semi-Supervised Learning</a></li><li><a href="https://arxiv.org/abs/1711.07476">Virtual Adversarial Ladder Networks For Semi-supervised Learning</a></li><li><a href="https://arxiv.org/abs/1702.08720">Learning Discrete Representations via Information Maximizing Self-Augmented Training</a></li></ul><p><em>Originally published at </em><a href="https://divamgupta.com/unsupervised-learning/semi-supervised-learning/2019/05/31/introduction-to-virtual-adversarial-training.html"><em>https://divamgupta.com</em></a><em> on May 31, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=540e744cf227" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Overview of Deep Learning Based Clustering Techniques]]></title>
            <link>https://medium.com/@divamgupta/an-overview-of-deep-learning-based-clustering-techniques-ff640f108b5d?source=rss-d955ffaf8a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff640f108b5d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Divam Gupta]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-06-08T14:19:26.067Z</atom:updated>
            <content:encoded><![CDATA[<p>This post gives an overview of various deep learning based clustering techniques. I will be explaining the latest advances in unsupervised clustering which achieve state-of-the-art performance by leveraging deep learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7A0qNVuOjgGh6pj4WUq5A.png" /></figure><p>This is a re-post of the original article: <a href="https://divamgupta.com/unsupervised-learning/2019/03/08/an-overview-of-deep-learning-based-clustering-techniques.html">https://divamgupta.com/unsupervised-learning/2019/03/08/an-overview-of-deep-learning-based-clustering-techniques.html</a></p><p>Unsupervised learning is an active field of research and has always been a challenge in deep learning. Finding out meaningful patterns from large datasets without the presence of labels is extremely helpful for many applications. Advances in unsupervised learning are very crucial for artificial general intelligence. Performing unsupervised clustering is equivalent to building a classifier without using labeled samples.</p><p>In the past 3–4 years, several papers have improved unsupervised clustering performance by leveraging deep learning. Several models achieve more than 96% accuracy on MNIST dataset without using a single labeled datapoint. However, we are still very far away from getting good accuracy for harder datasets such as CIFAR-10 and ImageNet.</p><p>In this post, I will be covering all the latest clustering techniques which leverage deep learning. The goal of most of these techniques is to clusters the data-points such that the data-points of the same ground truth class are assigned the same cluster. The deep learning based clustering techniques are different from traditional clustering techniques as they cluster the data-points by finding complex patterns rather than using simple pre-defined metrics like intra-cluster euclidean distance.</p><h3>Clustering with unsupervised representation learning</h3><p>One method to do deep learning based clustering is to learn good feature representations and then run any classical clustering algorithm on the learned representations. There are several deep unsupervised learning methods available which can map data-points to meaningful low dimensional representation vectors. The representation vector contains all the important information of the given data-point, hence clustering on the representation vectors yield better results.</p><p>One popular method to learn meaningful representations is deep auto-encoders. Here the input is fed into a multilayer encoder which has a low dimensional output. That output is fed to a decoder which produces an output of the same size as input. The training objective of the model is to reconstruct the given input. In order to do that successfully, the learned representations from the encoder contain all the useful information compressed in a low dimensional vector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/0*HEu3X5G9rJaSSYbW.png" /></figure><p>Running K-means on representation vectors learned by deep autoencoders tend to give better results compared to running K-means directly on the input vectors. For example in MNIST, clustering accuracy of K Means is 53.2% while running K-means on the learned representations from auto-encoders yield an accuracy of 78.9%.</p><p>Other techniques to learn meaningful representations include :</p><ul><li><a href="https://jaan.io/what-is-variational-autoencoder-vae-tutorial/">Variational Autoencoders</a></li><li><a href="https://web.stanford.edu/class/cs294a/sparseAutoencoder.pdf">Sparse Autoencoders</a></li><li><a href="https://openreview.net/pdf?id=Bklr3j0cKX">Deep InfoMax</a></li><li><a href="https://openreview.net/pdf?id=B1ElR4cgg">BiGAN</a></li></ul><h3>Clustering via information maximization</h3><p>Regularized Information Maximization is an information theoretic approach to perform clustering which takes care of class separation, class balance, and classifier complexity. The method uses a differentiable loss function which can be used to train multi-logit regression models via backpropagation. The training objective is to maximize the mutual information between the input <em>x</em> and the model output <em>y</em> while imposing some regularisation penalty on the model parameters.</p><p>Mutual information can be represented as the difference between marginal entropy and conditional entropy. Hence the training objective to minimize is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/0*5_l4fl6cxdU0c8u0.png" /></figure><p>Here it is maximizing the marginal entropy <em>H(Y)</em> and minimizing the conditional entropy <em>H( Y|X )</em>.</p><p>By maximizing <em>H(Y)</em>, the cluster assignments are diverse, hence the model cannot degenerate by assigning a single cluster to all the input data points. In fact, it will try to make the distribution of clusters as uniform as possible because entropy will be maximum when the probability of each cluster is the same.</p><p>The neural network model with the softmax activation estimates the conditional probability <em>p( y|x )</em>. By minimizing <em>H( Y|X )</em>, it ensures that the cluster assignment of any data point is with high confidence. If <em>H( Y|X )</em> is not minimized and only <em>H(Y)</em> is maximized, the model can degenerate by assigning an equal conditional probability to each cluster given any input.</p><p>While implementing in order to compute H(Y), p(y) is computed by marginalizing <em>p( y|x )</em> over a mini-batch. For a given <em>x</em>, <em>p( y|x )</em> is the output of the network after the softmax activation.</p><h3>Information maximization with self augmented training.</h3><p>The method described above assigns clusters while trying to balance the number of data points in the clusters. The only thing which tries to ensure the cluster assignments to be meaningful is the regularization penalty on the model parameters. A better way to ensure the cluster assignments to be meaningful is to have a way such that similar data-points go to the same clusters.</p><p>Information maximization with self augmented training ( IMSAT) is an approach which uses data augmentation to generate similar data-points. Given a data point <em>x</em>, an augmented training example T( <em>x</em>) is generated where T : <em>X</em> → <em>X</em> denote a pre-defined data augmentation function. The cross entropy between <em>p( y|x )</em> and <em>p( y|T(x) )</em> is minimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/0*rF7P8GKHlZTDQzqK.png" /></figure><p>The authors of IMSAT propose two ways to augment the data and train the model : 1) Random Perturbation Training 2) Virtual Adversarial Training</p><p><strong>Random Perturbation Training ( RPT )</strong> : Here a random perturbation <em>r</em> from a pre-defined noise distribution is added to the input. Hence the, augmentation function will be <em>T(x) = x + r</em> . The random perturbation r is chosen randomly from hyper-sphere. As you can see, this is a very naive way to do augmentation.</p><p><strong>Virtual Adversarial Training ( VAT )</strong> : Here, rather than randomly choosing the perturbation randomly, the perturbation is chosen such that the model fails to assign them to the same cluster. A limit is imposed on the perturbation <em>r</em> so that input is not changed a lot.</p><p>This training is somewhat similar to how GANs are trained. Rather than having a generator fooling the discriminator, we generate a perturbation such the model is fooled in assigning the pair different clusters. Simultaneously it makes the model better and it does not make the same mistake in the future. The paper reports significant improvement in VAT over RPT for some datasets.</p><p>You can read more about virtual adversarial training <a href="https://arxiv.org/abs/1704.03976">here</a>.</p><h3>Deep Adaptive Clustering</h3><p>Deep adaptive clustering ( DAC ) uses a pairwise binary classification framework. Given two input data-points, model outputs whether the inputs belong to the same cluster or not. Basically, there is a network with a softmax activation which takes an input data-point and produces a vector with probabilities of the input belong to the given set of clusters. Given two input data-points, the dot product of the model outputs of both the inputs is taken. When the cluster assignments of the two inputs are different, the dot product will be zero and for the same cluster assignments, the dot product will be one. As dot product is a differentiable operation, we can train it with backpropagation with pairwise training labels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/0*zQ_lNAs3pf-YzIfD.png" /></figure><p>As the ground truth data is not available, the features of the same network are used to create binary labels for the pairwise training. Cosine distance between the features of the two data-points is used. Given an input pair, if the cosine distance is greater than the upper threshold, then the input pair is considered a positive pair ( meaning both should be in the same cluster). Similarly, if the cosine distance is lesser than the lower threshold then the input pair is considered a negative pair ( meaning both should be in different clusters ). If the distance lies between the lower threshold and the upper threshold, the pair is ignored. After getting the positive and the negative pairs, the pairwise loss is minimized.</p><p>As the pairwise loss is minimized, it becomes better in classifying pair of data-points and the features of the network become more meaningful. With features becoming more meaningful, the binary labels obtained via cosine distance of the features become more accurate.</p><p>You may think this as a chicken and egg problem and the question is how to get a good start. The solution is having a good random initialization distribution. With standard initialization techniques, even with random model weights output is related to the inputs ( behaving like <a href="https://en.wikipedia.org/wiki/Extreme_learning_machine">extreme learning machine</a> ). Hence cosine distance of the features is somewhat meaningful in the beginning. In the beginning, the upper threshold is set to a large value as the cosine distance measure is not very accurate. Over iterations, the upper threshold is decreased.</p><h3>Conclusion</h3><p>I hope this post was able to give you an insight into various deep learning based clustering techniques. The deep learning based methods have outperformed traditional clustering techniques in many benchmarks. Most of the methods discussed are promising and there is huge potential for improvement in several datasets. If you have any questions or want to suggest any changes feel free to contact me or write a comment below.</p><h3>References</h3><ul><li><a href="https://arxiv.org/abs/1702.08720">Learning Discrete Representations via Information Maximizing Self-Augmented Training</a></li><li><a href="http://openaccess.thecvf.com/content_ICCV_2017/papers/Chang_Deep_Adaptive_Image_ICCV_2017_paper.pdf">Deep Adaptive Image Clustering</a></li><li><a href="https://www.jeremyjordan.me/autoencoders/">Introduction to autoencoders.</a></li><li><a href="https://papers.nips.cc/paper/4154-discriminative-clustering-by-regularized-information-maximization">Discriminative Clustering by Regularized Information Maximization</a></li></ul><p><em>Originally published at </em><a href="https://divamgupta.com/unsupervised-learning/2019/03/08/an-overview-of-deep-learning-based-clustering-techniques.html"><em>https://divamgupta.com</em></a><em> on March 8, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff640f108b5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>