<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>IGNORANT</title>
        <link>https://idzc.top/</link>
        <description>Research a little bit, 
and write a little bit.</description>
        <lastBuildDate>Fri, 07 Aug 2026 09:00:46 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, zfhxi</copyright>
        <item>
            <title><![CDATA[Mac上使用VSCode进行LaTeX写作]]></title>
            <link>https://idzc.top/article/202312080000</link>
            <guid>https://idzc.top/article/202312080000</guid>
            <pubDate>Fri, 08 Dec 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[VS Code中使用Latex的一些配置记录]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-70d3d50f1c4a827b9bc701782ff49625"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-8673d50f1c4a83f993e981393c8afe92">可主要参考：</div><div class="notion-text notion-block-fc83d50f1c4a8321851f010ad7a97c4c"><a class="notion-link" href="https://zhuanlan.zhihu.com/p/670790519" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/670790519</a></div><div class="notion-text notion-block-5ce3d50f1c4a82ab965f01168963139e">进行配置，只不过Mac上需要下载MacTex，Windows可以按指示下载TexLive或者CTAN。</div><div class="notion-text notion-block-6653d50f1c4a83caa77b01e325240d8f">Mac上使用skim作为论文pdf的阅读器，并进行跳转，可参考以下两篇文章：</div><div class="notion-text notion-block-14f3d50f1c4a829c80b701665bfa76e5"><a class="notion-link" href="https://www.jianshu.com/p/6f2e385c6653" target="_blank" rel="noopener noreferrer">https://www.jianshu.com/p/6f2e385c6653</a></div><div class="notion-text notion-block-fab3d50f1c4a82a5b46b8155d7c84bfb"><a class="notion-link" href="https://zhuanlan.zhihu.com/p/570559163" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/570559163</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-4713d50f1c4a8307abb20150d6324e05" data-id="4713d50f1c4a8307abb20150d6324e05"><span><div id="4713d50f1c4a8307abb20150d6324e05" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4713d50f1c4a8307abb20150d6324e05" title="抄作业"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>抄作业</b></span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-0693d50f1c4a83feb17c81cc179a9303" style="list-style-type:decimal"><li>去清华源下载<a class="notion-link" href="https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/mac/mactex/mactex-20230314.pkg" target="_blank" rel="noopener noreferrer">MacTex</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3793d50f1c4a839d85f381521a7ffd7f" style="list-style-type:decimal"><li>VSCode中安装Latex Workshop、grammarly插件</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1873d50f1c4a822fad050163a44da3a5" style="list-style-type:decimal"><li>将下列对应配置添加到VSCode的settings.json和keybindings.json中，</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-ef43d50f1c4a830690cf010f2ca9d093" style="list-style-type:decimal"><li>常用快捷操作：</li><ol class="notion-list notion-list-numbered notion-block-ef43d50f1c4a830690cf010f2ca9d093" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-5983d50f1c4a82229430812627ea4e20"><li>编辑器里：Alt+b进行编译（或保存自动编译）</li></ul><ul class="notion-list notion-list-disc notion-block-bff3d50f1c4a83d8af66015b2e458c72"><li>编辑器里：Alt+j跳转到当前latex代码所对应的PDF位置</li></ul><ul class="notion-list notion-list-disc notion-block-3883d50f1c4a822087ef81e933504474"><li>PDF预览页面里：鼠标双击PDF某位置，跳转到该位置对应的latex源码。</li></ul></ol></ol><div class="notion-blank notion-block-a1c3d50f1c4a834398b7812ad0d90429"> </div><div class="notion-text notion-block-47f3d50f1c4a831285db813da316cd83"><code class="notion-inline-code">settings.json</code></div><div class="notion-text notion-block-77b3d50f1c4a8216af9b81addd58d803"><code class="notion-inline-code">keybindings.json</code></div><div class="notion-text notion-block-d2e3d50f1c4a828c8d40818b667dfa8a">参考：</div><ol start="1" class="notion-list notion-list-numbered notion-block-fc43d50f1c4a83f88a0681329b6e1368" style="list-style-type:decimal"><li><a class="notion-link" href="https://zhuanlan.zhihu.com/p/670790519" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/670790519</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-5373d50f1c4a82c0881981e58997251d" style="list-style-type:decimal"><li><a class="notion-link" href="https://www.jianshu.com/p/6f2e385c6653" target="_blank" rel="noopener noreferrer">https://www.jianshu.com/p/6f2e385c6653</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-8933d50f1c4a83629b02016fb0c95530" style="list-style-type:decimal"><li><a class="notion-link" href="https://zhuanlan.zhihu.com/p/570559163" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/570559163</a></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-a423d50f1c4a8306a9b0018c6a1aa7c3" style="list-style-type:decimal"><li><a class="notion-link" href="https://code.visualstudio.com/docs/getstarted/keybindings#_running-multiple-commands" target="_blank" rel="noopener noreferrer">https://code.visualstudio.com/docs/getstarted/keybindings#_running-multiple-commands</a></li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[docker-compose搭建FreshRSS服务]]></title>
            <link>https://idzc.top/article/202311081400</link>
            <guid>https://idzc.top/article/202311081400</guid>
            <pubDate>Wed, 08 Nov 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[使用docker compose方式部署FreshRSS，并展示和RSSHub、NetNewsWire一起使用的方法]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1aa3d50f1c4a82688ba281baf61e3463"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-6a93d50f1c4a837da782814eb99f34b1">FreshRSS是一个自托管的RSS和Atom feed聚合器。它轻便易用，功能强大，可定制。它是一个多用户应用程序，具有匿名阅读模式。它支持自定义标签。它有一个用于（移动）客户端的API，以及一个命令行界面。</div><details class="notion-toggle notion-block-b313d50f1c4a8247a6d0010815ae5d68"><summary>展开更多</summary><div><div class="notion-text notion-block-0383d50f1c4a83e59d8d81843efe5080">FreshRSS可以跟踪网站、播客和视频频道。你可以直接在FreshRSS中阅读你的文章。它还支持搜索和保存查询以便快速访问。FreshRSS还可以通过抓取外部网站生成feed1，并根据你的过滤器生成新的feed。你可以使用OPML导入和导出你的feed。FreshRSS支持WebSub，让你实时连接到你的feed。它可以根据你的需要进行配置。你可以使用或不使用第三方应用来关注你的feed。FreshRSS可以管理超过1M+的文章和50k+的feed。你可以使用主题和扩展来定制FreshRSS。FreshRSS已经被翻译成15种以上的语言。FreshRSS是一个免费的软件（AGPL 3）并且对社区友好。</div></div></details><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6a23d50f1c4a8333bddb01ab42c4cf8d" data-id="6a23d50f1c4a8333bddb01ab42c4cf8d"><span><div id="6a23d50f1c4a8333bddb01ab42c4cf8d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6a23d50f1c4a8333bddb01ab42c4cf8d" title="docker部署freshrss"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>docker部署</b>freshrss</span></span></h3><div class="notion-text notion-block-0123d50f1c4a836595dd81fa21872b66"><code class="notion-inline-code">vim docker-compose.yml</code>新建docker-compose.yml文件（参考官方提供的<a class="notion-link" href="https://github.com/FreshRSS/FreshRSS/blob/edge/Docker/freshrss/docker-compose.yml" target="_blank" rel="noopener noreferrer">compose</a>）：</div><div class="notion-text notion-block-4ec3d50f1c4a8372894c012282db2bf8">记得更改volumes字段的路径， 如果你不需要代理，请删除http_proxy、https_proxy、no_proxy三个变量。下面下载镜像并启动容器：</div><div class="notion-text notion-block-a4b3d50f1c4a82da8af401df38efc87b">去宝塔添加静态网站绑定自己的域名<code class="notion-inline-code">xxx.yourdomain.com</code>，然后反向代理到<code class="notion-inline-code">http://127.0.0.1:8082</code>。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-f7f3d50f1c4a836589a301110fde7dae" data-id="f7f3d50f1c4a836589a301110fde7dae"><span><div id="f7f3d50f1c4a836589a301110fde7dae" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f7f3d50f1c4a836589a301110fde7dae" title="配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>配置</b></span></span></h3><div class="notion-text notion-block-3e83d50f1c4a83cc8cad018dc064d028">打开域名<code class="notion-inline-code">xxx.yourdomain.com</code>进行配置，数据库选择SQLite，安装。</div><div class="notion-blank notion-block-4bd3d50f1c4a830ea49401c6c2004f6d"> </div><div class="notion-text notion-block-f533d50f1c4a8214a93981505b64a311">下面为第三方app配置api密钥：</div><ol start="1" class="notion-list notion-list-numbered notion-block-c153d50f1c4a825f98b801bfa56de5e3" style="list-style-type:decimal"><li>右上角⚙️ → 管理→认证，勾选以下选项：</li><ol class="notion-list notion-list-numbered notion-block-c153d50f1c4a825f98b801bfa56de5e3" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-c633d50f1c4a824fa8100169b7ac361c"><li>✅ 允许不安全的自动登陆方式: xxxx</li></ul><ul class="notion-list notion-list-disc notion-block-bc13d50f1c4a831a969581b0c525f601"><li>✅ 允许 API 访问 （用于手机应用）</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-74b3d50f1c4a8366bc5281531ecf8bb4" style="list-style-type:decimal"><li>右上角⚙️ → 账户，设定api密码，并复制API management下的地址并拼接上<code class="notion-inline-code">greader.php</code>就是api地址了。</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-45c3d50f1c4a8327bec20120699ce403" data-id="45c3d50f1c4a8327bec20120699ce403"><span><div id="45c3d50f1c4a8327bec20120699ce403" class="notion-header-anchor"></div><a class="notion-hash-link" href="#45c3d50f1c4a8327bec20120699ce403" title="使用NetNewsWire绑定FreshRSS"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>使用NetNewsWire绑定FreshRSS</b></span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-9e63d50f1c4a82b1983501edae2bc91c" style="list-style-type:decimal"><li>打开NetNewsWire -&gt; Settings -&gt; Accounts -&gt; 点击左下角的➕ -&gt; 选择Self-Hosted的FreshRSS：</li><ol class="notion-list notion-list-numbered notion-block-9e63d50f1c4a82b1983501edae2bc91c" style="list-style-type:lower-alpha"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7583d50f1c4a83908b36813fce8cb85b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/11/07/17_02_34-1699376554373.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=7583d50f-1c4a-8390-8b36-813fce8cb85b" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-37c3d50f1c4a83759dea01cff7455d25" style="list-style-type:decimal"><li>填写如下信息：</li><ol class="notion-list notion-list-numbered notion-block-37c3d50f1c4a83759dea01cff7455d25" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-aa53d50f1c4a820a886b816768dfb784"><li>username：你设置的FreshRSS用户名</li></ul><ul class="notion-list notion-list-disc notion-block-59b3d50f1c4a8235b20f01bb388bed55"><li>password：api密码</li></ul><ul class="notion-list notion-list-disc notion-block-d6b3d50f1c4a834ea08d01930ac7f9c5"><li>API URL：上述拼接好的api地址</li></ul></ol></ol><div class="notion-text notion-block-36c3d50f1c4a8390bf708131dc1e4d46">这样就可以通过NetNewsWire来浏览FreshRSS的订阅了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-cb03d50f1c4a82a3b0e401d3b3239fb0" data-id="cb03d50f1c4a82a3b0e401d3b3239fb0"><span><div id="cb03d50f1c4a82a3b0e401d3b3239fb0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cb03d50f1c4a82a3b0e401d3b3239fb0" title="结合RSSHub食用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>结合RSSHub食用</b></span></span></h3><div class="notion-text notion-block-4423d50f1c4a83b3817c01c914efa1a7">RSSHub可以为一些不存在订阅链接的网页添加订阅链接，并且可以</div><div class="notion-text notion-block-4f73d50f1c4a836cb057011c1ae40aea">一键导入到FreshRSS。</div><ol start="1" class="notion-list notion-list-numbered notion-block-3d23d50f1c4a8215aceb017ea568f03d" style="list-style-type:decimal"><li>先按照<a class="notion-link" href="https://docs.rsshub.app/install/#docker-compose-deployment" target="_blank" rel="noopener noreferrer">官方教程</a>部署RSSHub，并获取部署的地址（绑定域名）。</li><ol class="notion-list notion-list-numbered notion-block-3d23d50f1c4a8215aceb017ea568f03d" style="list-style-type:lower-alpha"><blockquote class="notion-quote notion-block-9953d50f1c4a82458ade81a93ea4513d"><div>注：这里建议使用diygod/rsshub:chromium-bundled镜像，并按照说明注释掉 marked所在的行（实测这样捕获订阅链接成功率更高）</div></blockquote></ol></ol><div class="notion-text notion-block-f593d50f1c4a82f19f248122e46209dd">将上述中的10.0.5.1改为docker网关（通常为172.17.0.1，通过ifconfig docker0查询），然后拉取镜像并运行容器：</div><div class="notion-text notion-block-6733d50f1c4a83deb45d0144b32f9908">同样地，通过反向代理绑定域名到<code class="notion-inline-code">http://127.0.0.1:1200</code>。</div><ol start="1" class="notion-list notion-list-numbered notion-block-3b63d50f1c4a83f9bab681d09954074b" style="list-style-type:decimal"><li>安装<a class="notion-link" href="https://github.com/DIYgod/RSSHub-Radar" target="_blank" rel="noopener noreferrer">RSSHub-Radar浏览器插件</a>，将上述地址填入插件设置页面的<code class="notion-inline-code">自定义 RSSHub 域名</code>。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-59e3d50f1c4a836e9a2581195b7ea373" style="list-style-type:decimal"><li>在FreshRSS web主页，点击左上角的<code class="notion-inline-code">Subscription management</code> -&gt; 点击左栏的<code class="notion-inline-code">Subscription tools</code> -&gt; 复制<code class="notion-inline-code">订阅API链接</code> -&gt; 将其填写到<code class="notion-inline-code">RSSHub-Radar</code>插件设置页面里的<code class="notion-inline-code">一键订阅</code>下的<code class="notion-inline-code">FreshRSS</code>选项中。</li></ol><div class="notion-text notion-block-75e3d50f1c4a8231868501b73b1a0e9d">这样就可以通过点击浏览器导航栏的RSSHub-Radar图标快速将当前网页的订阅链接添加到FreshRSS中，从而通过NetNewsWire浏览。</div><div class="notion-text notion-block-2553d50f1c4a8368a02801e595b5599a">参考：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1583d50f1c4a82988c2301ce30f713e7" style="list-style-type:decimal"><li><a class="notion-link" href="https://blog.zhheo.com/p/9158a43c.html#%E6%90%AD%E5%BB%BAFreshRSS" target="_blank" rel="noopener noreferrer">https://blog.zhheo.com/p/9158a43c.html#搭建FreshRSS</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-a653d50f1c4a8351803601ea08b92673" style="list-style-type:decimal"><li><a class="notion-link" href="https://veryjack.com/technique/docker-install-freshrss/" target="_blank" rel="noopener noreferrer">https://veryjack.com/technique/docker-install-freshrss/</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-a993d50f1c4a82b69dd70123fe6bd99c" style="list-style-type:decimal"><li><a class="notion-link" href="https://www.bmqy.net/2648.html#%E8%AE%BF%E9%97%AE" target="_blank" rel="noopener noreferrer">https://www.bmqy.net/2648.html#访问</a></li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[frp内网穿透记录]]></title>
            <link>https://idzc.top/article/202311041500</link>
            <guid>https://idzc.top/article/202311041500</guid>
            <pubDate>Sat, 04 Nov 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[使用frp进行内网穿透]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-cef3d50f1c4a8316bc8c819f5299c0ed"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-9dc3d50f1c4a83b5b38681ea7ce36d4e" data-id="9dc3d50f1c4a83b5b38681ea7ce36d4e"><span><div id="9dc3d50f1c4a83b5b38681ea7ce36d4e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9dc3d50f1c4a83b5b38681ea7ce36d4e" title="场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>场景</b></span></span></h3><div class="notion-text notion-block-7ce3d50f1c4a834e82fa81f6f3b56003">需求：</div><ul class="notion-list notion-list-disc notion-block-a693d50f1c4a827ea53d81166b681e74"><li>Linux主机A，可以访问外网，但是没有公网ip；部署了wandb、ssh或其他程序；</li></ul><ul class="notion-list notion-list-disc notion-block-4dd3d50f1c4a833780bf81d2910d5ab7"><li>个人PC（例如MacOS），可以访问外网，也没有公网ip，与主机A不在同一局域网。希望能访问主机A上的wandb，且通过ssh连接主机A。</li></ul><div class="notion-text notion-block-8d13d50f1c4a8398a144819f6df44f13">思路：</div><ul class="notion-list notion-list-disc notion-block-8243d50f1c4a83daacf7813359df3643"><li>拥有一台远程Linux服务器B，可以访问外网，且有公网ip（这样主机A和个人PC都可以访问服务器B）。</li></ul><ul class="notion-list notion-list-disc notion-block-7c83d50f1c4a8289a5ab8160e9d3b45a"><li>使用frp来将服务器B当作“代理”：</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c0b3d50f1c4a82fb82720123435180b6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/11/04/07_21_36-1699082495696.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=c0b3d50f-1c4a-82fb-8272-0123435180b6" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3e23d50f1c4a826d943081d8c637cd21" data-id="3e23d50f1c4a826d943081d8c637cd21"><span><div id="3e23d50f1c4a826d943081d8c637cd21" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3e23d50f1c4a826d943081d8c637cd21" title="下载frp软件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>下载frp软件</b></span></span></h3><div class="notion-text notion-block-2983d50f1c4a83e58750814a66ed4052">在github上下载相应的服务器端与客户程序：</div><div class="notion-text notion-block-a6a3d50f1c4a821da06b01cd6e706310"><a class="notion-link" href="https://github.com/fatedier/frp/releases" target="_blank" rel="noopener noreferrer">fatedier/frp/releases</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1643d50f1c4a8388832d0147867e8ef5" data-id="1643d50f1c4a8388832d0147867e8ef5"><span><div id="1643d50f1c4a8388832d0147867e8ef5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1643d50f1c4a8388832d0147867e8ef5" title="服务器B上的操作"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>服务器B上的操作</b></span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-e253d50f1c4a839fb62781be5b76370a" data-id="e253d50f1c4a839fb62781be5b76370a"><span><div id="e253d50f1c4a839fb62781be5b76370a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e253d50f1c4a839fb62781be5b76370a" title="安装frps并配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>安装frps并配置</b></span></span></h4><div class="notion-text notion-block-4633d50f1c4a83a9af3981cf8ae8daf3">关注以下文件：</div><div class="notion-text notion-block-c7f3d50f1c4a8358a6868107f85e03e8">前两个文件（s结尾代表server）分别是服务端程序和服务端配置文件，后两个文件（c结尾代表client）分别是客户端程序和客户端配置文件。此时，我们在配置公网服务器，因此修改frps.toml：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-3303d50f1c4a82d7977181be7453cb65" data-id="3303d50f1c4a82d7977181be7453cb65"><span><div id="3303d50f1c4a82d7977181be7453cb65" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3303d50f1c4a82d7977181be7453cb65" title="添加到systemd自启动"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>添加到systemd自启动</b></span></span></h4><div class="notion-text notion-block-c983d50f1c4a82bcaf3d81cc1896205e"><code class="notion-inline-code">vim /etc/systemd/system/frps.service</code></div><div class="notion-text notion-block-fbc3d50f1c4a821c940281a5c2628395">并且你需要在防火墙里放行7000、7500这两个端口。</div><div class="notion-text notion-block-25a3d50f1c4a83fc847781d570ede40f">在个人PC上访问 http://服务器ip:7500，就可以看到frp server的状态。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-73d3d50f1c4a8260b82b017f3cd094d5" data-id="73d3d50f1c4a8260b82b017f3cd094d5"><span><div id="73d3d50f1c4a8260b82b017f3cd094d5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#73d3d50f1c4a8260b82b017f3cd094d5" title="主机A的配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>主机A的配置</b></span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-7cd3d50f1c4a82ba9f6501d5c59d100d" data-id="7cd3d50f1c4a82ba9f6501d5c59d100d"><span><div id="7cd3d50f1c4a82ba9f6501d5c59d100d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7cd3d50f1c4a82ba9f6501d5c59d100d" title="安装frpc并配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>安装frpc并配置</b></span></span></h4><div class="notion-text notion-block-be03d50f1c4a820e9cae81752daa234f">frpc.toml</div><blockquote class="notion-quote notion-block-c783d50f1c4a83d7987b019a38c7eb30"><div>上面的[[proxies]]板块是添加的代理服务</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-cf13d50f1c4a82c0ac5f01685013818a" data-id="cf13d50f1c4a82c0ac5f01685013818a"><span><div id="cf13d50f1c4a82c0ac5f01685013818a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cf13d50f1c4a82c0ac5f01685013818a" title="添加到systemd自启动"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>添加到systemd自启动</b></span></span></h4><div class="notion-text notion-block-9d63d50f1c4a83fca61a8122ce463585">类似服务器B的操作，这里假设主机A是以普通用户添加systemd自启动。</div><blockquote class="notion-quote notion-block-dc23d50f1c4a83e2aa160198481b479e"><div>如果主机A的普通用户没有开启systemd自启动功能，参考<a class="notion-link" href="https://wiki.archlinux.org/title/systemd/User" target="_blank" rel="noopener noreferrer">systemd/User - ArchWiki (archlinux.org)</a>执行<code class="notion-inline-code">loginctl enable-linger </code><em><code class="notion-inline-code">username</code></em><em>开启。</em></div></blockquote><div class="notion-text notion-block-d5e3d50f1c4a82b297ad01833aac3378"><code class="notion-inline-code">vim ~/.config/systemd/user/frpc.service</code></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-efb3d50f1c4a82fcb80701f148cb25eb" data-id="efb3d50f1c4a82fcb80701f148cb25eb"><span><div id="efb3d50f1c4a82fcb80701f148cb25eb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#efb3d50f1c4a82fcb80701f148cb25eb" title="达到的效果"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>达到的效果</b></span></span></h3><ul class="notion-list notion-list-disc notion-block-2c03d50f1c4a82998cc9814f1d4d790e"><li>个人PC通过<code class="notion-inline-code">ssh xxx@服务器ip:221</code>就能通过代理服务器远程连接主机A了。</li></ul><ul class="notion-list notion-list-disc notion-block-7143d50f1c4a82979f9d0198ec4a4015"><li>个人PC通过访问<code class="notion-inline-code">http://@服务器ip:1991</code>就能通过代理服务器访问主机A中的wandb服务了。</li></ul><div class="notion-text notion-block-c623d50f1c4a836f93ee81de3cf082c7">参考：</div><ul class="notion-list notion-list-disc notion-block-d673d50f1c4a836ab8e88121a83e51d9"><li><a class="notion-link" href="https://www.cnblogs.com/kxqblog/p/16080477.html" target="_blank" rel="noopener noreferrer">https://www.cnblogs.com/kxqblog/p/16080477.html</a></li></ul><ul class="notion-list notion-list-disc notion-block-df03d50f1c4a8259bbeb01ebb5364265"><li><a class="notion-link" href="https://dusays.com/636/" target="_blank" rel="noopener noreferrer">新版本 frp 参考配置分享</a></li></ul><ul class="notion-list notion-list-disc notion-block-aac3d50f1c4a82dcb7b201a94ae074f3"><li><a class="notion-link" href="https://juejin.cn/post/7293392480452247562" target="_blank" rel="noopener noreferrer">frp: 内网穿透利器 🐂🐂🐂</a></li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[代理软件Clash Verge配置记录]]></title>
            <link>https://idzc.top/article/202307011700</link>
            <guid>https://idzc.top/article/202307011700</guid>
            <pubDate>Sat, 01 Jul 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[个人认为的好用的代理客户端，给出了一个简单的配置示例]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-bbf3d50f1c4a83c5be2f81858e097be6"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-7593d50f1c4a83e597b7014816629484"><span class="notion-red">随着软件版本的迭代，该教程已过期。</span></div><div class="notion-blank notion-block-dee3d50f1c4a82be8a0801a36eb72060"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ac23d50f1c4a82bdb1c781c18a3c94e5" data-id="ac23d50f1c4a82bdb1c781c18a3c94e5"><span><div id="ac23d50f1c4a82bdb1c781c18a3c94e5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ac23d50f1c4a82bdb1c781c18a3c94e5" title="起因"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">起因</span></span></h3><div class="notion-text notion-block-df63d50f1c4a82a3b29581a3294a1e1a">和好朋友谈到我的梯子打开ChatGPT有点卡时，好朋友果断把他的梯子订阅链接分享了给我。</div><div class="notion-text notion-block-4f73d50f1c4a83809f020165aae5e26e">然而填到<a class="notion-link" href="https://github.com/Fndroid/clash_for_windows_pkg" target="_blank" rel="noopener noreferrer">clash for windows</a>（也称cfw）时报错不支持hysteria协议。查了下，hysteria协议只有<b><a class="notion-link" href="https://clash-meta.wiki/#clashmeta" target="_blank" rel="noopener noreferrer">Clash.Meta</a></b>的core才支持，而cfw原生只支持clash core，而clash core作者<a class="notion-link" href="https://github.com/Dreamacro/clash/issues/2372" target="_blank" rel="noopener noreferrer">似乎无意支持hysteria协议</a>。</div><div class="notion-text notion-block-4cd3d50f1c4a835394c1819e771db80f">于是我去谷歌了下支持<b><a class="notion-link" href="https://clash-meta.wiki/#clashmeta" target="_blank" rel="noopener noreferrer">Clash.Meta</a></b>的core的客户端，然后就找到了<b>Clash Verge</b>这个软件，和cfw界面有点类似，但配置不太一样。看了它的wiki后，自己折腾了下，感觉配置方式太灵活了，立马推荐给了我好朋友（他似乎用的是换core的cfw，百度有教程的，但我感觉那样不方便后续升级）。下面就记录下折腾结果。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-9173d50f1c4a8239b919016ef469c12a" data-id="9173d50f1c4a8239b919016ef469c12a"><span><div id="9173d50f1c4a8239b919016ef469c12a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9173d50f1c4a8239b919016ef469c12a" title="安装"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">安装</span></span></h3><div class="notion-text notion-block-5763d50f1c4a8339ac0301c57fdd49a9">直接在Clash Verge的<a class="notion-link" href="https://github.com/zzzgydi/clash-verge/releases" target="_blank" rel="noopener noreferrer">release</a>界面下载对应的包，点击安装即可。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-22d3d50f1c4a8394819a010730532da3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/09_46_34-1688204793427.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=22d3d50f-1c4a-8394-819a-010730532da3" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1013d50f1c4a836e9183012b2d249485" data-id="1013d50f1c4a836e9183012b2d249485"><span><div id="1013d50f1c4a836e9183012b2d249485" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1013d50f1c4a836e9183012b2d249485" title="使用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用</span></span></h3><div class="notion-text notion-block-83f3d50f1c4a8286999681d3b377be88"><b>添加订阅链接</b></div><div class="notion-text notion-block-e323d50f1c4a82838df6017dce5282d2">通常打开软件后，在状态栏/任务栏会有一个图标（Clash Verge是没有眼睛的猫猫头），右键猫猫头然后点击Dashboard→Profiles→搜索框输入订阅链接→IMPORT。</div><div class="notion-text notion-block-33d3d50f1c4a8300999081f1e5df6709"><b>开启代理</b></div><div class="notion-text notion-block-d5d3d50f1c4a824e834501c8fdadd50c">右键点击猫猫头，勾选System Proxy和Rule Mode：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-bde3d50f1c4a82d7a7f601baa90a463d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:288px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/09_48_18-1688204898113.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=bde3d50f-1c4a-82d7-a7f6-01baa90a463d" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-93f3d50f1c4a82c5b8fa81cb35a910cf" data-id="93f3d50f1c4a82c5b8fa81cb35a910cf"><span><div id="93f3d50f1c4a82c5b8fa81cb35a910cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#93f3d50f1c4a82c5b8fa81cb35a910cf" title="配置规则/白名单"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置规则/白名单</span></span></h3><div class="notion-text notion-block-d983d50f1c4a831b892581bd339ecbc5"><b>回顾下cfw是怎么配置的：</b></div><div class="notion-text notion-block-8ec3d50f1c4a83cba3a181c416dbc04b">右键猫猫头→Dashboard→Settings→Profiles→Parser Edit：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9a63d50f1c4a82788ff681c2b8d2ec4a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/09_54_11-1688205251069.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=9a63d50f-1c4a-8278-8ff6-81c2b8d2ec4a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-e0c3d50f1c4a83bab8de81ec42f13be8"> </div><div class="notion-text notion-block-ec43d50f1c4a82ad8a5881b712b060b1">然后添加规则：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4243d50f1c4a8392b25681c798e26976"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/09_55_19-1688205318786.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=4243d50f-1c4a-8392-b256-81c798e26976" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-cab3d50f1c4a8264809e811cc381f5da">保存后，需要Dashboard→Profiles→选中config（即订阅链接产生的选项卡）并点击更新图标（以保证自定义规则添加到了config）。</div><div class="notion-text notion-block-5a53d50f1c4a837a8efd019bbd33e86e"><b>Clash Verge的配置方式：</b></div><div class="notion-text notion-block-b443d50f1c4a8337b37401f17557b74a">参考作者的<a class="notion-link" href="https://github.com/zzzgydi/clash-verge/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97" target="_blank" rel="noopener noreferrer">wiki</a>：</div><blockquote class="notion-quote notion-block-2f83d50f1c4a8211b6580114c9525bfe"><div>目前支持4种类型的配置文件，分别是Remote、Local、Script、Merge。其中，Remote和Local类型为 <b>主配置文件</b>，Script和Merge类型为 <b>增强配置文件</b>，用于修改主配置文件的。点<code class="notion-inline-code">New</code>可以创建这些配置文件（如下图），对于Remote类型的，也可以直接输入url import即可。 <em>（备注：该模式主要参考了CFW的实现）</em></div></blockquote><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9143d50f1c4a83b4b45581527b29b64a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_01_28-1688205687532.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=9143d50f-1c4a-83b4-b455-81527b29b64a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-66b3d50f1c4a82eba6aa019bf586d2a1"> </div><div class="notion-text notion-block-3c23d50f1c4a8290a6348165ada23d84">简单来说:</div><ol start="1" class="notion-list notion-list-numbered notion-block-8d43d50f1c4a828da05681035e3c458e" style="list-style-type:decimal"><li>Remote Type Profile是用来订阅远程链接的，通常机场的订阅地址填写到下图红框中：</li><ol class="notion-list notion-list-numbered notion-block-8d43d50f1c4a828da05681035e3c458e" style="list-style-type:lower-alpha"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6f33d50f1c4a8396ac8101da3f98fbf4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_03_39-1688205818541.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=6f33d50f-1c4a-8396-ac81-01da3f98fbf4" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-a7c3d50f1c4a83f1973e81e5dd96a3b4" style="list-style-type:decimal"><li>Local Type Profile其实就是添加本地的config文件：</li><ol class="notion-list notion-list-numbered notion-block-a7c3d50f1c4a83f1973e81e5dd96a3b4" style="list-style-type:lower-alpha"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3773d50f1c4a8214b124819299023108"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_05_32-1688205932220.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=3773d50f-1c4a-8214-b124-819299023108" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-6d63d50f1c4a82e3bd1a01fe7ce2308f" style="list-style-type:decimal"><li>Script Type Profile：个人认为算是Clash Verge与cfw最大的不同之处了吧，它允许用户使用javascript脚本来预处理config（可以是上面的远程订阅得到的config，也可以是本地config文件）</li><ol class="notion-list notion-list-numbered notion-block-6d63d50f1c4a82e3bd1a01fe7ce2308f" style="list-style-type:lower-alpha"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1623d50f1c4a839cbef181fd64943b2d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_08_17-1688206096903.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=1623d50f-1c4a-839c-bef1-81fd64943b2d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-64d3d50f1c4a836daf9f012a0ad5da37">然后点击SAVE，再右键该Profile→Edit File→编写预处理js脚本→SAVE→Enable：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0fa3d50f1c4a83e7b889013df25ede77"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_09_59-1688206199286.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=0fa3d50f-1c4a-83e7-b889-013df25ede77" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-f773d50f1c4a8365b34b8113fc05aba4">我会在后面分享一个预处理config脚本，用来添加一个名字叫OpenAI的proxy group（专门为OpenAI/ChatGPT网站选节点）。</div></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1093d50f1c4a8399afbe81a8f4b8c703" style="list-style-type:decimal"><li>Merge Type Profile。作者说这是源于cfw中的配置方法而设计的。即方便将cfw配置的Parses迁移到Clash Verge中。</li><ol class="notion-list notion-list-numbered notion-block-1093d50f1c4a8399afbe81a8f4b8c703" style="list-style-type:lower-alpha"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b413d50f1c4a838b922901b6270cc542"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:336px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_13_37-1688206416866.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=b413d50f-1c4a-838b-9229-01b6270cc542" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-d1c3d50f1c4a830baaf7012b4be7008d">然后同样是：右键该Profile→Edit File→填写规则→SAVE→Enable：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b73d50f1c4a8359b895014410cc29a5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/10_16_09-1688206569174.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=1b73d50f-1c4a-8359-b895-014410cc29a5" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-eda3d50f1c4a83f695e901628d063242">作者在<a class="notion-link" href="https://github.com/zzzgydi/clash-verge/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97" target="_blank" rel="noopener noreferrer">wiki</a>里对这个yaml文件的各个字段做一个详细解释。但个人认为，平常用的最多的是<code class="notion-inline-code">prepend-rules</code>，其对应于cfw的Parse规则配置。我会在下面分享一个简单的、只有<code class="notion-inline-code">prepend-rules</code>的示例。</div><div class="notion-text notion-block-5183d50f1c4a8282ab8d016b5cb5d940"><b>总的来说：</b></div><ul class="notion-list notion-list-disc notion-block-1783d50f1c4a834598bb01bcb65e6788"><li>Clash Verge的配置就是进行上面134或者234步骤；</li></ul><ul class="notion-list notion-list-disc notion-block-d1d3d50f1c4a82a8b866814d90ee72bb"><li>如果你只想简单的添加订阅链接/本地config文件，只需要进行1或2的步骤；</li></ul><ul class="notion-list notion-list-disc notion-block-e2f3d50f1c4a83dca20a01fa38ef68af"><li>如果还需添加一些规则的话，额外进行步骤4；</li></ul><ul class="notion-list notion-list-disc notion-block-7d03d50f1c4a83e1980501d96d26f3a6"><li>添加一些复杂的操作的话，可能额外需要进行步骤3。</li></ul><ul class="notion-list notion-list-disc notion-block-b713d50f1c4a829daf6101e0b995ac31"><li>注意，在配置完规则或者脚本后，建议重新更新下订阅的Profiles，以保证规则和脚本生效。</li></ul><div class="notion-text notion-block-18b3d50f1c4a8367930c811a3bf1f882">建议在配置完规则后，Dashboard→Rules→输入关键字筛选（例如输入open）→检查是否有对应规则：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3c73d50f1c4a83f19eea810a0561cf4e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/07/01/11_07_28-1688209648094.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=3c73d50f-1c4a-83f1-9eea-810a0561cf4e" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-block-2643d50f1c4a82bea9d181f9280f99f2" data-id="2643d50f1c4a82bea9d181f9280f99f2"><span><div id="2643d50f1c4a82bea9d181f9280f99f2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2643d50f1c4a82bea9d181f9280f99f2" title="附件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">附件</span></span></h3><h4 class="notion-h notion-h3 notion-block-6bd3d50f1c4a83ec8dd0819a049874b5" data-id="6bd3d50f1c4a83ec8dd0819a049874b5"><span><div id="6bd3d50f1c4a83ec8dd0819a049874b5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6bd3d50f1c4a83ec8dd0819a049874b5" title="预处理js脚本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">预处理js脚本</span></span></h4><div class="notion-text notion-block-eee3d50f1c4a83ec821a01c1eeab1544">用来添加一个名字叫<code class="notion-inline-code">🔯OpenAI</code>的proxy group（专门为OpenAI/ChatGPT网站选节点，其节点列表拷贝自<code class="notion-inline-code">🌍 国外媒体</code>这个group）：</div><div class="notion-text notion-block-7dd3d50f1c4a83e3947c811cf0e2cb2c">为什么有这个脚本？因为之前用cfw时，我让openai相应的域名通过<code class="notion-inline-code">🎶 网易音乐</code>这个group指定的节点转发（我不用网易云音乐），而有的梯子提供商的订阅链接不自带这个group，但是都会自带<code class="notion-inline-code">🌍 国外媒体</code>这个group，且cfw似乎不具备脚本更改group的功能。因此，我打算用Clash Verge通过脚本拷贝一个group，专门服务于openai相应的域名访问。</div><h4 class="notion-h notion-h3 notion-block-b523d50f1c4a829c96df01ac3fb77edc" data-id="b523d50f1c4a829c96df01ac3fb77edc"><span><div id="b523d50f1c4a829c96df01ac3fb77edc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b523d50f1c4a829c96df01ac3fb77edc" title="简单规则示例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">简单规则示例</span></span></h4><div class="notion-text notion-block-6ba3d50f1c4a8262866781a1dc9eb150">指定一些白名单，如局域网的IP或者中国域名都走DIRECT直连（不走梯子流量）；后缀匹配到openai.com的域名（如chat.openai.com）走<code class="notion-inline-code">🔯OpenAI</code>这个proxy group设定的节点（通常是美国、英国节点）。</div><div class="notion-text notion-gray notion-block-08b3d50f1c4a83a18e0d0173f82ea6dc"><em>这个yaml文件中没有被配置的每个字段的下一行必有一个空行，否则报错。（由于本站的js脚本，导致最后一个空行被清除了）</em></div><div class="notion-blank notion-block-33d3d50f1c4a8280abd381fab558b6cd"> </div></ol></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[学习Sinkhorn Distance后的个人理解]]></title>
            <link>https://idzc.top/article/202305042300</link>
            <guid>https://idzc.top/article/202305042300</guid>
            <pubDate>Thu, 04 May 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[本文简单介绍一下最优传输理论中的Sinkhorn Distance及其求解的方法，并提供了Python代码实现]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-ae63d50f1c4a8282b70e81e964ba24d9"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-0f43d50f1c4a821a9fc981c43c268436">由于网上各位大佬都做了足够多的介绍，我这里当个缝合怪，顺便说说自己的理解。若有疏漏，请斧正！</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-4633d50f1c4a82d9baaf01f80a68d77e" data-id="4633d50f1c4a82d9baaf01f80a68d77e"><span><div id="4633d50f1c4a82d9baaf01f80a68d77e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4633d50f1c4a82d9baaf01f80a68d77e" title="概念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">概念</span></span></h3><div class="notion-text notion-block-5423d50f1c4a82089313012389b8d989">什么是<span class="notion-red"><b>Sinkhorn Distance</b></span>？它是一种<span class="notion-red"><b>optimal transport distance</b></span>。</div><div class="notion-text notion-block-8a33d50f1c4a838b957781f13fefa1f5">什么是<span class="notion-red"><b>optimal transport distances</b></span>呢？我们不妨说说其中很常见的<span class="notion-red"><b>推土机距离</b></span>。</div><div class="notion-text notion-block-0853d50f1c4a82f9a02101d95b1f6b70">什么又是<span class="notion-red"><b>推土机距离</b></span>呢？那下面就做个简单的介绍。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5343d50f1c4a839a8a05016c1e76b1c6" data-id="5343d50f1c4a839a8a05016c1e76b1c6"><span><div id="5343d50f1c4a839a8a05016c1e76b1c6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5343d50f1c4a839a8a05016c1e76b1c6" title="推土机距离"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">推土机距离</span></span></h4><div class="notion-text notion-block-c5d3d50f1c4a82aea8200179491289dd"><a class="notion-link" href="https://en.wikipedia.org/wiki/Earth_mover%27s_distance" target="_blank" rel="noopener noreferrer">Wikipedia</a>的对推土机距离的解释是：</div><blockquote class="notion-quote notion-block-dd53d50f1c4a82b0a4ef815bfca0cbd0"><div>In computer science, the <b>earth mover&#x27;s distance</b> (<b>EMD</b>) is a distance-like measure of dissimilarity between two <a class="notion-link" href="https://en.wikipedia.org/wiki/Frequency_(statistics)" target="_blank" rel="noopener noreferrer">frequency distributions</a>, <a class="notion-link" href="https://en.wikipedia.org/wiki/Density_(disambiguation)" target="_blank" rel="noopener noreferrer">densities</a>, or <a class="notion-link" href="https://en.wikipedia.org/wiki/Measure_(mathematics)" target="_blank" rel="noopener noreferrer">measures</a> over a region <em>D.</em></div></blockquote><div class="notion-text notion-block-d123d50f1c4a8223b17c01eaf68006a6">简单来说，推土机距离是衡量两个分布之间的距离的一种方法。它的基本思想是将一种分布通过一定的代价转换为另一种分布，计算这个代价就是推土机距离。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9863d50f1c4a83a9b06401754f77fd34"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/03/15_21_13-1683127273315.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=9863d50f-1c4a-83a9-b064-01754f77fd34" alt="对于两个分布和，可以将它们想象成仅堆叠不同的两堆土，怎么样花最低代价将左边的土推成右边的土呢？" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">对于两个分布<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，可以将它们想象成仅堆叠不同的两堆土，怎么样花最低代价将左边的土推成右边的土呢？</figcaption></div></figure><div class="notion-text notion-block-b803d50f1c4a823aa1168155eecd7a8c">你可能了解过度量两个分布的其他距离，如欧氏距离、KL散度、JS散度以及其他更复杂的距离，但是这类距离方式并未考虑两个分布之间的联合分布。而推土机考虑了：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-87a3d50f1c4a828dabee816e7c1083c9">其中，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是所有联合分布的集合，其边缘分布分别为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。</div><div class="notion-text notion-block-6123d50f1c4a8256b71c81577bcf5c17">求解这样的式子，得到联合分布<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，也就是最终的推土方案：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-52e3d50f1c4a83d58386015598c3a37e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/03/15_01_24-1683126081512.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=52e3d50f-1c4a-83d5-8386-015598c3a37e" alt="推土方案示例：左边某些区域的土可能还需要推到右边对应区域的附近区域上。" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">推土方案示例：左边某些区域的土可能还需要推到右边对应区域的附近区域上。</figcaption></div></figure><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-8e63d50f1c4a8244a836819957e1b16a" data-id="8e63d50f1c4a8244a836819957e1b16a"><span><div id="8e63d50f1c4a8244a836819957e1b16a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8e63d50f1c4a8244a836819957e1b16a" title="Optimal Transport Distances"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Optimal Transport Distances</span></span></h4><div class="notion-text notion-block-0f23d50f1c4a8210a44f01ad96a33669">介绍完推土机距离后，回到optimal transport distances上。</div><div class="notion-text notion-block-daf3d50f1c4a82e683a381d547a4b6a5">假设有这样的交通运输场景<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#e8f3d50f1c4a8243951501922ab7eab8">⁵</a>：有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个仓库，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个工厂，我们需要将某种物品从各个仓库运送到各个工厂（允许一个仓库的物品运往多个工厂，且允许一个工厂接受多个仓库的运货），希望找到最优运输方案来最大限度地降低运输成本，这便是最优传输问题。</div><div class="notion-blank notion-block-3b43d50f1c4a826f8ce381b8e2eba753"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0dd3d50f1c4a831ea19e819abbfcfceb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/03/15_32_30-1683127949721.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=0dd3d50f-1c4a-831e-a19e-819abbfcfceb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-5c33d50f1c4a821bb8e281cb36e9283b"> </div><div class="notion-text notion-block-f2b3d50f1c4a83038eb7811ec62f8fbf">假设第<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个仓库存货量是<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，第<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个工厂的需求量是<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，仓库<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>到工厂<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的运输距离是<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示从第<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个仓库运货到第<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个工厂的货物量，那么求解这样的问题其实是在求解如下的线性规划：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-a143d50f1c4a83b7aaf381061611b342"><b>和推土机距离的联系：</b></div><div class="notion-text notion-block-e673d50f1c4a82c78efd817388518318">（下面均假设<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，理论上可推广至<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的情形），仓库和工厂可看成两堆不同的土，各个仓库的存储量情况和各个工厂的需求量情况可以看作两个分布，各个仓库和各个工厂的距离可以看作为两个分布（直方图）各个区域间的距离。</div><div class="notion-blank notion-block-9c33d50f1c4a8338900a0171bf0e1851"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e863d50f1c4a82b9bd84012353fc408c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/03/15_59_10-1683129550260.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=e863d50f-1c4a-82b9-bd84-012353fc408c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-28c3d50f1c4a838a8f3d818123a16341"> </div><div class="notion-text notion-block-b423d50f1c4a826f86e98195c5be6eee">上面通过求解(2)式获得的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>就是最优传输距离，下文称之为原始optimal transport distance。</div><div class="notion-text notion-block-8093d50f1c4a8266829581d0e7a20bc4">然而一些工作在(2)式的基础上加了一些约束，使其便于求解，因此就有了不同“版本”的距离，统称为optimal transport distances。例如常见的有：</div><ol start="1" class="notion-list notion-list-numbered notion-block-4f63d50f1c4a839fa49181f8e6df8430" style="list-style-type:decimal"><li><b>Wasserstein Distance </b>(也称推土机距离)：用于WGAN中，使用Lipschitz正则化(1)式的对偶形式中引入的函数。不过一些人认为WGAN中计算的分布间的距离并不是严格意义上的Wasserstein Distance。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1213d50f1c4a8303a78e01630b461450" style="list-style-type:decimal"><li><b>Sinkhorn Distance:</b> 它是Wasserstein distance的一个近似算法，使用了熵正则化的方法实现计算上的效率。通过引入熵惩罚项，可以将概率分布之间的optimal transport问题转变为具备良好计算性质的解析表达式。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-7473d50f1c4a838696b781a1f7f19f78" style="list-style-type:decimal"><li><b><a class="notion-link" href="https://openreview.net/forum?id=S1m6h21Cb" target="_blank" rel="noopener noreferrer">Cramer Distance</a></b><b>:</b> 一种用于测量两个概率分布之间距离的方法，它是基于分布函数的平方差来定义的。Cramer Distance的提出是为了解决Wasserstein Distance在梯度计算中存在偏差的问题。</li></ol><div class="notion-text notion-block-90c3d50f1c4a83adb85801ec8c22e197">而今天本文的主角是“Sinkhorn Distance”，下面开始介绍。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6eb3d50f1c4a8346b23781fcba3dd687" data-id="6eb3d50f1c4a8346b23781fcba3dd687"><span><div id="6eb3d50f1c4a8346b23781fcba3dd687" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6eb3d50f1c4a8346b23781fcba3dd687" title="Sinkhorn Distance"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Sinkhorn Distance</span></span></h3><div class="notion-text notion-block-c113d50f1c4a831494c58104db3453d6">为什么文献<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#bb43d50f1c4a831b92d381d8531c1ebc">[1]</a>会提出Sinkhorn Distance呢？</div><div class="notion-text notion-block-d443d50f1c4a8318b1340129561dffea">其主要针对原始optimal transport distance的时间复杂度高这一问题，提出了一种最大化熵的约束方案来使传输方案不那么稀疏，并且降低了计算复杂度。具体而言，原始optimal transport distance存在的缺陷：</div><ul class="notion-list notion-list-disc notion-block-fc33d50f1c4a826f949701773628c420"><li><span class="notion-red"><b>计算复杂度高</b></span>：在针对两个d维的直方图的optimal transport distance时，至少需要<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。当测度空间嵌入到<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，在高维直方图上计算该距离的成本是非常巨大的。</li></ul><ul class="notion-list notion-list-disc notion-block-a5c3d50f1c4a83ad86b8019c68b42512"><li><span class="notion-red"><b>稀疏性</b></span>：由于计算原始optimal transport distance的是在求解线性规划问题，因此最优解通常出现在可行域的顶点处，落在顶点处的解通常是比较稀疏的。例如对于两个<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>维直方图，使用线性规划求解的传输方案为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的稀疏矩阵，且最多有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个非零元素，从概率角度看，如果<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，具有很少的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>能使得<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。即一个仓库偏向于只为少量（甚至一个）仓库供货。这样的稀疏可能并不符合实际场景，以至于计算得到的并非最优解。</li></ul><div class="notion-text notion-block-8263d50f1c4a823ba744011c9678faf2">Sinkhorn Distance便是针对这两个问题提出的一种lightspeed computation、sufficient smoothness的optimal transport distance。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5bd3d50f1c4a8386825a8154e3707974" data-id="5bd3d50f1c4a8386825a8154e3707974"><span><div id="5bd3d50f1c4a8386825a8154e3707974" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5bd3d50f1c4a8386825a8154e3707974" title="回顾optimal transport distance"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">回顾optimal transport distance</span></span></h4><div class="notion-text notion-block-52a3d50f1c4a82dd8972816352f56f4d">这里对上面提到的原始optimal transport distance做一个形式化描述：</div><div class="notion-text notion-block-3bb3d50f1c4a82dbba32010f1733c4a1">对于在单纯形<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中的两个概率向量<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，记<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>到<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的所有传输方案集合为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-6613d50f1c4a830ca6090174daa1fb01"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示全1的列向量，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>包含了行和列总和分别为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的所有非负<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>矩阵。对于取值均在<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的两个多项随机变量<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，每个变量分别具有分布<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>包含了所有关于<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的联合分布。对于<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。</div><div class="notion-text notion-block-f483d50f1c4a8287ab9b015b865207ae">那么对于<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>间的optimal transport distance定义为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-8853d50f1c4a827abc0581d4476fe965">其中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>代表Frobenius dot-product（矩阵对应元素相乘的和，相当于对Hadamard product的结果求和）。在有些论文中，上述的表示可能是：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-b693d50f1c4a83e7a0a68187637f7d11" data-id="b693d50f1c4a83e7a0a68187637f7d11"><span><div id="b693d50f1c4a83e7a0a68187637f7d11" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b693d50f1c4a83e7a0a68187637f7d11" title="最大化熵"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">最大化熵</span></span></h4><div class="notion-text notion-block-a283d50f1c4a82e4989081fb82a26f7d">Sinkhorn Distance提出将(4)中的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>进行smoothing，在机器学习领域很容易想到的就是最大化熵，即最大化<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，下面先探讨一下<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的上界。</div><div class="notion-text notion-block-f503d50f1c4a8244b0908173b721d016">符号说明：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-fda3d50f1c4a82dead3c81da3ac40bc2">由<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#5913d50f1c4a82cf93c2013c7054dd8a">[7]</a>中的公式<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>知：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-ed33d50f1c4a83938af301e146ab1177">因为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的联合分布，那么根据(6)有：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-7be3d50f1c4a8304a6a781e755b66346"><span class="notion-red">因此</span><span class="notion-red"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></span><span class="notion-red">的上界是</span><span class="notion-red"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></span>。显然h(P)不能严格靠近其上界（会导致过度平滑），且<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与上界的距离不应超过一定阈值<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>（否则会过度稀疏），即：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><details class="notion-toggle notion-block-03f3d50f1c4a8346afd3019d667765bc"><summary>且易证：<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，</summary><div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3083d50f1c4a8258a3ba01e743f6cdb5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/16_26_05-1683217565576.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=3083d50f-1c4a-8258-a3ba-01e743f6cdb5" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ede3d50f1c4a8386851281416c9c7c18"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/16_27_05-1683217624343.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=ede3d50f-1c4a-8386-8512-81416c9c7c18" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-47f3d50f1c4a82bdb26301e46b90bfe1"> </div></div></details><div class="notion-text notion-block-2183d50f1c4a82c28334012d30aea952">因此有：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-fc63d50f1c4a83cdaba3818a9a327fe1">用(9)来约束<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>得到：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-a213d50f1c4a82aeb8aa81826f227e99">其实直观上看，这个约束就是将运输方案<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>拉近。（那么这个<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>到底是什么呢？见补充部分。）</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-de73d50f1c4a826490e4815429e3a36f" data-id="de73d50f1c4a826490e4815429e3a36f"><span><div id="de73d50f1c4a826490e4815429e3a36f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#de73d50f1c4a826490e4815429e3a36f" title="定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">定义</span></span></h4><div class="notion-text notion-block-6793d50f1c4a82a09ebf81c0116dc0b8">根据上述，可以得到Sinkhorn Distance的定义：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-ff33d50f1c4a828fba3901b99c10c9aa">一般有了定义，会探讨有哪些性质，这里就不展开了，有兴趣的可阅读文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#950b580dc4c045a7ae8af81fa171161b">[1]</a>。</div><div class="notion-text notion-block-af13d50f1c4a83d18d06016f1f979bd0">简单来说，在<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>不是特别小或者特别大时，满足对称性和三角不等式。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-0cb3d50f1c4a82fbafb58162fc024087" data-id="0cb3d50f1c4a82fbafb58162fc024087"><span><div id="0cb3d50f1c4a82fbafb58162fc024087" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0cb3d50f1c4a82fbafb58162fc024087" title="对偶形式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">对偶形式</span></span></h4><div class="notion-text notion-block-4dc3d50f1c4a8355be4a8150a4c20523">直接求解(11)式是比较棘手的，可以考虑(11)式的对偶形式：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-3393d50f1c4a8349a08781341a13e665">对(11)中的每个<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，都能在(12)中找到合适的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>使得
<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>成立。如此便将较复杂的约束<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>转换为惩罚项<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。这里的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>被文献<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#bb43d50f1c4a831b92d381d8531c1ebc">[1]</a>作者称为<em><span class="notion-red">dual-Sinkhorn divergence</span></em>。</div><div class="notion-text notion-block-3243d50f1c4a82ec9c878118a8973aed">这里文献[1]作者给了一个描述原始optimal transport distance <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>、Sinkhorn distance <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>以及dual-Sinkhorn divergence <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>之间关系的示意图：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9453d50f1c4a835e88f00195b612b461"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/17_29_10-1683221349293.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=9453d50f-1c4a-835e-88f0-0195b612b461" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-0683d50f1c4a83cc8521811c4f0fb968">由上图看出，可以从0逐渐增大<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，来找到满足<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。然而在实际使用中，这样去找<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是不切实际的（会带来很多计算量），因此通常靠先验来选择可能合适的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。</div><blockquote class="notion-quote notion-block-e983d50f1c4a8368851601d712134c66"><div>⚠️从公式(12)中可以看出，（求解公式(12)的过程中）<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的熵随着（预定义的）<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的增大在递减。也就是说，如果选了太大的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>会导致公式(12)得到的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的熵偏低，因此<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>不宜太大。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-fcb3d50f1c4a827387e281bbf78d4a69" data-id="fcb3d50f1c4a827387e281bbf78d4a69"><span><div id="fcb3d50f1c4a827387e281bbf78d4a69" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fcb3d50f1c4a827387e281bbf78d4a69" title="使用Sinkhorn’s theorem求解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用Sinkhorn’s theorem求解</span></span></h4><div class="notion-text notion-block-8d73d50f1c4a83a588eb010c6ec87775">得到(12)形式的dual-Sinkhorn divergence后，使用拉格朗日乘子法，可以得到：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-8203d50f1c4a821992fa019f8fcc31cf">其中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是两个等式约束的系数。对<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>求导并令<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，得：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-0da3d50f1c4a82ef8a1a01252b0e726a">注：这里文献<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#bb43d50f1c4a831b92d381d8531c1ebc">[1]</a>作者可能是将<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>对数的底数当作<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>来进行处理的。</div><div class="notion-text notion-block-b283d50f1c4a8251b9ab01061d3995dc">根据(14)可知<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>应该有这样的形式:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-a413d50f1c4a834e889781bd92d0e966">其中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是待求的两个向量。</div><div class="notion-text notion-block-e403d50f1c4a826d87f1817ee02860cc">根据文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#8278ed790fa74a099b3142e17e473218">[8]</a>所提出的<span class="notion-red"><b>Sinkhorn’s theorem</b></span>可知：<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中有且仅有唯一的能表示成<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的矩阵，并且可以通过Sinkhorn’s fixed point iteration来求解<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-c303d50f1c4a837eb4ba0180bd4e7186">文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#950b580dc4c045a7ae8af81fa171161b">[1]</a>作者给出了Matlab风格的伪代码：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c913d50f1c4a83359cfc8147c6d43730"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/18_14_55-1683224093956.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=c913d50f-1c4a-8335-9cfc-8147c6d43730" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-32a3d50f1c4a838988c2016134f9e563">原文还给了其他有趣的证明和说明，有兴趣的可以阅读原文。这里就暂不往后阐述了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8273d50f1c4a83e89fa201fe1cec3710" data-id="8273d50f1c4a83e89fa201fe1cec3710"><span><div id="8273d50f1c4a83e89fa201fe1cec3710" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8273d50f1c4a83e89fa201fe1cec3710" title="Python代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Python代码</span></span></h3><div class="notion-text notion-block-fc13d50f1c4a82c4a7b7813e552cea96">在参考大佬们的Sinkhorn distance实现后，为了接近原文伪代码，我稍做了修改后的Python代码：</div><div class="notion-text notion-block-ef13d50f1c4a83608e128182ada3399b">完整demo见<a class="notion-link" href="https://github.com/zfhxi/Sinkhorn-Distance-Python" target="_blank" rel="noopener noreferrer">zfhxi/Sinkhorn-Distance-Python</a>。</div><div class="notion-text notion-block-a6a3d50f1c4a83ce844981c7907dda26">下面是该demo的可视化结果：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7f93d50f1c4a829e88f98122123c567e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/18_33_23-1683225202448.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=7f93d50f-1c4a-829e-88f9-8122123c567e" alt="分别是分布r、分布c、r和c之间的距离、以及rc的可视化" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">分别是分布r、分布c、r和c之间的距离、以及rc的可视化</figcaption></div></figure><div class="notion-text notion-block-8363d50f1c4a827ab40481dbb451469a">上图可以看出<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是相当光滑的。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cd93d50f1c4a83a28d8301616ab03d5c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/18_49_59-1683226198570.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=cd93d50f-1c4a-83a2-8d83-01616ab03d5c" alt="“使用线性规划求解的EMD运输方案”和“Sinkhorn运输方”的比较" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">“使用线性规划求解的EMD运输方案”和“Sinkhorn运输方”的比较</figcaption></div></figure><div class="notion-text notion-block-38c3d50f1c4a823086518164ca671c80">上图可以看出相比于线性规划求解的运输方案，Sinkhorn distance得到的运输方案更加平滑。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-dee3d50f1c4a8274b450018a764d3504"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://img.idzc.top/picgoimg/2023/05/04/18_53_00-1683226379279.png?spaceId=7c1586b1-f1cc-487f-9b60-342aedccaf51&amp;t=dee3d50f-1c4a-8274-b450-018a764d3504" alt="“使用线性规划求解的EMD”和”Sinkhorn distance“的直方图“堆土”的方案比较" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">“使用线性规划求解的EMD”和”Sinkhorn distance“的直方图“堆土”的方案比较</figcaption></div></figure><div class="notion-text notion-block-5063d50f1c4a836c90f381f5bcb08fa1">上图可以看到，Sinkhorn将直方图切分成更多的块，那么对应到实际场景，可能带来的问题是：运输货物时需要更多的车辆，或者说需要运输多次……</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-0ba3d50f1c4a82b09caf813c3d3f82df" data-id="0ba3d50f1c4a82b09caf813c3d3f82df"><span><div id="0ba3d50f1c4a82b09caf813c3d3f82df" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0ba3d50f1c4a82b09caf813c3d3f82df" title="补充"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">补充</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-7223d50f1c4a835886eb819c04fc9794" data-id="7223d50f1c4a835886eb819c04fc9794"><span><div id="7223d50f1c4a835886eb819c04fc9794" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7223d50f1c4a835886eb819c04fc9794" title="KL散度、JS散度、EMD距离的优缺点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">KL散度、JS散度、EMD距离的优缺点</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-8fe3d50f1c4a82419c7901eb3bdbf96e" style="list-style-type:decimal"><li>KL散度不具备对称性且不满足三角不等式，仅考虑边缘分布；</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-8173d50f1c4a83f78f96816fb925dda7" style="list-style-type:decimal"><li>JS散度具备对称性，但在两个分布距离较远（比如均值差异大）时，变成一个常数，且仅考虑边缘分布；</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-6a13d50f1c4a82a2b69781eb45d60f6a" style="list-style-type:decimal"><li>EMD对称且两个分布距离较远时仍能有效衡量距离，考虑了联合分布，但其计算复杂度比上面两个距离都要高出很多。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-f6c3d50f1c4a83eda056013318b8f02f" data-id="f6c3d50f1c4a83eda056013318b8f02f"><span><div id="f6c3d50f1c4a83eda056013318b8f02f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f6c3d50f1c4a83eda056013318b8f02f" title="代表什么"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>代表什么</span></span></h4><div class="notion-text notion-block-2213d50f1c4a8395b23f81cbf51506f4">根据<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#3cb3d50f1c4a83e1a002819bed08f12c">文章[2]</a>的解释并结合上面提到过的例子，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>意味着：</div><ul class="notion-list notion-list-disc notion-block-be53d50f1c4a831a8b55019a147c160c"><li>只有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中数值比较高（较低）的索引<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中数值较高（较低）的索引<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>相乘后才能使得<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>更高（更低）；</li></ul><ul class="notion-list notion-list-disc notion-block-f9a3d50f1c4a8336ab4101287f71d7f3"><li>并且<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中数值比较高的索引<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中数值较低的索引<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>相乘后并不能使得<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>更高。</li></ul><div class="notion-text notion-block-62a3d50f1c4a82ff8ace81a3b9189c20">也就是说：</div><ul class="notion-list notion-list-disc notion-block-fc63d50f1c4a83dabea281dabda31f6b"><li>对于一些仓库来说，如果它存储量更多，就应该运出更多货物；对于工厂来说，如果它需要更多，就应该从每个仓库那里按比例获得更多。</li></ul><ul class="notion-list notion-list-disc notion-block-aef3d50f1c4a820194fb0199ff217dd1"><li>对于货物存储量很多的仓库，它不会主要向需求量少的工厂运输货物。</li></ul><div class="notion-text notion-block-6ca3d50f1c4a838086070178c85da628"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>代表了一种十分光滑的运输方案，见demo中的<a class="notion-link" href="/ae63d50f1c4a8282b70e81e964ba24d9#7f93d50f1c4a829e88f98122123c567e">可视化图</a>。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-a683d50f1c4a830187c981ecf59a3829" data-id="a683d50f1c4a830187c981ecf59a3829"><span><div id="a683d50f1c4a830187c981ecf59a3829" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a683d50f1c4a830187c981ecf59a3829" title="不动点迭代法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">不动点迭代法</span></span></h4><div class="notion-text notion-block-c993d50f1c4a83c79c89818c7cb12b4e">什么是不动点迭代法参考：<a class="notion-link" href="https://zhuanlan.zhihu.com/p/369690237" target="_blank" rel="noopener noreferrer">不动点迭代法—单变量非线性方程近似根matlab求解 - 知乎 (zhihu.com)</a></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-0843d50f1c4a82f5b136814872e29b57" data-id="0843d50f1c4a82f5b136814872e29b57"><span><div id="0843d50f1c4a82f5b136814872e29b57" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0843d50f1c4a82f5b136814872e29b57" title="相关待读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">相关待读</span></span></h4><div class="notion-text notion-block-f263d50f1c4a83daac2481f6989db818"><a class="notion-link" href="https://zhuanlan.zhihu.com/p/346795219" target="_blank" rel="noopener noreferrer">当Top-k遇到深度学习 - 知乎 (zhihu.com)</a></div><div class="notion-blank notion-block-dd53d50f1c4a82c791d8019c19adbec9"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7de3d50f1c4a820c822a81a4f9338112" data-id="7de3d50f1c4a820c822a81a4f9338112"><span><div id="7de3d50f1c4a820c822a81a4f9338112" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7de3d50f1c4a820c822a81a4f9338112" title="参考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-bb43d50f1c4a831b92d381d8531c1ebc" style="list-style-type:decimal"><li><a class="notion-link" href="https://papers.nips.cc/paper_files/paper/2013/hash/af21d0c97db2e27e13572cbf59eb343d-Abstract.html" target="_blank" rel="noopener noreferrer">Sinkhorn Distances: Lightspeed Computation of Optimal Transport (nips.cc)</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3cb3d50f1c4a83e1a002819bed08f12c" style="list-style-type:decimal"><li><a class="notion-link" href="https://amsword.medium.com/a-simple-introduction-on-sinkhorn-distances-d01a4ef4f085" target="_blank" rel="noopener noreferrer">A simple introduction on Sinkhorn distances | by Jianfeng Wang | Medium</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-8103d50f1c4a8363b0ea013e3e7fb53b" style="list-style-type:decimal"><li><a class="notion-link" href="https://vincentherrmann.github.io/blog/wasserstein/" target="_blank" rel="noopener noreferrer">Wasserstein GAN and the Kantorovich-Rubinstein Duality - Vincent Herrmann</a></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-6453d50f1c4a832aba2d81187f2f8a2b" style="list-style-type:decimal"><li><a class="notion-link" href="https://kaizhao.net/blog/optimal-transport" target="_blank" rel="noopener noreferrer">https://kaizhao.net/blog/optimal-transport</a></li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-e8f3d50f1c4a8243951501922ab7eab8" style="list-style-type:decimal"><li><a class="notion-link" href="https://zhuanlan.zhihu.com/p/527799934" target="_blank" rel="noopener noreferrer">Sinkhorn 距离简单易懂！ - 知乎 (zhihu.com)</a></li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-73a3d50f1c4a83acae93013a8650a324" style="list-style-type:decimal"><li><a class="notion-link" href="https://lccurious.github.io/2020/01/30/optimal-transport/" target="_blank" rel="noopener noreferrer">最优传输理论 | Curiousity Hub (lccurious.github.io)</a></li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-5913d50f1c4a82cf93c2013c7054dd8a" style="list-style-type:decimal"><li><a class="notion-link" href="http://staff.ustc.edu.cn/~cgong821/Wiley.Interscience.Elements.of.Information.Theory.Jul.2006.eBook-DDU.pdf" target="_blank" rel="noopener noreferrer">Elements of Information Theory</a></li></ol><ol start="8" class="notion-list notion-list-numbered notion-block-e463d50f1c4a82769b6381a088b5df22" style="list-style-type:decimal"><li><a class="notion-link" href="https://www.jstor.org/stable/2040061" target="_blank" rel="noopener noreferrer">Diagonal Equivalence to Matrices with Prescribed Row and Column Sums. II on JSTOR</a></li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[长命令行自动转成为Vs Code的launch.json]]></title>
            <link>https://idzc.top/article/202304060000</link>
            <guid>https://idzc.top/article/202304060000</guid>
            <pubDate>Thu, 06 Apr 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[首先介绍了手动创建launch.json的步骤，然后提供了一个Python脚本，可以自动将命令行转换为launch.json。作者还以YOLOX项目为例，演示了如何使用该脚本。如果你经常需要在Vs Code上进行调试，但是长命令行又让你感到烦恼，那么这篇文章一定会对你有所帮助。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-31f3d50f1c4a8395909181315774d093"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-63f3d50f1c4a839aae25017fb68b749f" data-id="63f3d50f1c4a839aae25017fb68b749f"><span><div id="63f3d50f1c4a839aae25017fb68b749f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#63f3d50f1c4a839aae25017fb68b749f" title="调试场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">调试场景</span></span></h3><div class="notion-text notion-block-b2c3d50f1c4a8231988401541b12e338">在Vs Code上进行python项目调试时，通常要创建launch.json，步骤如下：</div><div class="notion-text notion-block-3973d50f1c4a82fb958e81c842ca77ff"><em><span class="notion-gray">BEGIN 以下内容由AI生成 BEGIN</span></em></div><div class="notion-text notion-block-a5b3d50f1c4a83bca35681394447467a">以下是将长命令行转换为Vs Code的launch.json的步骤：</div><ol start="1" class="notion-list notion-list-numbered notion-block-f063d50f1c4a83dab6c0816893424f47" style="list-style-type:decimal"><li>打开Vs Code，点击调试按钮，并选择“添加配置”。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1843d50f1c4a83e881c0816d4056789c" style="list-style-type:decimal"><li>选择你的程序的语言，这将自动生成一个launch.json文件。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-53e3d50f1c4a825d9157016eeb4648a6" style="list-style-type:decimal"><li>打开launch.json文件，并在“configurations”数组中添加一个新的配置。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-97a3d50f1c4a82048bda818ecefaf02e" style="list-style-type:decimal"><li>为新配置命名，并在“type”属性中指定你的程序的调试器。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-3a03d50f1c4a83778ff3011314fdb7a7" style="list-style-type:decimal"><li>在“args”属性中添加你的程序所需的所有参数。这些参数应该是一个数组，每个参数都应该是一个字符串。</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-e253d50f1c4a82a19c91017df67adcd5" style="list-style-type:decimal"><li>保存launch.json文件。</li></ol><div class="notion-text notion-block-d7f3d50f1c4a82fa86e8013a6e4d654d">现在，你可以使用Vs Code的调试功能来启动你的程序，而不必再输入长长的命令行参数了。只需打开调试选项卡，选择你的新配置，然后点击“启动调试”按钮即可。Vs Code会自动使用你在launch.json文件中指定的参数启动你的程序。</div><div class="notion-text notion-block-fea3d50f1c4a82daa35301dd110888f1"><em><span class="notion-gray">END AI生成 END</span></em></div><div class="notion-blank notion-block-da13d50f1c4a832780a08140b2ec514f"> </div><div class="notion-text notion-block-6ee3d50f1c4a82bba26201a78d0dc4f1">假如我在尝试调试一个<a class="notion-link" href="https://github.com/Megvii-BaseDetection/YOLOX" target="_blank" rel="noopener noreferrer">YOLOX项目</a>，其运行时的命令行是：</div><div class="notion-text notion-block-1b43d50f1c4a8366bb1f01dc612fab4b">我按照上面的配置步骤得到launch.json：</div><div class="notion-blank notion-block-4983d50f1c4a824b9b5001ea6cc677f8"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1833d50f1c4a838192e7814793d67958" data-id="1833d50f1c4a838192e7814793d67958"><span><div id="1833d50f1c4a838192e7814793d67958" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1833d50f1c4a838192e7814793d67958" title="脚本自动转换"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">脚本自动转换</span></span></h3><div class="notion-text notion-block-3b73d50f1c4a8234b75881be412e7b81">由于我个人经常需要调试各种长命令行，每次都按照上述方式创建launch.json的话，太浪费时间了（自己太懒）。因此撸了一个python脚本，来实现自动将命令行转成launch.json来进行调试：</div><div class="notion-text notion-block-3b43d50f1c4a820ab50581c813025b6c">使用示例（假设脚本命名为launch_json_generator.py，且在Vs Code工作区根目录）：</div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>