<?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 Daniel Hsu on Medium]]></title>
        <description><![CDATA[Stories by Daniel Hsu on Medium]]></description>
        <link>https://medium.com/@nightheronry?source=rss-4c99b558e239------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*cbrbZqbwGJT-CN-baMzNCg.png</url>
            <title>Stories by Daniel Hsu on Medium</title>
            <link>https://medium.com/@nightheronry?source=rss-4c99b558e239------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 10:54:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nightheronry/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[How To Add and Update Git Submodules]]></title>
            <link>https://medium.com/@nightheronry/how-to-add-and-update-git-submodules-dc1ba035e63b?source=rss-4c99b558e239------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc1ba035e63b</guid>
            <dc:creator><![CDATA[Daniel Hsu]]></dc:creator>
            <pubDate>Fri, 25 Mar 2022 07:58:45 GMT</pubDate>
            <atom:updated>2022-03-25T07:58:45.563Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are a developer working on a large project, you are probably already familiar with the concept of <strong>Git submodules</strong>.</p><p><strong>Git </strong><a href="https://git-scm.com/docs/git-submodule"><strong>submodules</strong></a> are most of the time used in order to incorporate another versioned project within an existing project.</p><p>Submodules can be used for example in order to store third-party libraries used by your main project in order to compile successfully.</p><p>In order to keep up with the changes made for those third-party libraries, you choose <strong>to include projects as submodules</strong> in your main project.</p><p>In this tutorial, we are going to explain <strong>how you can easily add, update and remove Git submodules on your main project.</strong></p><p>We are also going to explain concepts about <strong>Git submodules</strong>, what they are and how they should be worked with on a Git repository.</p><h3>Add a Git Submodule</h3><p>The first thing you want to do is to add a Git submodule to your main project.</p><p><strong>In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule.</strong></p><p>Optionally, you can also <strong>specify the target directory</strong> (it will be included in a directory named as the remote repository name if not provided)</p><pre>$ git submodule add &lt;remote_url&gt; &lt;destination_folder&gt;</pre><p>When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.</p><pre>$ git commit -m &quot;Added the submodule to the project.&quot;</pre><pre>$ git push</pre><p>As an example, let’s pretend that you want to add the “project” repository as a submodule on your project into a folder named “vendors”.</p><p>To add “project” as a submodule, you would run the following command at the root of your repository</p><pre>$ git submodule add https://github.com/project/project.git vendors</pre><pre>Cloning into &#39;/home/user/main/project&#39;...<br>remote: Enumerating objects: 5257, done.<br>remote: Total 5257 (delta 0), reused 0 (delta 0), pack-reused 5257<br>Receiving objects: 100% (5257/5257), 3.03 MiB | 3.38 MiB/s, done.<br>Resolving deltas: 100% (3319/3319), done.</pre><p>When adding a new Git submodule into your project, multiple actions will be performed for you :</p><ul><li>A folder is created in your Git repository named after the submodule that you chose to add (in this case “vendors”);</li><li><a href="https://devconnected.com/how-to-show-hidden-files-on-linux/">A hidden file</a> named “<strong>.gitmodules</strong>” is created in your Git repository : this file contains the references to the remote repositories that you cloned as submodules;</li><li>Your Git configuration (located at .git/config) was also modified in order to include the submodule you just added;</li><li>The submodule you just added are marked as changes to be committed in your repository.</li></ul><h3>Pull a Git Submodule</h3><p>In this section, we are going to see how you can pull a Git submodule as another developer on the project.</p><p>Whenever <a href="https://devconnected.com/how-to-clone-a-git-repository/">you are cloning a Git repository</a> having submodules, you need to execute an extra command in order for the submodules to be pulled.</p><p>If you don’t execute this command, you will fetch the submodule folder, but you won’t have any content in it.</p><p><strong>To pull a Git submodule, use the “git submodule update” command with the “–init” and the “–recursive” options.</strong></p><pre>$ git submodule update --init --recursive</pre><p>Going back to the example we described before : let’s pretend that we are in a complete new Git repository created by our colleague.</p><p>In its Git repository, our colleague first starts by cloning the repository, however, it is not cloning the content of the Git submodule.</p><p>To update its own Git configuration, it has to execute the “git submodule update” command.</p><pre>$ git submodule update --init --recursive</pre><pre>Submodule &#39;vendors&#39; (https://github.com/project/project.git) registered for path &#39;vendors&#39;<br>Cloning into &#39;/home/colleague/submodules/vendors&#39;...<br>Submodule path &#39;vendors&#39;: checked out &#39;43d08138766b3592352c9d4cbeea9c9948537359&#39;</pre><p>As you can see, pulling a Git submodule in our colleague Git repository detached the HEAD at a given commit.</p><p>The submodule is always set to have its HEAD detached at a given commit by default : as the main repository is not tracking the changes of the submodule, it is only seen as a specific commit from the submodule repository.</p><h3>Update a Git Submodule</h3><p>In some cases, you are not pulling a Git submodule but you are simply look to update your existing Git submodule in the project.</p><p><strong>In order to update an existing Git submodule, you need to execute the “git submodule update” with the “–remote” and the “–merge” option.</strong></p><pre>$ git submodule update --remote --merge</pre><p>Using the “–remote” command, you will be able to update your existing Git submodules without having to run “git pull” commands in each submodule of your project.</p><p>When using this command, your detached HEAD will be updated to the newest commit in the submodule repository.</p><p>Given the example that we used before, when updating the submodule, we would get the following output</p><pre>$ git submodule update --remote --merge</pre><pre>Updating 43d0813..93360a2<br>Fast-forward<br> README.md | 6 +++++-<br> 1 file changed, 5 insertions(+), 1 deletion(-)<br>Submodule path &#39;vendors&#39;: merged in &#39;93360a21dc79011ff632b68741ac0b9811b60526&#39;</pre><h3>Fetch new submodule commits</h3><p>In this section, you are looking to update your Git repository with your commits coming from the submodule repository.</p><p>First, you may want to fetch new commits that were done in the submodule repository.</p><p>Let’s say for example that you want to fetch two new commits that were added to the submodule repository.</p><p><strong>To fetch new commits done in the submodule repository, head into your submodule folder and run the “git fetch” command first (you will get the new submodule commits)</strong></p><pre>$ cd repository/submodule </pre><pre>$ git fetch</pre><p>Now, if you run the “git log” command again, you will be able to see the new commits you are looking to integrate.</p><pre>$ git log --oneline origin/master -3</pre><pre>93360a2 (origin/master, origin/HEAD) Second commit<br>88db523 First commit<br>43d0813 (HEAD -&gt; master) Initial commit</pre><p>Now, in order for your submodule to be in-line with the newest commits, you can run the “git checkout” command and specify the SHA that you want to update your submodule to (in this case 93360a2)</p><pre>$ git checkout -q 93360a2</pre><p>Great! Your HEAD is now aligned with the newest commits from the submodule repository.</p><p>You can now go back to your main repository and commit your changes for other developers to fetch those new commits.</p><pre>$ cd repository</pre><pre>$ git add .</pre><pre>$ git commit -m &quot;Added new commits from the submodule repository&quot;</pre><pre>$ git push</pre><h3>Remove Git submodules</h3><p>In this section, we are going to see how you can effectively remove a Git submodule from your repository.</p><p><strong>In order to remove a Git submodule from your repository, use the “git submodule deinit” command followed by the “git rm” command and specify the name of the submodule folder.</strong></p><pre>$ git submodule deinit &lt;submodule&gt;</pre><pre>$ git rm &lt;submodule&gt;</pre><p>When executing the “git submodule deinit” command, you will delete the local submodule configuration stored in your repository.</p><p>As a consequence, the line referencing the submodule will be <strong>deleted </strong>from your .git/config file.</p><p>The “git rm” command is used in order to delete submodules files from the working directory and remaining .git folders.</p><h3>Configuring submodules for your repository</h3><p>In some cases, you may want to have additional logging lines whenever you are executing “git status” commands.</p><p>Luckily for you, there are configuration properties that you can tweak in order to have more information about your submodules.</p><h3>Submodule summary</h3><p><strong>In order to have a submodule summary when executing “git status”, execute the “git config” command and add the “status.submoduleSummary” option.</strong></p><pre>$ git config --global status.submoduleSummary true</pre><p>As a consequence, you will be presented with more information when executing “git status” commands.</p><pre>$ git status<br>On branch master<br>Your branch is up-to-date with &#39;origin/master&#39;.<br>Changes to be committed:<br>  (use &quot;git reset HEAD &lt;file&gt;...&quot; to unstage)</pre><pre>  new file:   .gitmodules<br>  new file:   &lt;submodule&gt;</pre><pre>Submodule changes to be committed:</pre><pre>* &lt;submodule&gt; 0000000...ae14a2 (1):<br>  &gt; Change submodule name</pre><h3>Detailed diff for submodules</h3><p>If you configured your Git to have the submodule summary as explained in the previous section, you should now have a customized way to see differences between submodules.</p><p>However, in some cases, you want to get more information about the commits that might have been done in your submodules folder.</p><p><strong>For the “git diff” command to have detailed information about your submodules, use the “git config” command with the “diff.submodule” parameter set to true.</strong></p><pre>$ git config --global diff.submodule log</pre><p>Now, whenever you are executing the <a href="https://devconnected.com/how-to-compare-two-git-branches/">“git diff” command</a>, you will be able to see the commits that were done in the submodules folder.</p><pre>$ git diff</pre><pre>Submodule &lt;submodule&gt; 0000000...ae14a2:<br>  &gt; Submodule commit n°1<br>  &gt; Submodule commit n°2</pre><h3>Conclusion</h3><p>In this tutorial, you learnt what submodules are and how you can use them in order to have external repositories in your main project repository.</p><p>You also learnt that it is possible <strong>to add and update Git submodules</strong> using the dedicated “git submodule” commands : “<strong>git submodule add</strong>” and “<strong>git submodule update</strong>“.</p><p>Finally, you have seen that it is possible to tweak your Git configuration in order to get more information about your Git repository.</p><p>If you are interested about Git or about software engineering in general, we have a complete section dedicated to it on the website, so make sure to check it out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc1ba035e63b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paper Summary: Towards Adversarially Robust Object Detection]]></title>
            <link>https://medium.com/@nightheronry/paper-summary-towards-adversarially-robust-object-detection-f3ef9a9006c8?source=rss-4c99b558e239------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3ef9a9006c8</guid>
            <dc:creator><![CDATA[Daniel Hsu]]></dc:creator>
            <pubDate>Wed, 21 Aug 2019 07:49:45 GMT</pubDate>
            <atom:updated>2020-03-30T07:40:30.962Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Paper Summary] Towards Adversarially Robust Object Detection</h3><p><a href="https://arxiv.org/abs/1907.10310">Towards Adversarially Robust Object Detection</a></p><p>Authors: Haichao Zhang, Jianyu Wang</p><p>This paper focuses on improving robustness of object detection model. The contributes are analyzing the pros and cons<em> </em>of the mainstream attack approaches and presenting an approach for improving the robustness object detectors against adversarial attacks.</p><h4>Attacks and Adversarial Training for Classification</h4><p>Early on, most of white-box attacks were <a href="https://medium.com/@nightheronry/paper-summary-explaining-and-harnessing-adversarial-examples-9e7ea490ac24">Fast gradient sign method (FGSM)</a> based examples, and they could be defensed by <a href="https://medium.com/@nightheronry/paper-summary-towards-deep-learning-models-resistant-to-adversarial-attacks-cb95cee6f495">Projective Gradient Descend (PGD)</a> based adversarial training. In the classification attack, loss of class label is essential factor</p><h4><strong>Detection Attacks</strong></h4><p>For object detection, author considers adversarial attack is the multi-task learning of classification and localization. And exploring the robustness of object detection model using analyzing the mutual impacts of two task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*gkzQZTDn3T2cfKf-PshM4w.png" /><figcaption>One-stage Detector</figcaption></figure><blockquote>an attack to a detector can be achieved by utilizing variants of individual task losses or their combinations.</blockquote><ul><li>Mutual Impacts of Task Losses</li></ul><p>First, suffering attack based on each task reduces not only the task performance but the other task performance as well. As figure (a) below, the red component in the left shows after executing classification based attack, classification accuracy and average IoU accuracy of localization are sharply declined together, and the blue component also appears the same phenomenon. Author thinks this is one of season that cross-task attack can transfer successfully.</p><ul><li>Misaligned Task Gradients</li></ul><p>In figure (b) below, the scales of two tasks loss gradients spread with different value ranges, maybe it present existence of imbalance between the two task losses. Otherwise, the points in Quadrant I and Quadrant IV imply the conflicts between two gradients of task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*e0LBkIrSI6fsNSnD8EJgtQ.png" /></figure><p>After embedding losscls(red) and lossloc(blue) with t-SEN, we can find two task domains have both overlaps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*ym3c2YkUQRXVLLdJYfv_SA.png" /></figure><p><strong>Adversarial Training for Robust Detection</strong></p><p>About the adversarial training, author defines two task loss spaces</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*REh4M7Zy-iQ-G-jVn_LT8g.png" /></figure><p>and uses they to constrain adversarial training to a “<a href="https://medium.com/@nightheronry/paper-summary-towards-deep-learning-models-resistant-to-adversarial-attacks-cb95cee6f495">maxmin problem</a>”. The loss is restricted from Sx to Scls∪Sloc, and the adversarial examples which are search on the space of object detection model have overall maximum loss. This kind of task-domain constraints is helpful to generate adversarial examples which can avoid multial impact between tasks . The formula is showed as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*TjL6xgNbDT3qCzYQBJ3asA.png" /></figure><p>However, to train the model more efficiently, author adopts <a href="https://medium.com/@nightheronry/paper-summary-explaining-and-harnessing-adversarial-examples-9e7ea490ac24?source=friends_link&amp;sk=b2169d49ca27cd271f11f05114d0fc0d">FGSM</a> in inner-max generation rather than PGD.</p><h3>Experiments</h3><p>In the experiments part, author evaluate the performance of models under attacks with different number of PGD steps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*dVWRtot_EN3n_OgYjkaJEg.png" /><figcaption>(a)loss cls and (b)loss loc-based PGD attack with budget= 8.</figcaption></figure><ul><li>STD: standard training with clean image as the domain</li><li>CLS: using Scls only as the task domain for training</li><li>LOC: using Sloc only as the task domain for training.</li></ul><p><strong>Attacks under different number of steps</strong></p><p>As shown in upper figure, the performance of the standard model (STD) drops below all other robust models as the number of PGD steps increases, for both losscls-base and lossloc-based attacks. In the compare power of each attack mathod , Scls-based(a) is better than Sloc-based(b).</p><p><strong>Beyond Single-Task Domain</strong></p><p>In different task sets,</p><ul><li>CON: using the conventional task agnostic domain Sx,which is essentially the direct application of the adversarial training for classification to detection</li><li>MTD: using the task oriented domain Scls ∪ Sloc</li></ul><p>Accuracy for clean images: STD &gt; LOC &gt; MTD &gt; CLS &gt; CON</p><p>Power of attacks: Scls ≥ DAG &gt;Sloc &gt; RAP</p><p>For the most part, under the convenient single-task based attacks, the different of are nonsignificant. But, multi-task based attacks, MTD is outstanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*UeA_PcrOFPyoUT-K80QyCw.png" /></figure><p><strong>Failure Case Analysis</strong></p><p>Images with small objects that are challenging for the standard detectors, and the detectors trained by adversarial examples as well.</p><p>Visually similar images lead to lower confidence. So the detectors misclassify easily.</p><p>And the completely wrong cases reveals that the robust detector training leave much to be desired</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l6VPouPEPIez6zL-UolmSg.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdocs.google.com%2Fpresentation%2Fembed%3Fid%3D1Uw6BtdtdM7lbAdLfe--2Qd2o2YFOpXH8huBlxPq_5Wg%26size%3Dl&amp;url=https%3A%2F%2Fdocs.google.com%2Fpresentation%2Fd%2F1Uw6BtdtdM7lbAdLfe--2Qd2o2YFOpXH8huBlxPq_5Wg%2Fedit%3Fusp%3Dsharing&amp;image=https%3A%2F%2Flh4.googleusercontent.com%2F9hTf6Dw9uL3OMDGsU0EhraZV76CiF_Pvmufraj8QDM7kU1cVsGF_cp2aXsA0vIWtOs8u5A%3Dw1200-h630-p&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="700" height="559" frameborder="0" scrolling="no"><a href="https://medium.com/media/da7cdae6c484f5ca0e189abb5ad213f7/href">https://medium.com/media/da7cdae6c484f5ca0e189abb5ad213f7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3ef9a9006c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paper Summary: Explaining and Harnessing Adversarial Examples]]></title>
            <link>https://medium.com/@nightheronry/paper-summary-explaining-and-harnessing-adversarial-examples-9e7ea490ac24?source=rss-4c99b558e239------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e7ea490ac24</guid>
            <dc:creator><![CDATA[Daniel Hsu]]></dc:creator>
            <pubDate>Mon, 19 Aug 2019 11:08:52 GMT</pubDate>
            <atom:updated>2019-09-08T09:30:51.290Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Paper Summary] Explaining and Harnessing Adversarial Examples</h3><p>Author: <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Goodfellow%2C+I+J">Ian J. Goodfellow</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Shlens%2C+J">Jonathon Shlens</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Szegedy%2C+C">Christian Szegedy</a></p><p><a href="https://arxiv.org/abs/1412.6572">Explaining and Harnessing Adversarial Examples</a></p><p><a href="https://arxiv.org/abs/1412.6572">Fast gradient sign method (FGSM)</a></p><p>*以下圖所有未註明來源之圖像皆來自該篇論文</p><p>基本構想是找出一個擾動<em>η</em>加上原始照片<em>x</em>，這樣就能經由 <em>x</em>+<em>η</em>來生成對抗樣本<em>x</em>˜<em>, y</em>是<em>x</em>的類別，分類器的權重用<em>θ</em>表示,如此一來就可以使用loss function J(θ, x, y)來訓練，根據所輸入影像loss function的梯度可以被計算為∇<em>x J</em>(<em>θ</em>,<em>x</em>,<em>y</em>)</p><p>此外，因為分類器的forward-propagation為矩陣內積</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/0*9gKXodkgNpiZpdmJ" /></figure><p>為了最大擾動效果,這邊加上一個Sign function讓梯度方向一致下最大化，且為了要讓所產生的擾動不要偏離太多(肉眼難以察覺)，這邊乘上一個極小值<em>ϵ ,</em>整個過程如下圖</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*7HeCjbnMi2i0mAh_ZzDxEw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e7ea490ac24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paper Summary: Towards Deep Learning Models Resistant to Adversarial Attacks]]></title>
            <link>https://medium.com/@nightheronry/paper-summary-towards-deep-learning-models-resistant-to-adversarial-attacks-cb95cee6f495?source=rss-4c99b558e239------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb95cee6f495</guid>
            <dc:creator><![CDATA[Daniel Hsu]]></dc:creator>
            <pubDate>Mon, 19 Aug 2019 11:04:21 GMT</pubDate>
            <atom:updated>2019-09-08T09:31:15.325Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Paper Summary] Towards Deep Learning Models Resistant to Adversarial Attacks</h3><p><a href="https://arxiv.org/abs/1706.06083">Towards Deep Learning Models Resistant to Adversarial Attacks</a></p><p>Authors: <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Madry%2C+A">Aleksander Madry</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Makelov%2C+A">Aleksandar Makelov</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Schmidt%2C+L">Ludwig Schmidt</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Tsipras%2C+D">Dimitris Tsipras</a>, <a href="https://arxiv.org/search/stat?searchtype=author&amp;query=Vladu%2C+A">Adrian Vladu</a></p><p>Projective Gradient Descend (PGD) in Adversarial Attacks</p><p>*以下圖所有未註明來源之圖像皆來自該篇論文</p><p>作者將有效的攻擊跟防禦視為一組尋找極大極小值的問題，分別為 inner-max 和 outer-min ，而 PGD 就是用來找 inner-max 的方式。</p><ul><li>inner-max: 基於原始影像尋找存在有最大損失的對抗樣本</li><li>outer-min: 尋找最小 loss 的網路參數，其實就是一般的網路訓練, 這邊使用 SGD</li></ul><p>完整流程如以下公式</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/0*E-KhomRuWAs1VeTx.png" /><figcaption>其中 max L() 就是 inner-max 目的為在數據的分佈 D 上最大化對抗樣本的loss, 並嘗試最小化整體的輸出風險 𝙥(ɵ) 也就是 outer-min, E 為 Empirical risk</figcaption></figure><p>而 inner-max 的尋找方法類似迭代型的 FGSM (簡單介紹可以參考<a href="https://medium.com/@nightheronry/paper-summary-explaining-and-harnessing-adversarial-examples-9e7ea490ac24">這裡</a>)，不過這裡不使用 SGD，因為作者指出這種大規模的限制最佳化問題使用 PGD 會比較好，相關證明可參考<a href="http://niaohe.ise.illinois.edu/IE598_2016/pdf/IE598-lecture10-projected%20gradient%20descent.pdf">link</a>，<a href="http://freemind.pluskid.org/machine-learning/projected-gradient-method-and-lasso/">link</a>，公式如下</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/0*48EYzFuUW41Ck2Ww.jpg" /><figcaption>sgn() 用於限制梯度的值為+1 or -1，如此一來經由與α相乘後會限制，梯度在α距離內</figcaption></figure><h4>Inner-max分析</h4><p>Inner-max是對於壹個模型及壹個樣本，尋找壹個對抗樣本，使得該模型最大化對於對抗樣本的cross-entropy。作者使用 PGD 分别在 MNIST 和 CIFAR10 上進行實驗，且為了為了搜索大部分的 loss 範圍，這邊重複使用 PGD 在距離同一原始樣本 𝓁∞但位置不同的點來找尋對抗樣本，下途中的12條曲線就是距離同一原始樣本 𝓁∞所產生的 12 個對抗樣本。實驗結果發現，對抗樣本訓練的 loss 值遠小於自然樣本訓練，且不管是自然樣本訓練還是對抗樣本訓練 loss 值都會趨向收斂。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*SZmc0UB9gzz12-nFFv9yaA.png" /></figure><blockquote>𝓁∞ 為 ∞-norm，下圖為p-norm 為特定值時在2維平面上的投影</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rydET2-KBY1Wbjx4.png" /><figcaption><a href="https://de.wikipedia.org/wiki/P-Norm#/media/Datei:Vector-p-Norms_qtl1.svg">https://de.wikipedia.org/wiki/P-Norm#/media/Datei:Vector-p-Norms_qtl1.svg</a></figcaption></figure><p>此外，藉由挑選 5 個自然樣本來各做 10⁵ 次的迭代後，發現對抗訓練(下圖紅色)所產生的 loss 值，其局部最大值 cross-entropy比自然樣本訓練(下圖藍色)還要小且集中並無異常值，因此推論出 PGD 所找出的為真實局部最大值。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*_y2Twj4X7P6V8QdIaEkXMw.png" /></figure><p>而作者將這種基於損失函數相對於樣本梯度生成對抗樣本的過程稱為 First-order Adversarial，並推測出只要是基於一階對抗的攻擊應該都是能被此方法找出對抗樣本，進而防禦。不過並不是不可能有其他更大的loss值，不過這就非基於一階對抗的方法所能找出的。例如屬於 0-order 攻擊的 transfer attacks 或者 <a href="https://www.research.ibm.com/artificial-intelligence/publications/paper/?id=AutoZOOM-Autoencoder-based-Zeroth-Order-Optimization-Method-for-Attacking-Blackbox-Neural-Networks">ZOO attack</a>。</p><h4>Outer-min分析</h4><p>這邊就比較直觀，由下圖可見，將對抗樣本經由 SDG 訓練後，loss 值有效的下降。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*VMIeTr9RnFD_HDw2uOhRMg.png" /></figure><h3><strong>Network Capacity and Adversarial Robustness</strong></h3><p>不同的分類器的強健性也是有差異的。作者藉由調整同一模型的 convolution kernel 的個數跟 layer 的大小來展示不同雜度的模型在 MIST 上的結果，可以發現不管是否是對抗訓練，越複雜的模型效果越好，而採用不同大小的ResNet 在 CIFAR10 也有一樣的發現。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*e6aB4L_hTXtT2xAiKw6-6w.png" /></figure><p>不過，可以發現太過簡單的模型反而精度變差，因為簡單的模型無法學到有用的資訊而造成 label leakage 的問題(下圖中)，此外若單純使用 FGSM 的話容易因 overfit 對抗樣本而造成對於原始樣本的精確度下降。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*12DfZ8XJZJLo10aO" /><figcaption>紅星為對抗樣本, 中間的簡單模型無法學到對抗樣本的資訊, 而最右圖較複雜的模型則能學到新資訊且能不被對抗樣本所影響</figcaption></figure><p>最後，作者也實驗在 PGD 中使用不同的距離來尋找對抗樣本對於正確率的影響，紅色虛線為訓練所使用的擾動，MIST 為0.3而 CIFAE10 則是8，可以發現攻擊成功的情況下，使用 𝓁∞ 所需要的擾動小於 𝓁2所需要的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*gnrNPiqpNjjDVcLbnvmgsA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb95cee6f495" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>