<?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, 09 May 2025 15:02:26 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en-US</language>
        <copyright>All rights reserved 2025, 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-1420508adf264dc08756e0de12a2d2e5"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-07284ad557cf4da49826f8feb52af9a5">可主要参考：</div><div class="notion-text notion-block-79c5b2a4a5504187bcbe8f3ced39a063"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/670790519">https://zhuanlan.zhihu.com/p/670790519</a></div><div class="notion-text notion-block-aec1b3df7b404f53bb8753160d59a707">进行配置，只不过Mac上需要下载MacTex，Windows可以按指示下载TexLive或者CTAN。</div><div class="notion-text notion-block-7637b74cff2248cfaf4e239da5d184d4">Mac上使用skim作为论文pdf的阅读器，并进行跳转，可参考以下两篇文章：</div><div class="notion-text notion-block-d9d0ae4f7038464ca9748d04c9347da0"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.jianshu.com/p/6f2e385c6653">https://www.jianshu.com/p/6f2e385c6653</a></div><div class="notion-text notion-block-3ec1117ec91a4137a642bc1adc12113b"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/570559163">https://zhuanlan.zhihu.com/p/570559163</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-66e8855e656143189808a2b087126a1e" data-id="66e8855e656143189808a2b087126a1e"><span><div id="66e8855e656143189808a2b087126a1e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#66e8855e656143189808a2b087126a1e" 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-c1010a8a78914bf9aa7761a738c754bf"><li>去清华源下载<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/mac/mactex/mactex-20230314.pkg">MacTex</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-e6ab7c14de7a42b3afbf9a1dcc4e0675"><li>VSCode中安装Latex Workshop、grammarly插件</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-fb98b5195c7a404a8adb5d4384b2367c"><li>将下列对应配置添加到VSCode的settings.json和keybindings.json中，</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-01fa45561c7148678f3cb6b03cd74f04"><li>常用快捷操作：</li><ol class="notion-list notion-list-numbered notion-block-01fa45561c7148678f3cb6b03cd74f04"><ul class="notion-list notion-list-disc notion-block-52ff5c87c396475aad57b07fcdc11e17"><li>编辑器里：Alt+b进行编译（或保存自动编译）</li></ul><ul class="notion-list notion-list-disc notion-block-71b3320ec6074b0daadcf18131ea4c72"><li>编辑器里：Alt+j跳转到当前latex代码所对应的PDF位置</li></ul><ul class="notion-list notion-list-disc notion-block-ada888204ee444b1a194a7500ba3f706"><li>PDF预览页面里：鼠标双击PDF某位置，跳转到该位置对应的latex源码。</li></ul></ol></ol><div class="notion-blank notion-block-23d8eb4dbb4e44a1928ed3aedb83c91f"> </div><div class="notion-text notion-block-3570404d1fe44f05b54d158599e9fac6"><code class="notion-inline-code">settings.json</code></div><div class="notion-text notion-block-05abd9f0606643fe80e9ced877ef2fde"><code class="notion-inline-code">keybindings.json</code></div><div class="notion-text notion-block-99160ab957f1447295c1f6ddfc3af2c4">参考：</div><ol start="1" class="notion-list notion-list-numbered notion-block-4c2bd4c7a1cb474b9b409f5e4864a5c2"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/670790519">https://zhuanlan.zhihu.com/p/670790519</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-c0a06777cb5e4c8e829532ce5bf6004c"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.jianshu.com/p/6f2e385c6653">https://www.jianshu.com/p/6f2e385c6653</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2c36f021a3864a42911dbae9a2a94048"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/570559163">https://zhuanlan.zhihu.com/p/570559163</a></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-15e66996b42b46489732d56f4c49d7c6"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://code.visualstudio.com/docs/getstarted/keybindings#_running-multiple-commands">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-9010f6a829eb4f309f7111aac4bc1ae6"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-6f3fdd25084f4a93a5488478fe827346">FreshRSS是一个自托管的RSS和Atom feed聚合器。它轻便易用，功能强大，可定制。它是一个多用户应用程序，具有匿名阅读模式。它支持自定义标签。它有一个用于（移动）客户端的API，以及一个命令行界面。</div><details class="notion-toggle notion-block-3b3ea74d130c4a96bfd63dea6b7ef6e6"><summary>展开更多</summary><div><div class="notion-text notion-block-437fadd9923f496f9f2e5741b4a77dee">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-82f4e1701ec34ec5b7ebee28e4468e22" data-id="82f4e1701ec34ec5b7ebee28e4468e22"><span><div id="82f4e1701ec34ec5b7ebee28e4468e22" class="notion-header-anchor"></div><a class="notion-hash-link" href="#82f4e1701ec34ec5b7ebee28e4468e22" 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-c66d95ffdefc48db888190aaab865eac"><code class="notion-inline-code">vim docker-compose.yml</code>新建docker-compose.yml文件（参考官方提供的<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/FreshRSS/FreshRSS/blob/edge/Docker/freshrss/docker-compose.yml">compose</a>）：</div><div class="notion-text notion-block-a4cf4ae75e034a229c01e85ca1238625">记得更改volumes字段的路径， 如果你不需要代理，请删除http_proxy、https_proxy、no_proxy三个变量。下面下载镜像并启动容器：</div><div class="notion-text notion-block-7f9949a7e1dc4c5a8032ee477f40c0ce">去宝塔添加静态网站绑定自己的域名<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-9a59d25098a8428db7ee844ea8dc1fba" data-id="9a59d25098a8428db7ee844ea8dc1fba"><span><div id="9a59d25098a8428db7ee844ea8dc1fba" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9a59d25098a8428db7ee844ea8dc1fba" 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-2ade0c7f643549959d4ef729b4994c75">打开域名<code class="notion-inline-code">xxx.yourdomain.com</code>进行配置，数据库选择SQLite，安装。</div><div class="notion-blank notion-block-c0f0ee930ae64e66b4671566c6c09f3f"> </div><div class="notion-text notion-block-93ede7f7d8094ac98a13dfd3e78641c2">下面为第三方app配置api密钥：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1d3992236b5144d58e4a94ac4a7dc117"><li>右上角⚙️ → 管理→认证，勾选以下选项：</li><ol class="notion-list notion-list-numbered notion-block-1d3992236b5144d58e4a94ac4a7dc117"><ul class="notion-list notion-list-disc notion-block-a9ea9cc0401e411b82f1ef94230b7567"><li>✅ 允许不安全的自动登陆方式: xxxx</li></ul><ul class="notion-list notion-list-disc notion-block-f9b179eba32e44299973e31b11c27e31"><li>✅ 允许 API 访问 （用于手机应用）</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-ca82b3ea5bbc44368f6b7937033f1b95"><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-d9eb843325ee433da5c817d887465028" data-id="d9eb843325ee433da5c817d887465028"><span><div id="d9eb843325ee433da5c817d887465028" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d9eb843325ee433da5c817d887465028" 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-154b9b7f86954e148ee586229b4c2453"><li>打开NetNewsWire -&gt; Settings -&gt; Accounts -&gt; 点击左下角的➕ -&gt; 选择Self-Hosted的FreshRSS：</li><ol class="notion-list notion-list-numbered notion-block-154b9b7f86954e148ee586229b4c2453"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0cc62e69c77b45cc9dbce48a7a665196"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://img.idzc.top/picgoimg/2023/11/07/17_02_34-1699376554373.png?t=0cc62e69-c77b-45cc-9dbc-e48a7a665196" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-efd8826a42494884aa514c928ca22ff7"><li>填写如下信息：</li><ol class="notion-list notion-list-numbered notion-block-efd8826a42494884aa514c928ca22ff7"><ul class="notion-list notion-list-disc notion-block-005bde2c27ea4fd39d7b5357a3128bb6"><li>username：你设置的FreshRSS用户名</li></ul><ul class="notion-list notion-list-disc notion-block-804ca054a9e243ce9fd94825571ecc59"><li>password：api密码</li></ul><ul class="notion-list notion-list-disc notion-block-09ead927ad8c4316ac435c505830b3ee"><li>API URL：上述拼接好的api地址</li></ul></ol></ol><div class="notion-text notion-block-9b6e2c9ee9cd4eb79a605eb461ef4cdd">这样就可以通过NetNewsWire来浏览FreshRSS的订阅了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-604c02c697a3450ab0ee43795cd0b6b1" data-id="604c02c697a3450ab0ee43795cd0b6b1"><span><div id="604c02c697a3450ab0ee43795cd0b6b1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#604c02c697a3450ab0ee43795cd0b6b1" 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-a5f23d156c7044758ddfb8a3cc95f8dd">RSSHub可以为一些不存在订阅链接的网页添加订阅链接，并且可以</div><div class="notion-text notion-block-8e165b28e0ae480e92948dcf1e3eba3a">一键导入到FreshRSS。</div><ol start="1" class="notion-list notion-list-numbered notion-block-45f5f9394bf8464d9ff9188cd47222db"><li>先按照<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://docs.rsshub.app/install/#docker-compose-deployment">官方教程</a>部署RSSHub，并获取部署的地址（绑定域名）。</li><ol class="notion-list notion-list-numbered notion-block-45f5f9394bf8464d9ff9188cd47222db"><blockquote class="notion-quote notion-block-c7f5afc5b21a4919aa60a34b5eb97878"><div>注：这里建议使用diygod/rsshub:chromium-bundled镜像，并按照说明注释掉 marked所在的行（实测这样捕获订阅链接成功率更高）</div></blockquote></ol></ol><div class="notion-text notion-block-5e5fe6dd03c64525ad90bfa3bdd512d7">将上述中的10.0.5.1改为docker网关（通常为172.17.0.1，通过ifconfig docker0查询），然后拉取镜像并运行容器：</div><div class="notion-text notion-block-93074ede3e2a47e59bfbb3dd8bf26287">同样地，通过反向代理绑定域名到<code class="notion-inline-code">http://127.0.0.1:1200</code>。</div><ol start="1" class="notion-list notion-list-numbered notion-block-cdf60b4e8de4465ca082888bc4a15a45"><li>安装<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/DIYgod/RSSHub-Radar">RSSHub-Radar浏览器插件</a>，将上述地址填入插件设置页面的<code class="notion-inline-code">自定义 RSSHub 域名</code>。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-f8b6bc70d17b458cad71d23eea256e25"><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-a92c4108a1a747ddb8343430e028163c">这样就可以通过点击浏览器导航栏的RSSHub-Radar图标快速将当前网页的订阅链接添加到FreshRSS中，从而通过NetNewsWire浏览。</div><div class="notion-text notion-block-7fb1a78b4bfb41c3bdefdd67ac448c05">参考：</div><ol start="1" class="notion-list notion-list-numbered notion-block-636211936938422b80dda4c442c6341f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.zhheo.com/p/9158a43c.html#%E6%90%AD%E5%BB%BAFreshRSS">https://blog.zhheo.com/p/9158a43c.html#搭建FreshRSS</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-d766845abed04bf3ad6b1fcaa8fdc4e1"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://veryjack.com/technique/docker-install-freshrss/">https://veryjack.com/technique/docker-install-freshrss/</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-5d7f713b39c84c47b9243ef6de5f4ecc"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.bmqy.net/2648.html#%E8%AE%BF%E9%97%AE">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-7d211dabcbb14d69851a0b8f975a5a70"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33f50e3074454de192fffcad20004d37" data-id="33f50e3074454de192fffcad20004d37"><span><div id="33f50e3074454de192fffcad20004d37" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33f50e3074454de192fffcad20004d37" 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-279e82ca547843909bdb60232ed4ef75">需求：</div><ul class="notion-list notion-list-disc notion-block-bbed394d95d848348af4188aa649da2f"><li>Linux主机A，可以访问外网，但是没有公网ip；部署了wandb、ssh或其他程序；</li></ul><ul class="notion-list notion-list-disc notion-block-cb548a66b0514899b54c8dc94c3a8290"><li>个人PC（例如MacOS），可以访问外网，也没有公网ip，与主机A不在同一局域网。希望能访问主机A上的wandb，且通过ssh连接主机A。</li></ul><div class="notion-text notion-block-fb38fa9962f84f7982ba1bc6a51d278a">思路：</div><ul class="notion-list notion-list-disc notion-block-6a24de288b3f4b4b926c71871d0932f0"><li>拥有一台远程Linux服务器B，可以访问外网，且有公网ip（这样主机A和个人PC都可以访问服务器B）。</li></ul><ul class="notion-list notion-list-disc notion-block-8923499e6c964f2cad7509ecf05e8a1a"><li>使用frp来将服务器B当作“代理”：</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-bdc58c4758b24252afbcb7bea00a6e57"><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?t=bdc58c47-58b2-4252-afbc-b7bea00a6e57" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bdd3a12933d4602a82f0f0d0901f99a" data-id="1bdd3a12933d4602a82f0f0d0901f99a"><span><div id="1bdd3a12933d4602a82f0f0d0901f99a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bdd3a12933d4602a82f0f0d0901f99a" 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-a89073f6c0db4ae4bde1299cf7d07e4a">在github上下载相应的服务器端与客户程序：</div><div class="notion-text notion-block-eaf27b12ff1c482f80941fd632aa9d98"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/fatedier/frp/releases">fatedier/frp/releases</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-0bdddfd126ca4c4ca5c32361f5175507" data-id="0bdddfd126ca4c4ca5c32361f5175507"><span><div id="0bdddfd126ca4c4ca5c32361f5175507" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0bdddfd126ca4c4ca5c32361f5175507" 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-39967a45b9c641bbb1623f107542f92d" data-id="39967a45b9c641bbb1623f107542f92d"><span><div id="39967a45b9c641bbb1623f107542f92d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#39967a45b9c641bbb1623f107542f92d" 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-43422d02722d4d2f808ffe7959394755">关注以下文件：</div><div class="notion-text notion-block-594e318933094ff0af96bb075f8a0bbb">前两个文件（s结尾代表server）分别是服务端程序和服务端配置文件，后两个文件（c结尾代表client）分别是客户端程序和客户端配置文件。此时，我们在配置公网服务器，因此修改frps.toml：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-61672a39d8ca4501b0e99e4298013bc9" data-id="61672a39d8ca4501b0e99e4298013bc9"><span><div id="61672a39d8ca4501b0e99e4298013bc9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#61672a39d8ca4501b0e99e4298013bc9" 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-16abac50b4e34351ba3e032243d3f418"><code class="notion-inline-code">vim /etc/systemd/system/frps.service</code></div><div class="notion-text notion-block-1ab1792673ba442db677e5edc798e2c7">并且你需要在防火墙里放行7000、7500这两个端口。</div><div class="notion-text notion-block-afa38452bb2148d0a2adad8cb917ba26">在个人PC上访问 http://服务器ip:7500，就可以看到frp server的状态。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-da90e8c3e88a48bca055225f4c3539d3" data-id="da90e8c3e88a48bca055225f4c3539d3"><span><div id="da90e8c3e88a48bca055225f4c3539d3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#da90e8c3e88a48bca055225f4c3539d3" 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-34f3f7df76c54cfc96d2e78692e59db0" data-id="34f3f7df76c54cfc96d2e78692e59db0"><span><div id="34f3f7df76c54cfc96d2e78692e59db0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#34f3f7df76c54cfc96d2e78692e59db0" 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-77359519857f46108ee03bf00a67cb43">frpc.toml</div><blockquote class="notion-quote notion-block-57cf634161e4410eafd188cbfed224a2"><div>上面的[[proxies]]板块是添加的代理服务</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-4a3b7b7c59d9459eb8088ef208da7c3a" data-id="4a3b7b7c59d9459eb8088ef208da7c3a"><span><div id="4a3b7b7c59d9459eb8088ef208da7c3a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4a3b7b7c59d9459eb8088ef208da7c3a" 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-44c7693147d14db1a3a24d027404e7e1">类似服务器B的操作，这里假设主机A是以普通用户添加systemd自启动。</div><blockquote class="notion-quote notion-block-0d03130586f24d53a7d8562b30392263"><div>如果主机A的普通用户没有开启systemd自启动功能，参考<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://wiki.archlinux.org/title/systemd/User">systemd/User - ArchWiki (archlinux.org)</a>执行<code class="notion-inline-code">loginctl enable-linger </code><code class="notion-inline-code"><em>username</em></code><em>开启。</em></div></blockquote><div class="notion-text notion-block-5963afe661524b83b0b23a70427fc8d9"><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-8d9f110a12ba45009a89921ba3a5cee8" data-id="8d9f110a12ba45009a89921ba3a5cee8"><span><div id="8d9f110a12ba45009a89921ba3a5cee8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8d9f110a12ba45009a89921ba3a5cee8" 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-dc8e34dd2c8b488f8fe148bf949fef99"><li>个人PC通过<code class="notion-inline-code">ssh xxx@服务器ip:221</code>就能通过代理服务器远程连接主机A了。</li></ul><ul class="notion-list notion-list-disc notion-block-e9751c161bf04610a3dff884f684378d"><li>个人PC通过访问<code class="notion-inline-code">http://@服务器ip:1991</code>就能通过代理服务器访问主机A中的wandb服务了。</li></ul><div class="notion-text notion-block-eb7ad0486ad34d5586f89a11ba69a974">参考：</div><ul class="notion-list notion-list-disc notion-block-dbac3c598def4e5d9eec6c0a095f804e"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.cnblogs.com/kxqblog/p/16080477.html">https://www.cnblogs.com/kxqblog/p/16080477.html</a></li></ul><ul class="notion-list notion-list-disc notion-block-886dda8d5a9341bc93d111a0d5f21b63"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://dusays.com/636/">新版本 frp 参考配置分享</a></li></ul><ul class="notion-list notion-list-disc notion-block-b17484d6623943de9101ccad005923e3"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://juejin.cn/post/7293392480452247562">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-90e74ba971d74b3f9b11caca33c166b0"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-1137ac44c7228090b788ed17517baa90"><span class="notion-red">随着软件版本的迭代，该教程已过期。</span></div><div class="notion-blank notion-block-1137ac44c722806ab108eeb391e24477"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-28f2ee6ba3db49b49423f71054a2f80c" data-id="28f2ee6ba3db49b49423f71054a2f80c"><span><div id="28f2ee6ba3db49b49423f71054a2f80c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28f2ee6ba3db49b49423f71054a2f80c" 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-5d377cbd5c9746ea9aa507a0961981d7">和好朋友谈到我的梯子打开ChatGPT有点卡时，好朋友果断把他的梯子订阅链接分享了给我。</div><div class="notion-text notion-block-2d1a95c8b97a42e49cef121b9a70e762">然而填到<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/Fndroid/clash_for_windows_pkg">clash for windows</a>（也称cfw）时报错不支持hysteria协议。查了下，hysteria协议只有<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://clash-meta.wiki/#clashmeta"><b>Clash.Meta</b></a>的core才支持，而cfw原生只支持clash core，而clash core作者<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/Dreamacro/clash/issues/2372">似乎无意支持hysteria协议</a>。</div><div class="notion-text notion-block-3a335aef729e40eba11c4b4e3b52120a">于是我去谷歌了下支持<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://clash-meta.wiki/#clashmeta"><b>Clash.Meta</b></a>的core的客户端，然后就找到了<b>Clash Verge</b>这个软件，和cfw界面有点类似，但配置不太一样。看了它的wiki后，自己折腾了下，感觉配置方式太灵活了，立马推荐给了我好朋友（他似乎用的是换core的cfw，百度有教程的，但我感觉那样不方便后续升级）。下面就记录下折腾结果。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-24a951a180684a27a48b7cc8f2d0575c" data-id="24a951a180684a27a48b7cc8f2d0575c"><span><div id="24a951a180684a27a48b7cc8f2d0575c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#24a951a180684a27a48b7cc8f2d0575c" 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-a7f1d609c5e84a47852f5355b9a53aa6">直接在Clash Verge的<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zzzgydi/clash-verge/releases">release</a>界面下载对应的包，点击安装即可。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-183438ea2b06416a957fc44d6a1eaa77"><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?t=183438ea-2b06-416a-957f-c44d6a1eaa77" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-03e33694a1c1481d85be5135ae4affbe" data-id="03e33694a1c1481d85be5135ae4affbe"><span><div id="03e33694a1c1481d85be5135ae4affbe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#03e33694a1c1481d85be5135ae4affbe" 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-b2126e3a0f534cef973b788f5402db9b"><b>添加订阅链接</b></div><div class="notion-text notion-block-bb5e371f8efd47099a08f44788f892d9">通常打开软件后，在状态栏/任务栏会有一个图标（Clash Verge是没有眼睛的猫猫头），右键猫猫头然后点击Dashboard→Profiles→搜索框输入订阅链接→IMPORT。</div><div class="notion-text notion-block-2e4a6b7c3d78413685ed5ac1f341e68e"><b>开启代理</b></div><div class="notion-text notion-block-91773f5a6d164f33b45b52d2051c4129">右键点击猫猫头，勾选System Proxy和Rule Mode：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1cd90fc7bccd471c980328d4cacbe194"><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?t=1cd90fc7-bccd-471c-9803-28d4cacbe194" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-d97a8e927986405796eee6b2365d88df" data-id="d97a8e927986405796eee6b2365d88df"><span><div id="d97a8e927986405796eee6b2365d88df" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d97a8e927986405796eee6b2365d88df" 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-f36fc1d3b1134d00ac88bad480c1d671"><b>回顾下cfw是怎么配置的：</b></div><div class="notion-text notion-block-592610ea8b1c4b048d4e1911c5e42ba1">右键猫猫头→Dashboard→Settings→Profiles→Parser Edit：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4f112403d988478da246d3e25dd81b15"><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?t=4f112403-d988-478d-a246-d3e25dd81b15" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-46662fed9e2941b0a3f37ac6878cd936"> </div><div class="notion-text notion-block-4f6d3f7ac6ab4f90baafa5d19040e1c9">然后添加规则：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d4177770c869491a8c9422fbf4cea070"><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?t=d4177770-c869-491a-8c94-22fbf4cea070" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-47342683b6534acbb7f08e85522d18a5">保存后，需要Dashboard→Profiles→选中config（即订阅链接产生的选项卡）并点击更新图标（以保证自定义规则添加到了config）。</div><div class="notion-text notion-block-d7a13a606c304c18b88c9d059a44ff13"><b>Clash Verge的配置方式：</b></div><div class="notion-text notion-block-9e34ee7d208541bd86153151462c82ba">参考作者的<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zzzgydi/clash-verge/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97">wiki</a>：</div><blockquote class="notion-quote notion-block-eb25919ce60b4dd5a9ce48d212e0009e"><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-6243d3faabdf424491069accf9a16ddd"><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?t=6243d3fa-abdf-4244-9106-9accf9a16ddd" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-5d095c6e44674904bafb7d56dddc6ce8"> </div><div class="notion-text notion-block-cb1e311779bf453abceef5505f13ae9d">简单来说:</div><ol start="1" class="notion-list notion-list-numbered notion-block-f11cdeb9271447bcb4dae9f11c00b3ce"><li>Remote Type Profile是用来订阅远程链接的，通常机场的订阅地址填写到下图红框中：</li><ol class="notion-list notion-list-numbered notion-block-f11cdeb9271447bcb4dae9f11c00b3ce"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e38bc2a4c1764d19949279d4543074f7"><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?t=e38bc2a4-c176-4d19-9492-79d4543074f7" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-f6d103e9a4084186aae68b4e721c82fd"><li>Local Type Profile其实就是添加本地的config文件：</li><ol class="notion-list notion-list-numbered notion-block-f6d103e9a4084186aae68b4e721c82fd"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6b2469d814da4517a9985efb8f0334e2"><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?t=6b2469d8-14da-4517-a998-5efb8f0334e2" alt="notion image" loading="lazy" decoding="async"/></div></figure></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1d9673044ae849399e7ec855f75e7636"><li>Script Type Profile：个人认为算是Clash Verge与cfw最大的不同之处了吧，它允许用户使用javascript脚本来预处理config（可以是上面的远程订阅得到的config，也可以是本地config文件）</li><ol class="notion-list notion-list-numbered notion-block-1d9673044ae849399e7ec855f75e7636"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cdf29e43253d424fa6746d2ceed3f94c"><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?t=cdf29e43-253d-424f-a674-6d2ceed3f94c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-0ad300ff02224e628d7233fb42ce1dfd">然后点击SAVE，再右键该Profile→Edit File→编写预处理js脚本→SAVE→Enable：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-257aa98ad19d4e33816aa68e70862dd6"><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?t=257aa98a-d19d-4e33-816a-a68e70862dd6" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-7994eb2cc80848238e49974c90cb537e">我会在后面分享一个预处理config脚本，用来添加一个名字叫OpenAI的proxy group（专门为OpenAI/ChatGPT网站选节点）。</div></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-b12db02e8f9b4dad809f646f23dce39e"><li>Merge Type Profile。作者说这是源于cfw中的配置方法而设计的。即方便将cfw配置的Parses迁移到Clash Verge中。</li><ol class="notion-list notion-list-numbered notion-block-b12db02e8f9b4dad809f646f23dce39e"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d0c69628b03a414ba029246f66856b3a"><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?t=d0c69628-b03a-414b-a029-246f66856b3a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-5802647d74a143068942ecd3f7cf9e7d">然后同样是：右键该Profile→Edit File→填写规则→SAVE→Enable：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-8bc13ba88ca44de2b25b083ad5cc6709"><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?t=8bc13ba8-8ca4-4de2-b25b-083ad5cc6709" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-68b11297bb9a40c984dfd1f9e383458b">作者在<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zzzgydi/clash-verge/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97">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-b661d340b0634ecbb2dd529c3673222d"><b>总的来说：</b></div><ul class="notion-list notion-list-disc notion-block-aa750373d6da49a7944052c364f32d8c"><li>Clash Verge的配置就是进行上面134或者234步骤；</li></ul><ul class="notion-list notion-list-disc notion-block-6eeef461bbf04f668a00702cda462c0d"><li>如果你只想简单的添加订阅链接/本地config文件，只需要进行1或2的步骤；</li></ul><ul class="notion-list notion-list-disc notion-block-5a50f4764cd7426a8d07dfe164c2af88"><li>如果还需添加一些规则的话，额外进行步骤4；</li></ul><ul class="notion-list notion-list-disc notion-block-203a777855354230b87b55851217f6ba"><li>添加一些复杂的操作的话，可能额外需要进行步骤3。</li></ul><ul class="notion-list notion-list-disc notion-block-fd8cbcb3c506494ca671e4b1df49d320"><li>注意，在配置完规则或者脚本后，建议重新更新下订阅的Profiles，以保证规则和脚本生效。</li></ul><div class="notion-text notion-block-e4e24bbb4cf143dab97206733a2076c4">建议在配置完规则后，Dashboard→Rules→输入关键字筛选（例如输入open）→检查是否有对应规则：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7b441a0ef475412bbb2459ac5a4c4d26"><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?t=7b441a0e-f475-412b-bb24-59ac5a4c4d26" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-block-a3af86044f8a4745ac7f93292ba30e97" data-id="a3af86044f8a4745ac7f93292ba30e97"><span><div id="a3af86044f8a4745ac7f93292ba30e97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a3af86044f8a4745ac7f93292ba30e97" 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-429e45e47472464dab4dd699ad5f92da" data-id="429e45e47472464dab4dd699ad5f92da"><span><div id="429e45e47472464dab4dd699ad5f92da" class="notion-header-anchor"></div><a class="notion-hash-link" href="#429e45e47472464dab4dd699ad5f92da" 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-8f4f225038b9436d9ed2537c6178b9a0">用来添加一个名字叫<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-c73032741ee34e188977c333a74fc8f8">为什么有这个脚本？因为之前用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-a92282f2e23d40ba847857613350db86" data-id="a92282f2e23d40ba847857613350db86"><span><div id="a92282f2e23d40ba847857613350db86" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a92282f2e23d40ba847857613350db86" 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-892427a336174b69807b621311a2804a">指定一些白名单，如局域网的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-59bd65ea37b24445a07db31719700c9a"><em>这个yaml文件中没有被配置的每个字段的下一行必有一个空行，否则报错。（由于本站的js脚本，导致最后一个空行被清除了）</em></div><div class="notion-blank notion-block-78a24cef70924fa8ba704eb8962b5487"> </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-9560982f02c54d45a77a735537dcd39e"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-687dd9002cc64a39a91290233f553d09">由于网上各位大佬都做了足够多的介绍，我这里当个缝合怪，顺便说说自己的理解。若有疏漏，请斧正！</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-748411f8047c4781bde4f0c9ef614fae" data-id="748411f8047c4781bde4f0c9ef614fae"><span><div id="748411f8047c4781bde4f0c9ef614fae" class="notion-header-anchor"></div><a class="notion-hash-link" href="#748411f8047c4781bde4f0c9ef614fae" 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-25d2120abfd14454b95180f60d4d55ed">什么是<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-18c4fd8892404269b167e297ae9dafcb">什么是<span class="notion-red"><b>optimal transport distances</b></span>呢？我们不妨说说其中很常见的<span class="notion-red"><b>推土机距离</b></span>。</div><div class="notion-text notion-block-7191169723bd44c986892e90d33cd2e8">什么又是<b><span class="notion-red">推土机距离</span></b>呢？那下面就做个简单的介绍。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26935bb5e8c845e8a70e27bced7be7d3" data-id="26935bb5e8c845e8a70e27bced7be7d3"><span><div id="26935bb5e8c845e8a70e27bced7be7d3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26935bb5e8c845e8a70e27bced7be7d3" 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-fa5eb46d7277486fadc84d35c6233a8a"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://en.wikipedia.org/wiki/Earth_mover%27s_distance">Wikipedia</a>的对推土机距离的解释是：</div><blockquote class="notion-quote notion-block-602369130100446d85790251e46f8417"><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 target="_blank" rel="noopener noreferrer" class="notion-link" href="https://en.wikipedia.org/wiki/Frequency_(statistics)">frequency distributions</a>, <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://en.wikipedia.org/wiki/Density_(disambiguation)">densities</a>, or <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://en.wikipedia.org/wiki/Measure_(mathematics)">measures</a> over a region <em>D.</em></div></blockquote><div class="notion-text notion-block-2ce52ca95b144d9b994e884b4daed7e4">简单来说，推土机距离是衡量两个分布之间的距离的一种方法。它的基本思想是将一种分布通过一定的代价转换为另一种分布，计算这个代价就是推土机距离。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3b15bec0578b479ab8bd9da3f8903b31"><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?t=3b15bec0-578b-479a-b8bd-9da3f8903b31" alt="对于两个分布和，可以将它们想象成仅堆叠不同的两堆土，怎么样花最低代价将左边的土推成右边的土呢？" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">对于两个分布<!-- -->和<!-- -->，可以将它们想象成仅堆叠不同的两堆土，怎么样花最低代价将左边的土推成右边的土呢？</figcaption></div></figure><div class="notion-text notion-block-33b90298c4f14144a3d38c795dc83c4e">你可能了解过度量两个分布的其他距离，如欧氏距离、KL散度、JS散度以及其他更复杂的距离，但是这类距离方式并未考虑两个分布之间的联合分布。而推土机考虑了：</div><div class="notion-text notion-block-0a42cbf1297b45b3ab647690ae0b31a7">其中，<!-- -->是所有联合分布的集合，其边缘分布分别为<!-- -->。</div><div class="notion-text notion-block-6e2ad388b6a14c62922e1762a55d06a0">求解这样的式子，得到联合分布<!-- -->，也就是最终的推土方案：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7041d2344680401191e7e1ce93f087b7"><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?t=7041d234-4680-4011-91e7-e1ce93f087b7" 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-6d7b387a584a4490bd9fbe03faf200c6" data-id="6d7b387a584a4490bd9fbe03faf200c6"><span><div id="6d7b387a584a4490bd9fbe03faf200c6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6d7b387a584a4490bd9fbe03faf200c6" 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-0d5da804235c498aadfcfc68ec9fe12b">介绍完推土机距离后，回到optimal transport distances上。</div><div class="notion-text notion-block-7e0243f1088148248ad8ebbb66444f8e">假设有这样的交通运输场景<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#04e3fb8d7d064fcf9fcc2ecee4644672">⁵</a>：有<!-- -->个仓库，<!-- -->个工厂，我们需要将某种物品从各个仓库运送到各个工厂（允许一个仓库的物品运往多个工厂，且允许一个工厂接受多个仓库的运货），希望找到最优运输方案来最大限度地降低运输成本，这便是最优传输问题。</div><div class="notion-blank notion-block-ed17809999754291837ff55792a225ab"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-33818e43fb0d46f5a5cf537741a946fb"><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?t=33818e43-fb0d-46f5-a5cf-537741a946fb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-119f82d75fdb4e929426043608d48f22"> </div><div class="notion-text notion-block-1bf445ef187343109f7b9a8dc1faea45">假设第<!-- -->个仓库存货量是<!-- -->，第<!-- -->个工厂的需求量是<!-- -->，仓库<!-- -->到工厂<!-- -->的运输距离是<!-- -->，<!-- -->表示从第<!-- -->个仓库运货到第<!-- -->个工厂的货物量，那么求解这样的问题其实是在求解如下的线性规划：</div><div class="notion-text notion-block-8db0fb698baf453d9b9d1bbfff12d06b"><b>和推土机距离的联系：</b></div><div class="notion-text notion-block-6ea992ca73044609b8b8c1dfd9c21306">（下面均假设<!-- -->，理论上可推广至<!-- -->的情形），仓库和工厂可看成两堆不同的土，各个仓库的存储量情况和各个工厂的需求量情况可以看作两个分布，各个仓库和各个工厂的距离可以看作为两个分布（直方图）各个区域间的距离。</div><div class="notion-blank notion-block-31440b37a05d46b0be05fb1144877771"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b6b86f14fdaf4d5b97f18d4973f3fe36"><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?t=b6b86f14-fdaf-4d5b-97f1-8d4973f3fe36" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-a3ff8a8337de400aa71615c96f715b8b"> </div><div class="notion-text notion-block-9b14605c1c2948d48f9c8b763d4e2b45">上面通过求解(2)式获得的<!-- -->就是最优传输距离，下文称之为原始optimal transport distance。</div><div class="notion-text notion-block-0ee0b1723433494787a67ad66221cdb2">然而一些工作在(2)式的基础上加了一些约束，使其便于求解，因此就有了不同“版本”的距离，统称为optimal transport distances。例如常见的有：</div><ol start="1" class="notion-list notion-list-numbered notion-block-aa7c607cad524c889803094ce4f65945"><li><b>Wasserstein Distance </b>(也称推土机距离)：用于WGAN中，使用Lipschitz正则化(1)式的对偶形式中引入的函数。不过一些人认为WGAN中计算的分布间的距离并不是严格意义上的Wasserstein Distance。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-25c95e16437b48c8b6c2d8b8787914d8"><li><b>Sinkhorn Distance:</b> 它是Wasserstein distance的一个近似算法，使用了熵正则化的方法实现计算上的效率。通过引入熵惩罚项，可以将概率分布之间的optimal transport问题转变为具备良好计算性质的解析表达式。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-94874bcafd4e42a79624276d57164e8d"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://openreview.net/forum?id=S1m6h21Cb"><b>Cramer Distance</b></a><b>:</b> 一种用于测量两个概率分布之间距离的方法，它是基于分布函数的平方差来定义的。Cramer Distance的提出是为了解决Wasserstein Distance在梯度计算中存在偏差的问题。</li></ol><div class="notion-text notion-block-ecb85428ba784a0fb0daaf1690f34ddc">而今天本文的主角是“Sinkhorn Distance”，下面开始介绍。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ff246cd8d996402b981c8d4ba78d3876" data-id="ff246cd8d996402b981c8d4ba78d3876"><span><div id="ff246cd8d996402b981c8d4ba78d3876" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ff246cd8d996402b981c8d4ba78d3876" 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-31c8a137923a453aa2970a4b0960be38">为什么文献<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#f50f688882954dd1b170467685cef676">[1]</a>会提出Sinkhorn Distance呢？</div><div class="notion-text notion-block-03b7f32f821c44129b8be63889dffe59">其主要针对原始optimal transport distance的时间复杂度高这一问题，提出了一种最大化熵的约束方案来使传输方案不那么稀疏，并且降低了计算复杂度。具体而言，原始optimal transport distance存在的缺陷：</div><ul class="notion-list notion-list-disc notion-block-015c7a91e145426ebc2fff41ce63e2e0"><li><span class="notion-red"><b>计算复杂度高</b></span>：在针对两个d维的直方图的optimal transport distance时，至少需要<!-- -->。当测度空间嵌入到<!-- -->，在高维直方图上计算该距离的成本是非常巨大的。</li></ul><ul class="notion-list notion-list-disc notion-block-536f50b55dcf46fe84a4e7c26b689fcd"><li><span class="notion-red"><b>稀疏性</b></span>：由于计算原始optimal transport distance的是在求解线性规划问题，因此最优解通常出现在可行域的顶点处，落在顶点处的解通常是比较稀疏的。例如对于两个<!-- -->维直方图，使用线性规划求解的传输方案为<!-- -->的稀疏矩阵，且最多有<!-- -->个非零元素，从概率角度看，如果<!-- -->，具有很少的<!-- -->能使得<!-- -->。即一个仓库偏向于只为少量（甚至一个）仓库供货。这样的稀疏可能并不符合实际场景，以至于计算得到的并非最优解。</li></ul><div class="notion-text notion-block-ceb762c0cabc43c3ac12e1130c3af57a">Sinkhorn Distance便是针对这两个问题提出的一种lightspeed computation、sufficient smoothness的optimal transport distance。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-bc00f1cad07f4da2a8bcc1b8fea01b73" data-id="bc00f1cad07f4da2a8bcc1b8fea01b73"><span><div id="bc00f1cad07f4da2a8bcc1b8fea01b73" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bc00f1cad07f4da2a8bcc1b8fea01b73" 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-5cc8e8ef31c44db3b49c6ea779ee16df">这里对上面提到的原始optimal transport distance做一个形式化描述：</div><div class="notion-text notion-block-3f95540c80e64bbbaa031abe5416d247">对于在单纯形<!-- -->中的两个概率向量<!-- -->和<!-- -->，记<!-- -->到<!-- -->的所有传输方案集合为<!-- -->：</div><div class="notion-text notion-block-ffdb2e0c00ea4746aa0ca89bf8e71d51">表示全1的列向量，<!-- -->包含了行和列总和分别为<!-- -->和<!-- -->的所有非负<!-- -->矩阵。对于取值均在<!-- -->的两个多项随机变量<!-- -->和<!-- -->，每个变量分别具有分布<!-- -->和<!-- -->，<!-- -->包含了所有关于<!-- -->的联合分布。对于<!-- -->，有<!-- -->。</div><div class="notion-text notion-block-d72dc2496d1f47c99f2ae8bc2be1d38f">那么对于<!-- -->和<!-- -->间的optimal transport distance定义为：</div><div class="notion-text notion-block-427c2abef253476b9b1f2144493ccd1b">其中<!-- -->代表Frobenius dot-product（矩阵对应元素相乘的和，相当于对Hadamard product的结果求和）。在有些论文中，上述的表示可能是：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-6ad7d9740461406181253852c10b67d0" data-id="6ad7d9740461406181253852c10b67d0"><span><div id="6ad7d9740461406181253852c10b67d0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6ad7d9740461406181253852c10b67d0" 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-4824d988dc984efe9f7cb4be8be64a97">Sinkhorn Distance提出将(4)中的<!-- -->进行smoothing，在机器学习领域很容易想到的就是最大化熵，即最大化<!-- -->，下面先探讨一下<!-- -->的上界。</div><div class="notion-text notion-block-af88d74d64854b8c9bc602ce0180c3d1">符号说明：</div><div class="notion-text notion-block-a0b205b01f3e4dbdb3c02f1259edaf9a">由<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#483792e4ea844edd9ebe20a6b006ce2f">[7]</a>中的公式<!-- -->知：</div><div class="notion-text notion-block-6190dbdfb81a4bdcaa853819b5f48607">因为<!-- -->是<!-- -->和<!-- -->的联合分布，那么根据(6)有：</div><div class="notion-text notion-block-d21a18783d54439587c36deafa36c262"><span class="notion-red">因此</span><span class="notion-red"></span><span class="notion-red">的上界是</span><span class="notion-red"></span>。显然h(P)不能严格靠近其上界（会导致过度平滑），且<!-- -->与上界的距离不应超过一定阈值<!-- -->（否则会过度稀疏），即：</div><details class="notion-toggle notion-block-e1762a18b1ab4a9b9451b2564f04e4af"><summary>且易证：<!-- -->，<!-- --> ，</summary><div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-28dd449250f94e46a8e6ebcbe8383f54"><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?t=28dd4492-50f9-4e46-a8e6-ebcbe8383f54" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-302742af7c7046a7bbf86fb29e28c910"><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?t=302742af-7c70-46a7-bbf8-6fb29e28c910" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-30e6da474f9a49aa84059fe9adfa52ae"> </div></div></details><div class="notion-text notion-block-6d8b55e365d44d4d974cf9e72ec5f7d8">因此有：</div><div class="notion-text notion-block-f89a1857847b420c8307e612ae9354d9">用(9)来约束<!-- -->得到：</div><div class="notion-text notion-block-da58979204544d468db9dfce6a72cf9d">其实直观上看，这个约束就是将运输方案<!-- -->和<!-- -->拉近。（那么这个<!-- -->到底是什么呢？见补充部分。）</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-8d86d1ea74a641da93c3913baa1d69dc" data-id="8d86d1ea74a641da93c3913baa1d69dc"><span><div id="8d86d1ea74a641da93c3913baa1d69dc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8d86d1ea74a641da93c3913baa1d69dc" 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-393b20ffa66b40f4a6de02743b5cee7e">根据上述，可以得到Sinkhorn Distance的定义：</div><div class="notion-text notion-block-dbac95f071e249279fc2ab568e9fd58e">一般有了定义，会探讨有哪些性质，这里就不展开了，有兴趣的可阅读文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#950b580dc4c045a7ae8af81fa171161b">[1]</a>。</div><div class="notion-text notion-block-31a735eabe6a47aa8700814ae8c3a110">简单来说，在<!-- -->不是特别小或者特别大时，满足对称性和三角不等式。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d1c4d297917547cd9b0df3144493bafd" data-id="d1c4d297917547cd9b0df3144493bafd"><span><div id="d1c4d297917547cd9b0df3144493bafd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d1c4d297917547cd9b0df3144493bafd" 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-f747740ddee146358af277b022f212aa">直接求解(11)式是比较棘手的，可以考虑(11)式的对偶形式：</div><div class="notion-text notion-block-457ba6115bf64da688ccf9c6400f3a6e">对(11)中的每个<!-- -->，都能在(12)中找到合适的<!-- -->使得
<!-- -->成立。如此便将较复杂的约束<!-- -->转换为惩罚项<!-- -->。这里的<!-- -->被文献<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#f50f688882954dd1b170467685cef676">[1]</a>作者称为<span class="notion-red"><em>dual-Sinkhorn divergence</em></span>。</div><div class="notion-text notion-block-4d0218b971a840ecaa0f137181e968aa">这里文献[1]作者给了一个描述原始optimal transport distance <!-- -->、Sinkhorn distance <!-- -->以及dual-Sinkhorn divergence <!-- -->之间关系的示意图：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-96666174cc4246e8ba4e94e3afefc14b"><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?t=96666174-cc42-46e8-ba4e-94e3afefc14b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-a9e8c561461b487d902906e714ad62d8">由上图看出，可以从0逐渐增大<!-- -->，来找到满足<!-- -->的<!-- -->。然而在实际使用中，这样去找<!-- -->是不切实际的（会带来很多计算量），因此通常靠先验来选择可能合适的<!-- -->。</div><blockquote class="notion-quote notion-block-e6efffa747cc4ba68c388651d416db00"><div>⚠️从公式(12)中可以看出，（求解公式(12)的过程中）<!-- -->的熵随着（预定义的）<!-- -->的增大在递减。也就是说，如果选了太大的<!-- -->会导致公式(12)得到的<!-- -->的熵偏低，因此<!-- -->不宜太大。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5367fa00b8ff4a68b4e59c7634b38797" data-id="5367fa00b8ff4a68b4e59c7634b38797"><span><div id="5367fa00b8ff4a68b4e59c7634b38797" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5367fa00b8ff4a68b4e59c7634b38797" 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-775df1360c354962826efa528d8a65fc">得到(12)形式的dual-Sinkhorn divergence后，使用拉格朗日乘子法，可以得到：</div><div class="notion-text notion-block-991f1b9bd30a413d8d5d02d1265306f7">其中<!-- -->是两个等式约束的系数。对<!-- -->求导并令<!-- -->，得：</div><div class="notion-text notion-block-525a8b897a824d37b9de161e1aaf03b2">注：这里文献<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#f50f688882954dd1b170467685cef676">[1]</a>作者可能是将<!-- -->对数的底数当作<!-- -->来进行处理的。</div><div class="notion-text notion-block-63bb8f370c0144c0987c9a3d7872dbf0">根据(14)可知<!-- -->应该有这样的形式:</div><div class="notion-text notion-block-2f34c304787b46f3b8b3e01e24f48b01">其中<!-- -->，中<!-- -->是待求的两个向量。</div><div class="notion-text notion-block-90bd1f789da9487a8e6dd3fe3db69214">根据文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#8278ed790fa74a099b3142e17e473218">[8]</a>所提出的<span class="notion-red"><b>Sinkhorn’s theorem</b></span>可知：<!-- -->中有且仅有唯一的能表示成<!-- -->的矩阵，并且可以通过Sinkhorn’s fixed point iteration来求解<!-- -->：</div><div class="notion-text notion-block-fc24c65b6335476da19ebefd175ca3af">文献<a class="notion-link" href="/3bfed8c194e94720b3f3f08c6762636c#950b580dc4c045a7ae8af81fa171161b">[1]</a>作者给出了Matlab风格的伪代码：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-51f5a539431640c7886f8740ad3eb36c"><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?t=51f5a539-4316-40c7-886f-8740ad3eb36c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-22e0782b7e0a478194587ee68f905ba6">原文还给了其他有趣的证明和说明，有兴趣的可以阅读原文。这里就暂不往后阐述了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-395b8dada6e4485989dd0d186c1e963a" data-id="395b8dada6e4485989dd0d186c1e963a"><span><div id="395b8dada6e4485989dd0d186c1e963a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#395b8dada6e4485989dd0d186c1e963a" 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-2aa272a08a7941feb23c6973cea08383">在参考大佬们的Sinkhorn distance实现后，为了接近原文伪代码，我稍做了修改后的Python代码：</div><div class="notion-text notion-block-8c24e99aa11649d4a676db5d04dbb205">完整demo见<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zfhxi/Sinkhorn-Distance-Python">zfhxi/Sinkhorn-Distance-Python</a>。</div><div class="notion-text notion-block-6d080820d4c0435e9fdb30859006169b">下面是该demo的可视化结果：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3885c90b093548f9bbdccb7d956e5dc1"><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?t=3885c90b-0935-48f9-bbdc-cb7d956e5dc1" 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-cebbdec230f94c68bfb7c71ee3331570">上图可以看出<!-- -->是相当光滑的。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1dd590a503b84b82811e982adcc4b9b2"><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?t=1dd590a5-03b8-4b82-811e-982adcc4b9b2" alt="“使用线性规划求解的EMD运输方案”和“Sinkhorn运输方”的比较" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">“使用线性规划求解的EMD运输方案”和“Sinkhorn运输方”的比较</figcaption></div></figure><div class="notion-text notion-block-1df10e6512174e32ad7924ef61c15db8">上图可以看出相比于线性规划求解的运输方案，Sinkhorn distance得到的运输方案更加平滑。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7d071b4cfddf4791bc3dcd73aefb74ea"><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?t=7d071b4c-fddf-4791-bc3d-cd73aefb74ea" 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-bca793b866d64fc88891876cc7da519a">上图可以看到，Sinkhorn将直方图切分成更多的块，那么对应到实际场景，可能带来的问题是：运输货物时需要更多的车辆，或者说需要运输多次……</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1de5747d4a4248478a4c9b1cc7a9d747" data-id="1de5747d4a4248478a4c9b1cc7a9d747"><span><div id="1de5747d4a4248478a4c9b1cc7a9d747" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1de5747d4a4248478a4c9b1cc7a9d747" 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-e0cc674606a44a93ab5440077a7b21a7" data-id="e0cc674606a44a93ab5440077a7b21a7"><span><div id="e0cc674606a44a93ab5440077a7b21a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e0cc674606a44a93ab5440077a7b21a7" 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-c436b8ce68a14b65836c9d0e386b05c9"><li>KL散度不具备对称性且不满足三角不等式，仅考虑边缘分布；</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-729a0cc0fa4441029017231edc652d21"><li>JS散度具备对称性，但在两个分布距离较远（比如均值差异大）时，变成一个常数，且仅考虑边缘分布；</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-6db4037768b44fb49f5df2bcb0ccaad5"><li>EMD对称且两个分布距离较远时仍能有效衡量距离，考虑了联合分布，但其计算复杂度比上面两个距离都要高出很多。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-e88d5e4a94d04e7f926b71b7e7e43f44" data-id="e88d5e4a94d04e7f926b71b7e7e43f44"><span><div id="e88d5e4a94d04e7f926b71b7e7e43f44" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e88d5e4a94d04e7f926b71b7e7e43f44" 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-33672f73cb6b49a9abe381a004bd4a9c">根据<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#ddcd845991794bfa932a6e8a03b203a4">文章[2]</a>的解释并结合上面提到过的例子，<!-- -->意味着：</div><ul class="notion-list notion-list-disc notion-block-85724635a3da488ebac80cd6cbecd29f"><li>只有<!-- -->中数值比较高（较低）的索引<!-- -->和<!-- -->中数值较高（较低）的索引<!-- -->相乘后才能使得<!-- -->更高（更低）；</li></ul><ul class="notion-list notion-list-disc notion-block-a842c5311709404bb56fd20349dda104"><li>并且<!-- -->中数值比较高的索引<!-- -->和<!-- -->中数值较低的索引<!-- -->相乘后并不能使得<!-- -->更高。</li></ul><div class="notion-text notion-block-bbe1bc3286fb420288ddcfd4a240330a">也就是说：</div><ul class="notion-list notion-list-disc notion-block-781b828085274136a59dfd13001ae8cf"><li>对于一些仓库来说，如果它存储量更多，就应该运出更多货物；对于工厂来说，如果它需要更多，就应该从每个仓库那里按比例获得更多。</li></ul><ul class="notion-list notion-list-disc notion-block-50563be7f67a433e8a86de0b622c7bc2"><li>对于货物存储量很多的仓库，它不会主要向需求量少的工厂运输货物。</li></ul><div class="notion-text notion-block-4dcf428e2b4f4540aef0dd33951db116">代表了一种十分光滑的运输方案，见demo中的<a class="notion-link" href="/9560982f02c54d45a77a735537dcd39e#3885c90b093548f9bbdccb7d956e5dc1">可视化图</a>。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-996f9c6553f646408b55780ac45a9656" data-id="996f9c6553f646408b55780ac45a9656"><span><div id="996f9c6553f646408b55780ac45a9656" class="notion-header-anchor"></div><a class="notion-hash-link" href="#996f9c6553f646408b55780ac45a9656" 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-0132668d5b42494e8c89372aa71c554c">什么是不动点迭代法参考：<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/369690237">不动点迭代法—单变量非线性方程近似根matlab求解 - 知乎 (zhihu.com)</a></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d559234cb48e4d18a8f59108d42762e7" data-id="d559234cb48e4d18a8f59108d42762e7"><span><div id="d559234cb48e4d18a8f59108d42762e7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d559234cb48e4d18a8f59108d42762e7" 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-e14b21a3a8314b68b48486b5d9f04b05"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/346795219">当Top-k遇到深度学习 - 知乎 (zhihu.com)</a></div><div class="notion-blank notion-block-364595f633114652acb3572edcf80857"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-f675ec742ead4d50927a540671c5594e" data-id="f675ec742ead4d50927a540671c5594e"><span><div id="f675ec742ead4d50927a540671c5594e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f675ec742ead4d50927a540671c5594e" 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-f50f688882954dd1b170467685cef676"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://papers.nips.cc/paper_files/paper/2013/hash/af21d0c97db2e27e13572cbf59eb343d-Abstract.html">Sinkhorn Distances: Lightspeed Computation of Optimal Transport (nips.cc)</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-ddcd845991794bfa932a6e8a03b203a4"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://amsword.medium.com/a-simple-introduction-on-sinkhorn-distances-d01a4ef4f085">A simple introduction on Sinkhorn distances | by Jianfeng Wang | Medium</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-329d4df5fc7640ad81df908c1f53ebbc"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://vincentherrmann.github.io/blog/wasserstein/">Wasserstein GAN and the Kantorovich-Rubinstein Duality - Vincent Herrmann</a></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-8589685092224705a10b28c68f7e7651"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://kaizhao.net/blog/optimal-transport">https://kaizhao.net/blog/optimal-transport</a></li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-04e3fb8d7d064fcf9fcc2ecee4644672"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhuanlan.zhihu.com/p/527799934">Sinkhorn 距离简单易懂！ - 知乎 (zhihu.com)</a></li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-cee8677ce76c43fabebc53f228d808ff"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://lccurious.github.io/2020/01/30/optimal-transport/">最优传输理论 | Curiousity Hub (lccurious.github.io)</a></li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-483792e4ea844edd9ebe20a6b006ce2f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://staff.ustc.edu.cn/~cgong821/Wiley.Interscience.Elements.of.Information.Theory.Jul.2006.eBook-DDU.pdf">Elements of Information Theory</a></li></ol><ol start="8" class="notion-list notion-list-numbered notion-block-75520d1ece4e46778748f5a08dff760e"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.jstor.org/stable/2040061">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-442b641fdc6c4272b55d048a9fd0c6ff"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130caae7c94d423f9b55c431ca126119" data-id="130caae7c94d423f9b55c431ca126119"><span><div id="130caae7c94d423f9b55c431ca126119" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130caae7c94d423f9b55c431ca126119" 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-c4818581ebb84537a937204a848f2a68">在Vs Code上进行python项目调试时，通常要创建launch.json，步骤如下：</div><div class="notion-text notion-block-909ecdbded3b40bbba933785ee1e45a2"><em><span class="notion-gray">BEGIN 以下内容由AI生成 BEGIN</span></em></div><div class="notion-text notion-block-9a435adbccbd4e1fbbeb76009471107b">以下是将长命令行转换为Vs Code的launch.json的步骤：</div><ol start="1" class="notion-list notion-list-numbered notion-block-a5a44ab435fb471cb519567874752aac"><li>打开Vs Code，点击调试按钮，并选择“添加配置”。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2edd401081a44c6396775b4787bac4fe"><li>选择你的程序的语言，这将自动生成一个launch.json文件。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-ea0fc8b76e814843883abc44bbc1e510"><li>打开launch.json文件，并在“configurations”数组中添加一个新的配置。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-c8cab0482017498a802b568b1950596e"><li>为新配置命名，并在“type”属性中指定你的程序的调试器。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-fccd715e1fe74a9faf72ad5ea599f9ed"><li>在“args”属性中添加你的程序所需的所有参数。这些参数应该是一个数组，每个参数都应该是一个字符串。</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-a74960914a0542b696f54d41967b4cc1"><li>保存launch.json文件。</li></ol><div class="notion-text notion-block-f9aef2b677004e9db53b07be63f30122">现在，你可以使用Vs Code的调试功能来启动你的程序，而不必再输入长长的命令行参数了。只需打开调试选项卡，选择你的新配置，然后点击“启动调试”按钮即可。Vs Code会自动使用你在launch.json文件中指定的参数启动你的程序。</div><div class="notion-text notion-block-5086ad0b73fb4007913757838dc90c00"><span class="notion-gray"><em>END AI生成 END</em></span></div><div class="notion-blank notion-block-56fb8757f2794ddf94d31532ff534d4f"> </div><div class="notion-text notion-block-bb6ce2cfd41d4021814fc56dd11503ab">假如我在尝试调试一个<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/Megvii-BaseDetection/YOLOX">YOLOX项目</a>，其运行时的命令行是：</div><div class="notion-text notion-block-7f7e1685ccae49af98cba545cdbb0457">我按照上面的配置步骤得到launch.json：</div><div class="notion-blank notion-block-5a12c0f01e664f5abb7255119c42fdc5"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6ee1d17bd43e479893cc576d48f30aab" data-id="6ee1d17bd43e479893cc576d48f30aab"><span><div id="6ee1d17bd43e479893cc576d48f30aab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6ee1d17bd43e479893cc576d48f30aab" 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-d2fd576b53c544cd86446f59170cd335">由于我个人经常需要调试各种长命令行，每次都按照上述方式创建launch.json的话，太浪费时间了（自己太懒）。因此撸了一个python脚本，来实现自动将命令行转成launch.json来进行调试：</div><div class="notion-text notion-block-3e098437b2874261af687e4870c90d76">使用示例（假设脚本命名为launch_json_generator.py，且在Vs Code工作区根目录）：</div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>