<?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 Scarlett KONG on Medium]]></title>
        <description><![CDATA[Stories by Scarlett KONG on Medium]]></description>
        <link>https://medium.com/@haojia-kong?source=rss-69c6aa6d5cde------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A2XLwJOKFV0An1HOy5SUjA.png</url>
            <title>Stories by Scarlett KONG on Medium</title>
            <link>https://medium.com/@haojia-kong?source=rss-69c6aa6d5cde------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 09:29:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haojia-kong/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[Quantum Computing Challenge in 21 Days.]]></title>
            <link>https://haojia-kong.medium.com/quantum-computing-challenge-in-21-days-0d7be2b0d3da?source=rss-69c6aa6d5cde------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d7be2b0d3da</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[21-days-challenge]]></category>
            <dc:creator><![CDATA[Scarlett KONG]]></dc:creator>
            <pubDate>Fri, 05 Sep 2025 10:06:33 GMT</pubDate>
            <atom:updated>2025-09-05T10:06:33.802Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quantum Computing Challenge in 21 Days. Day 1: Why Quantum Computing Starts with Complex Numbers and Linear Algebra ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VweJuj7drkYkoR3bnj_v2Q.png" /></figure><p><em>The Mathematical Foundation That Changes Everything.</em></p><p>In late August, IBM and AMD announced plans to develop quantum-centric supercomputing — hybrid architectures combining quantum computers with high-performance computing. The quantum revolution continues to gain momentum.</p><p>As a graduate student passionate about cutting-edge technology, I’ve been fascinated by quantum computing for years — but I’ll be honest: I’ve hit walls before. Complex mathematics, abstract concepts, and information scattered across textbooks and research papers made it feel impossible to build a solid foundation.</p><p>This time is different. I’m committing to a structured 21-day learning journey, inspired by QuCode.in’s curriculum, and I want you to join me. Instead of struggling alone, we’ll tackle quantum computing together — one concept at a time, one day at a time.</p><p>This isn’t another dry technical article. I’m not pretending to be an expert teaching from above.<strong> I’m a student sharing my real learning journey, breaking down complex ideas into plain language, and building the solid quantum computing foundation that has eluded me (and maybe you) before.</strong></p><p>Over the next 21 days, we’ll transform from confused beginners into <strong>confident practitioners who truly understand quantum computing’s principles and applications.</strong></p><h3>Why Start with Math?</h3><p>Quantum computing uses a completely different language than classical computing. While classical computers use bits (0 or 1), quantum computers use qubits that follow quantum mechanical laws. This creates a much richer computational space for solving complex problems in drug discovery, materials science, optimization, and logistics.</p><p>Complex numbers and linear algebra are the alphabet and grammar of quantum computing. Once we understand these mathematical tools, we can easily follow the math behind quantum states, quantum gates, entanglement, and measurement.</p><h3>Complex Numbers: The Language of Quantum States</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z1mfuxSEi2OdvYdiYOLhug.png" /></figure><p>💡 Why This Matters in Quantum Computing:</p><ul><li>Qubit amplitudes are complex numbers (α, β)</li><li>Measurement probabilities use |α|² and |β|²</li><li>The relative phase between amplitudes can dramatically change outcomes</li></ul><h3>Linear Algebra: The Structure of Quantum Operations</h3><p>1. Vectors = Quantum States</p><p>Quantum states are represented as column vectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYIrcawuXISpaklo-jpRcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WI19VaXqdj7Q258ZVp4dBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdG8ZeqqvdIwfouIRfxLuQ.png" /></figure><h3><strong>What’s Next?</strong></h3><p>Tomorrow, we’ll dive into probability and statistics — essential foundational knowledge we need before exploring quantum computing concepts.</p><p>Here’s what makes this fascinating: when you measure a classical bit, you always get either 0 or 1 with certainty. But when you measure a quantum bit, the outcome is probabilistic — yet these probabilities aren’t random. They’re precisely determined by the complex amplitudes we just learned about.</p><p>We’ll explore how |α|² and |β|² become the probabilities of measuring |0⟩ and |1⟩, probability distributions, expected values, and variance. You’ll see why understanding these statistical concepts is crucial for interpreting quantum measurement results and designing quantum algorithms.</p><p>Key Takeaway: Quantum computing isn’t magic — it’s mathematics. Complex numbers capture the wave-like nature of quantum states, while linear algebra provides the framework for manipulating and measuring these states.</p><p>Ready to continue this journey? Tomorrow we’ll build the probability foundation that makes quantum mechanics measurable and predictable.</p><h3>References &amp; Further Reading</h3><p>- QuCode.in <a href="https://qucode.in/">https://qucode.in/</a></p><p>- IBM Press Release: “IBM and AMD Join Forces to Build the Future of Computing” <a href="https://newsroom.ibm.com/2025-08-26-ibm-and-amd-join-forces-to-build-the-future-of-computing">https://newsroom.ibm.com/2025-08-26-ibm-and-amd-join-forces-to-build-the-future-of-computing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d7be2b0d3da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adversarial in Domain Adaptation]]></title>
            <link>https://haojia-kong.medium.com/adversarial-in-domain-adaptation-84d18ebee84b?source=rss-69c6aa6d5cde------2</link>
            <guid isPermaLink="false">https://medium.com/p/84d18ebee84b</guid>
            <category><![CDATA[adversarial-network]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[gans]]></category>
            <category><![CDATA[domain-adaptation]]></category>
            <dc:creator><![CDATA[Scarlett KONG]]></dc:creator>
            <pubDate>Thu, 22 Sep 2022 13:48:11 GMT</pubDate>
            <atom:updated>2022-09-23T06:31:15.120Z</atom:updated>
            <content:encoded><![CDATA[<p>This series of articles is focused on <strong>unsupervised domain adaptation</strong>. Unsupervised domain adaptation handles situations where there are labeled data from a source domain and unlabeled data from a related but different target domain with a different distribution. The goal of the domain adaptation learning methods is to utilize labeled samples from the source domain to learn a robust classifier for the target domain which has a few or even no labeled samples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5q9C670hafZ6GyEjV-1Sw.jpeg" /><figcaption>From [1] <a href="https://arxiv.org/abs/1511.05547"><em>Return of frustratingly easy domain adaptation</em></a></figcaption></figure><h4>GAN, huh?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dKSYwtj06lghiZC7.png" /><figcaption>GAN from:<a href="https://geekflare.com/generative-adversarial-networks/">Generative Adversarial Networks (GAN): An Introduction — Geekflare</a></figcaption></figure><p>There is a <strong>Generator</strong> and a <strong>Discriminator</strong> in GANs. On one hand, the Generator generates fake samples of data and tries to fool the Discriminator. On the other hand, the Discriminator tries to distinguish between real and fake samples.</p><p>The Generator and Discriminator are both neural networks and they run in competition with each other during the training process. The GANs are formulated as a minimax optimizer.</p><h4>The Math Behind GANs</h4><p>The following is a long jpg to explain the math behind GANs. It is optional whether you skip this part or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*qpltfGRiSmSKtmwves8Djw.jpeg" /></figure><p>For more details, you could also <a href="https://jaketae.github.io/study/gan-math/">check t</a>his blog!</p><h4>Domain Invariant Feature Learning</h4><p>A typical idea is to align source and target domains by creating a domain-invariant feature representation. A feature representation is domain-invariant if the features follow the same distribution regardless of whether the input data are from the source or target domain. If a classifier can be trained to perform well in the source domain using domain-invariant features, then the classifier may generalize well to the target domain since the features of the target data match those on which the classifier was trained.</p><p><em>DANN</em>[2] is a classical method for solving this problem.</p><h4>How does <em>DANN</em> work?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tVFI9ogzBJgz0Is15hwTcA.png" /><figcaption>Architecture of DANN</figcaption></figure><p>Reference:</p><p>[1]Sun, B., Feng, J., and Saenko, K., “Return of Frustratingly Easy Domain Adaptation”, &lt;i&gt;arXiv e-prints&lt;/i&gt;, 2015.</p><p>[2]Hana Ajakan et al. “Domain-Adversarial Neural Networks” arXiv: Machine Learning (2014): n. pag.</p><p>[3]<a href="https://jaketae.github.io/study/gan-math/">The Math Behind GANs — Jake Tae</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84d18ebee84b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let the ML model admit when it doesn’t know.]]></title>
            <link>https://haojia-kong.medium.com/let-the-ml-model-admit-when-it-doesnt-know-4b7e512c455?source=rss-69c6aa6d5cde------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b7e512c455</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[outlier-detection]]></category>
            <category><![CDATA[active-learning]]></category>
            <category><![CDATA[out-of-distribution]]></category>
            <dc:creator><![CDATA[Scarlett KONG]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 16:15:41 GMT</pubDate>
            <atom:updated>2022-09-07T00:04:22.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overconfidence in Out-of-Distribution Detection</h3><p>Machine learning models are known to generalize well when all testing data and training data are sampled from the same distribution. However, a more realistic scenario is that incomplete knowledge of the world’s present at training time, and irrelevant samples from unknown classes or distributions can be submitted to the ML model during testing[1]. Research shows that the ML model can incorrectly classify test samples from unknown classes or different semantic distributions as one of the known categories with high confidence. Classifiers failing to indicate when they are likely mistaken can limit their adoption or cause serious accidents. Such notorious behavior of the ML model is referred to as “arrogance” or “agnostophobin”. It is an emergency that models need to reject label-shifted samples to guarantee reliability and safety. The field of out-of-distribution detection is proposed to address this problem.</p><p>Out-of-distribution(OOD) detection aims to detect test samples with non-overlapping labels w.r.t training data. In the OOD detection setting, test samples come from the distribution with the semantic shift from ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*L1uBaQUMkge3FggLMWdf6Q.png" /><figcaption>there is a semantic shift between OOD distribution and ID distribution</figcaption></figure><p>OOD Detection considers the problem of distinguishing in- and out-of-distribution samples. In this blog, we focus on detecting out-of-distribution images in the image classification task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Rkx8Q2rHbJUAzi6_whtyg.png" /><figcaption>Fig1: Out-of-distribution detection: ID images belong to multiple classes. Test images from different distributions with training distributions will be considered as OOD samples.</figcaption></figure><h4>What mechanism triggers overconfident predictions on OOD samples?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FsY4Gj1qQyugQpK8uurCHw.png" /><figcaption>Fig2: The framework of a CNN model</figcaption></figure><p>Research shows that these high-confidence predictions are frequently produced by softmax because softmax probabilities are computed with the fast-growing exponential function(see Fig3), which means minor additions to the softmax inputs, i.e. the logits, can lead to substantial changes in the output distribution. Besides, since the softmax function is a smooth approximation of an indicator function, it is uncommon to see a uniform distribution outputted for out-of-distribution examples. Indeed, even random Gaussian noise fed into an MNIST image classifier could give a “prediction confidence” probability of a 91% high score. [2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*Dpu2NRUnqtHtqiRJ.png" /><figcaption>Figure 3: softmax function From <a href="https://911weknow.com/wp-content/uploads/2020/09/understand-the-softmax-function-in-minutes-2.png">https://911weknow.com/wp-content/uploads/2020/09/understand-the-softmax-function-in-minutes-2.png</a></figcaption></figure><h4>How do we design methods to detect in-distribution(ID) samples and out-of-distribution(OOD) samples?</h4><p>Classification-based methods, density-based methods, and distance-based methods are three ways to achieve this goal. In this blog, we choose one branch of classification-based methods because it could be applied to any well-trained neural network without further re-training networks.</p><h4><strong>Max-Softmax</strong></h4><p>The prediction probability of incorrect and out-of-distribution examples tends to be lower than the prediction probability for correct examples, so capturing prediction probability statistics about correct or in-sample examples is often sufficient for detecting OOD [2]. Therefore, a simple baseline is using the maximum softmax probability as the indicator score of ID-ness. A classical method is Max-Softmax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRWzXSbXlZ6nPAnJBt8RYA.png" /><figcaption>Figure 4: OOD detector</figcaption></figure><p>OOD Detection can be viewed as a binary classification problem, with the two classes being out-distribution and in-distribution. As for the test data, its label is given as 0(stands for OOD) or 1 (stands for ID). For detection, we have two classes, and the detector outputs a score for both the positive and negative classes. We compute the maximum softmax probability as the score of the detector, and the threshold delta is chosen so that the fraction of in-distribution images correctly classified as in-distribution images is 95%. We say that the image <strong>x</strong> is an in-distribution example if the softmax score is above the threshold and that the image <strong>x</strong> is an out-of-distribution example otherwise.</p><p>I want to explain a bit more about the reason why we choose the AURPC and AUPR to measure for evaluation metrics. As we define the OOD as the positive class and ID as the negative class, the detector may always guess the negative class and obtain high accuracy because the number of ID samples is much higher than that of the OOD sample, which means the ID class is far more likely than the OOD class. Faced with this issue, we need to specify a score threshold so that some positive examples are classified correctly. But this depends upon the trade-off between false negatives(FN) and false positives(FP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92uQ5LLP1DFkmjtg5t2tUw.png" /><figcaption>Figure 5: AUROC &amp; AUPR</figcaption></figure><p>AUROC <em>(the Area Under the Receiver Operating Characteristic curve)</em> is an optimal choice. The ROC curve is a graph showing the trade-off between the true positive rate(TPR=TP/(TP+FN)) and the false positive rate(FPR =FP/(FP+TN)). For every threshold, we calculate TPR and FPR and plot them on one chart. AUROC means the area under the ROC curve (see Fig. 5).</p><p>AUPR (the Area Under the Precision-Recall curve) plays a complementary role to AUROC. This is because the AUROC is not ideal when the positive class and negative class are heavily imbalanced, and the AUPR adjusts for this. What’s more, AUPR helps when we care more about positive(OOD) than negative(ID) class. The PR curve plots the precision (TP/(TP+FP)) and recall (FP/(TP+FN)) against each other. AUPR is the area under the PR curve (see Fig. 5).</p><h4>Other methods following the Max-Softmax</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Cf1a6yqSyK-Rw9afi6jIA.png" /><figcaption>Figure 6: softmax score distributions between in- and out-of-distribution</figcaption></figure><p>After the Max-Softmax method, much of the work on OOD detection focused on defining more suitable measures of OOD uncertainty to improve the separation of distributions of ID and OOD uncertainty scores, which allows for more effective detection. The following section will introduce three representative methods — ODIN, Energy, and ReAct. All three methods do not require re-training the neural network and are easily implementable on any modern neural architecture.</p><h4>ODIN: Enhancing the Reliability of out-of-distribution image detection in neural networks [4]</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R1rpdjGbE7fCZYOTcgVs9w.png" /><figcaption>Figure 7: ODIN method</figcaption></figure><p>In this paper, ODIN is proposed, which combines adding small perturbations to the input and using temperature scaling on the softmax score. A sufficiently large temperature has a strong smoothing effect that transforms the softmax score back to the logit space. These techniques help enlarge the softmax score gap between in- and out-of-distribution.</p><h4>Energy: Energy-based Out-of-distribution Detection[5]</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFeaHL1_VNdhitNr5Pdh7Q.png" /><figcaption>Figure 8: Energy-based out-of-distribution framework. From [5]</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DN95OcW5QYCZ5sEPfv9nSA.png" /><figcaption>Figure 9: Energy-based method</figcaption></figure><p>Unlike softmax confidence scores, the energy scores can be aligned with the density of inputs and result in improving OOD detection performance. The key idea is to use a non-probabilistic energy function that attributes lower values to in-distribution data and higher values to out-of-distribution data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ec9-rHkiXcA9JleS8moWEA.png" /><figcaption>Figure 10 : softmax score distribution v.s. energy score distribution From[5]</figcaption></figure><p>Fig.10 compared the softmax and energy score distributions. The energy scores calculated from a pre-trained network on both training and OOD data naturally form smooth distributions, while softmax scores for both in- and out-of-distribution data concentrate on high values. Energy successfully makes the scores more distinguishable between ID and OOD.[5]</p><h4>ReAct: Out-of-distribution Detection With Rectified Activations [6]</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*W4whY08tK7y88Fz-S5qPMA.png" /><figcaption>Figure 11: The distribution of per-unit activations in the penultimate layer for ID and OOD data</figcaption></figure><p>This work reveals one fundamental cause of overconfidence, which is that the OOD data can trigger unit activation patterns that are significantly different from ID data. In Fig 11 we can see that the mean activation for ID data(blue) is well-behaved with a near-constant mean and standard deviation while for OOD data(grey) the mean activation is biased towards having sharp positive values. As a result, such high unit activation can manifest producing overconfident predictions on OOD data in model output. <strong><em>ReAct </em></strong>is provided as a simple activation rectification strategy that utilizes activation truncation. The operation is applied element-wise to the feature <strong><em>x </em></strong>on the penultimate layer of a DNN where<strong> <em>ReAcr(x;c) = min(x, c),</em></strong><em> and </em>the rectification parameter<strong><em> c </em></strong>is chosen to preserve the activation for ID data while rectifying that of OOD data.</p><p><strong>Why do OOD samples trigger abnormal unit activation patterns?</strong></p><p>This paper provides one explanation related to batch normalization (BatchNorm).</p><p>Batch normalization is a mechanism that aims to stabilize the distribution over a mini-batch of inputs to a given network layer during training by setting the mean and variance of the distribution of each activation to be zero and one respectively.[7]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1Ul9b0mqtl9sgzvb5FdIQ.png" /><figcaption>Figure 12: Batch Normalization</figcaption></figure><p>During training time, we calculate the mean and standard deviation of mini-batch data and update these statistics every time.</p><p>During inference time, however, the mean and standard deviation are based on previous estimations in training and are fixed.</p><p>In the OOD detection task, the statistics of ID and OOD are quite different. If the BatchNorm statistics estimated on ID distribution are blindly applied to the OOD distribution, high unit activation can be triggered. The overconfidence phenomenon is might caused by mismatching statistics used during inference.</p><h4>Conclusion</h4><p>The application of OOD detection usually falls into safety-critical situations and is paid more and more attention. Many practical methods have been developed, but few pieces of research focus on examining the internal mechanisms of neural networks for OOD detection. As ReAct has provided an idea of mismatching statistics, I hope this blog could inspire you, and if possible, you might dig deep into this aspect and go further.</p><p><strong>Acknowledgment</strong></p><p>Xiaoxiao is my pet, which is a really naughty boy. I really couldn’t help to share his photo with you!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*MDPVHBYS_-eVa_aS7FtD5Q.png" /><figcaption>Xiaoxiao</figcaption></figure><h4><strong>Reference:</strong></h4><p>[1]Yang, Jingkang, et al. “Generalized out-of-distribution detection: A survey.” arXiv preprint arXiv:2110.11334 (2021).</p><p>[2]Hendrycks, Dan, and Kevin Gimpel. “A baseline for detecting misclassified and out-of-distribution examples in neural networks.” <em>arXiv preprint arXiv:1610.02136</em> (2016).</p><p>[3]Liang, Shiyu, Yixuan Li, and Rayadurgam Srikant. “Enhancing the reliability of out-of-distribution image detection in neural networks.” <em>arXiv preprint arXiv:1706.02690</em> (2017).</p><p>[4]Liang, Shiyu, Yixuan Li, and Rayadurgam Srikant. “Enhancing the reliability of out-of-distribution image detection in neural networks.” <em>arXiv preprint arXiv:1706.02690</em> (2017)</p><p>[5]Liu, Weitang, et al. “Energy-based out-of-distribution detection.” <em>Advances in Neural Information Processing Systems</em> 33 (2020): 21464–21475.</p><p>[6]Sun, Yiyou, Chuan Guo, and Yixuan Li. “React: Out-of-distribution detection with rectified activations.” <em>Advances in Neural Information Processing Systems</em> 34 (2021): 144–157.</p><p>[7]Santurkar, Shibani, et al. “How does batch normalization help optimization?.” <em>Advances in neural information processing systems</em> 31 (2018).</p><p>[8]Ioffe, Sergey, and Christian Szegedy. “Batch normalization: Accelerating deep network training by reducing internal covariate shift.” <em>International conference on machine learning</em>. PMLR, 2015.</p><p>[9]<a href="https://blog.mindee.com/batch-normalization/">The Danger of Batch Normalization in Deep Learning — Mindee</a></p><p>[8]<a href="https://blog.csdn.net/qq_36478718/article/details/122449081">(34条消息) Out-of-distribution Detection系列专栏（三）_DS..的博客-CSDN博客</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b7e512c455" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security and Privacy of Machine Learning Models]]></title>
            <link>https://haojia-kong.medium.com/security-and-privacy-of-machine-learning-models-285699ec25bb?source=rss-69c6aa6d5cde------2</link>
            <guid isPermaLink="false">https://medium.com/p/285699ec25bb</guid>
            <category><![CDATA[privacy-protection]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Scarlett KONG]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 00:25:37 GMT</pubDate>
            <atom:updated>2022-08-31T04:46:10.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Umbja9ht05FFdRCNogdbLA.jpeg" /></figure><p>Nowadays, the use of Machine Learning (ML) has increased substantially in our daily life. A well-trained ML model can achieve outstanding performance on a particular task, however, it might be easily broken when facing threats and adversaries. This is because the machine learning model has been developed with no opponent and threat so it is hard to defend against the attack of a malicious machine learning-based adversary.</p><p>At the core of machine, learning security is the act of maintaining <strong>confidentiality</strong>, <strong>integrity</strong> and <strong>availability. </strong>Confidentiality is the property that privacy data or parameters of ML models are not made available to unauthorized users. Integrity means maintaining and assuring the accuracy of data prediction. And availability is asked ML model to remain available at all times, even when it suffers attacked. Together, these three properties form <strong>the CIA model</strong> of security.</p><p>A machine learning system may be dogged by an adversary during the training process (when a model is trained) or inference process (when a model is making predictions). During the training progress, the adversary might make modifications to existing training data or insert additional data in the training set to destroy the model. Or they just simply perturb the inputs during the inference process, which can force the model to predict wrongly. What’s more, privacy issues exist in both processes. So the following will be three parts: <strong>security of data</strong>,<strong> security of model</strong>, and <strong>privacy</strong>.</p><h4>Security of data</h4><p>Data poisoning attacks involve polluting a machine learning model’s training data. It can render machine learning models inaccurate as tampering with the training data impacts the model’s ability to output correct predictions. For example, in 2018 some attackers tried to throw the Gmail filter off track by reporting massive amounts of spam emails as not spam. This would lead to model skewing in classifying spam emails.</p><p>Data poison can be achieved either in a blackbox scenario against classifiers that depend on the users’ feedback to update parameters or in a whitebox scenario where the attacker gets at the model and its private training data is possibly collected from multiple sources.</p><p>Malicious inputs are usually out-of-distribution compared with nature training data, which means that malicious inputs can be seen as outliers. Developers need to provide measures that could either block attack attempts or detect anomalies.</p><p>If a model were poisoned, it would need to be retrained, which is a really expensive cost. <em>Machine Unlearning </em>research could solve this problem. It aims to develop an algorithm that can take as its input a trained machine learning model and output a new one such that any specific training data has been removed. For further information please check <a href="https://www.cleverhans.io/2020/07/20/unlearning.html">[4]</a>.</p><h4><strong>Security of model</strong></h4><p>In the inference phase, adversarial examples can force the model to make wrong predictions by perturbing the inputs. To get an idea of what adversarial examples look like, consider a demonstration in the CV field from <a href="https://arxiv.org/pdf/1412.6572.pdf">[6]</a>. By adding an imperceptibly small vector whose elements are equal to the sign of the elements of the gradient of the cost function concerning the input, it can change CNN’s classification of the image from panda to gibbon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VKSdvRMd1UvhFSgOlAYjGw.png" /><figcaption>adversarial examples in CV</figcaption></figure><p>Another instance is from <a href="https://arxiv.org/pdf/1908.07125.pdf">[7]</a> in the NLP field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMlznLknXLXu3EhavbuYdA.png" /><figcaption>adversarial examples in NLP</figcaption></figure><p>In this paper[7], researchers created adversarial examples with triggers that commonly trigger a specific target prediction when concatenated to any input from a dataset. For sentiment analysis, concatenating the displayed trigger caused the model to flip its correct positive predictions to negative. For SQuAD, the displayed trigger caused the model to change its prediction from the underlined span to a desired target span inside the trigger. For language modeling, triggers were prefixes that prompt GPT-2 to generate racist outputs, even when conditioned on non-racist user inputs.</p><p>How do we defend against adversarial examples?</p><p>So far, two methods have provided a significant defense. These defenders attempt to make a ML model more robust and mitigate adversarial examples.</p><p><strong>Adversarial training</strong><a href="https://arxiv.org/abs/1511.05432"><strong>[9]</strong></a><strong> </strong>generates scores of adversarial examples to train ML models, with the aim of reducing the changes made by perturbation.</p><p><strong>Defensive distillation</strong><a href="https://ieeexplore.ieee.org/document/7546524/"><strong>[10]</strong></a> smooths the model’s decision surface in adversarial directions exploited by the adversary.</p><p>Adversarial examples show that ML models can be broken in unforeseen ways. When facing attacks, their behaviors are possibly quite different from what they are expected to be. Further research is needed to find better methods to prevent adversarial examples.</p><h4><strong>Privacy</strong></h4><p>Training ML models require a significant amount of data, while some ML applications have to the analysis of sensitive data. A model might inadvertently store some of its training data which may therefore reveal sensitive information after carefully analyzing the model.</p><p>Ideally, we expect ML model learns information about general pattern rather than facts about specific training examples. Differential privacy is one of the common methods. A survey paper<a href="https://arxiv.org/pdf/2005.08679">[11]</a> provides a comprehensive collection of methods in the field of privacy.</p><p>The following will be covering an algorithm <strong><em>PATE, </em></strong>short for<em> Private Aggregation of Teacher Ensembles</em><strong><em>.</em></strong><a href="https://arxiv.org/pdf/1610.05755.pdf">[12]</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BgMtxVgwT0TIZES1r9oKw.png" /><figcaption>differential privacy (from “Privacy-preserving ML with PATE”,<a href="https://www.youtube.com/watch?v=jm1Sfdno_5A">https://www.youtube.com/watch?v=jm1Sfdno_5A</a>)</figcaption></figure><p>The basic idea of differential privacy is to randomize part of the mechanism’s behavior to provide privacy. In this work, the authors train the model as normal but instead added noise to the outcomes. The reason why they add noise to the model is that they want to ensure the model has learned a general trend instead of memorizing the specific example. Randoms improve the generalization of the model, in other words, the probability of learning any particular set of parameters should stay roughly the same if we change a single training example in the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pq-Cv7HjIuSjFCsWetBqMQ.png" /><figcaption>ensemble learning(from “Privacy-preserving ML with PATE”,<a href="https://www.youtube.com/watch?v=jm1Sfdno_5A">https://www.youtube.com/watch?v=jm1Sfdno_5A</a>)</figcaption></figure><p>Inspired by this, the PATE approach is based on an intuition that if several different classifiers trained on several disjoint datasets, and vote on how to classify a new input example, then that decision would not reveal information about any single training instance as they can’t all have memorized that example. In PATE, we call these classifiers <em>teacher models</em>. The ensemble of teachers is trained on separated subsets of sensitive data. The privacy guarantees of this teacher ensemble stem from its aggregation. They add noise while aggregating the predictions made individually by each teacher to form a single common prediction. This provides correctness and privacy to the predictions.</p><p>However, there are several limitations at this point. 1) Each prediction made by the aggregation mechanism increases the total privacy budget, which would lead to a too large budget and make the privacy guarantees meaningless. 2) The ensemble of teacher models can’t be published.</p><p><em>A student model is created </em>to solve these issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKlKQLaOrMVbY790Np7hRw.png" /><figcaption>PATE framework(from “Privacy-preserving ML with PATE”,<a href="https://www.youtube.com/watch?v=jm1Sfdno_5A">https://www.youtube.com/watch?v=jm1Sfdno_5A</a>)</figcaption></figure><p>The student model is trained on public data labeled using the ensemble. It learns to predict an output chosen by noisy voting among all of the teachers and cannot directly access an individual teacher or the underlying data or parameters. An adversary can only access the student model, and in the worst case could recover the labels on which the student trained which are private.</p><p>With these structures, the PATE framework successfully provides the guarantee of training data privacy.</p><h4>Conclusion</h4><p>Breaking things is easy, but defending and protecting is a tough job. The study of the security and privacy of ML is exciting as many important problems remain open. The goal of this blog is to inspire readers to build awareness of security and privacy protection as well as making a contribution to solving some of these problems.</p><h4>Reference</h4><p>[1]<a href="http://www.jos.org.cn/html/2021/1/6131.htm">机器学习模型安全与隐私研究综述 (jos.org.cn)</a></p><p>[2]<a href="https://en.wikipedia.org/wiki/Information_security">https://en.wikipedia.org/wiki/Information_security</a></p><p>[3]<a href="https://www.cleverhans.io/security/privacy/ml/2016/12/16/breaking-things-is-easy.html">https://www.cleverhans.io/security/privacy/ml/2016/12/16/breaking-things-is-easy.html</a></p><p><a href="https://www.cleverhans.io/2020/07/20/unlearning.html">[4]</a>unlearning</p><p>[5]<a href="https://www.csoonline.com/article/3613932/how-data-poisoning-attacks-corrupt-machine-learning-models.html">https://www.csoonline.com/article/3613932/how-data-poisoning-attacks-corrupt-machine-learning-models.html</a></p><p>[6]<a href="https://arxiv.org/pdf/1412.6572.pdf">https://arxiv.org/pdf/1412.6572.pdf</a></p><p>[7]<a href="https://arxiv.org/pdf/1908.07125.pdf">https://arxiv.org/pdf/1908.07125.pdf</a></p><p>[8]<a href="https://openai.com/blog/adversarial-example-research/">https://openai.com/blog/adversarial-example-research/</a></p><p>[9]<a href="https://arxiv.org/abs/1511.05432">https://arxiv.org/abs/1511.05432</a></p><p>[10]<a href="https://ieeexplore.ieee.org/document/7546524/">https://ieeexplore.ieee.org/document/7546524/</a></p><p>[11]<a href="https://arxiv.org/pdf/2005.08679">extension://bfdogplmndidlpjfhoijckpakkdjkkil/pdf/viewer.html?file=https%3A%2F%2Farxiv.org%2Fpdf%2F2005.08679.pdf</a></p><p>[12]<a href="https://arxiv.org/pdf/1610.05755.pdf">https://arxiv.org/pdf/1610.05755.pdf</a></p><p>[13]”Privacy-preserving ML with PATE” <a href="https://www.youtube.com/watch?v=jm1Sfdno_5A">https://www.youtube.com/watch?v=jm1Sfdno_5A</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=285699ec25bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>