<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>所有文章 - mywebsite</title><link>https://steven-yl.github.io/mywebsite/posts/</link><description>所有文章 | mywebsite</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>steven@gmail.com (Steven)</managingEditor><webMaster>steven@gmail.com (Steven)</webMaster><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Fri, 03 Apr 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://steven-yl.github.io/mywebsite/posts/" rel="self" type="application/rss+xml"/><item><title>TorchCode 技术文档索引</title><link>https://steven-yl.github.io/mywebsite/readme/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/readme/</guid><description>从零实现算子的练习项目配套文档索引，链向总览与各章详解。</description></item><item><title>第七章：高级主题（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/07_advanced_topics/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/07_advanced_topics/</guid><description>TorchCode 文档第七章：分词、量化与 RLHF 损失。</description></item><item><title>第六章：推理与解码策略（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/06_inference_decoding/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/06_inference_decoding/</guid><description>TorchCode 文档第六章：推理与解码。</description></item><item><title>第五章：训练与优化（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/05_training_optimization/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/05_training_optimization/</guid><description>TorchCode 文档第五章：训练与优化实践。</description></item><item><title>第四章：架构与模型组件（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/04_architectures/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/04_architectures/</guid><description>TorchCode 文档第四章：从组件到完整模型块。</description></item><item><title>第三章：注意力机制（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/03_attention_mechanisms/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/03_attention_mechanisms/</guid><description>TorchCode 文档第三章：注意力机制从基础到高效实现。</description></item><item><title>第二章：归一化技术（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/02_normalization/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/02_normalization/</guid><description>TorchCode 文档第二章：归一化技术全解。</description></item><item><title>第一章：激活函数与基础组件（TorchCode）</title><link>https://steven-yl.github.io/mywebsite/01_activations_and_fundamentals/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/01_activations_and_fundamentals/</guid><description>TorchCode 文档第一章：从最底层算子到损失函数。</description></item><item><title>总览：TorchCode 知识架构与学习路径</title><link>https://steven-yl.github.io/mywebsite/00_overview/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/00_overview/</guid><description>算子级练习项目的整体架构与推荐阅读顺序。</description></item><item><title>Title / Tags / Categories / Series</title><link>https://steven-yl.github.io/mywebsite/blog_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/blog_guide/</guid><description><![CDATA[<p>本文档整合 <code>content/posts</code> 下各篇博文的 <strong>title</strong>、<strong>tags</strong>、<strong>categories</strong>、<strong>series</strong>，便于查阅与保持 frontmatter 一致。新文或改文时，<strong>tags/categories/series 优先从下方 <a href="#1-%e5%85%a8%e7%ab%99%e6%a0%87%e7%ad%be--%e5%88%86%e7%b1%bb--%e7%b3%bb%e5%88%97%e6%b1%87%e6%80%bb" rel="">§1 全站去重列表</a> 中复用</strong>；完整约定见仓库根目录 <a href="../../AGENTS.md" rel="">AGENTS.md</a> 中的「博客编写规范」。</p>]]></description></item><item><title>PyTorch 随机种子（Seed）全面解释</title><link>https://steven-yl.github.io/mywebsite/seed/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/seed/</guid><description>系统梳理随机种子的概念与 PyTorch 实践，包括 DataLoader worker、cuDNN、不确定性算子和常见陷阱，帮助你搭建可复现实验环境。</description></item><item><title>PyTorch 优化器原理</title><link>https://steven-yl.github.io/mywebsite/optim/</link><pubDate>Tue, 17 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/optim/</guid><description>解析PyTorch 优化器原理、更新公式与偏差校正推导，并给出超参数建议与优缺点总结。</description></item><item><title>Pytorch Batch Size 与学习率缩放规则</title><link>https://steven-yl.github.io/mywebsite/batch_size_lr/</link><pubDate>Tue, 17 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/batch_size_lr/</guid><description>详解分布式训练中 batch size 扩大时学习率的线性缩放、平方根缩放及线性+长 warmup 的推导依据与使用建议。</description></item><item><title>Kaiming（He）初始化：方差推导与 ReLU 网络</title><link>https://steven-yl.github.io/mywebsite/kaiming/</link><pubDate>Fri, 03 Apr 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/kaiming/</guid><description>用前向方差分析解释为何 ReLU 网络宜用方差 2/fan_in 的权重初始化，并对比 Xavier、给出 PyTorch 中的对应实现。</description></item><item><title>PyTorch Tensor 工具函数技术文档：创建、计算、拼接与索引</title><link>https://steven-yl.github.io/mywebsite/tensor_ops_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/tensor_ops_guide/</guid><description>总览 PyTorch 张量运算知识结构；创建/reshape/cat/stack/split；逐元与矩阵运算；归约；索引、gather/scatter；比较与逻辑；einsum 等工具；速查与延伸。</description></item><item><title>PyTorch 模型训练技术文档：求解器、参数配置与训练循环</title><link>https://steven-yl.github.io/mywebsite/training_solver_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/training_solver_guide/</guid><description>从总览到各章节：Optimizer/SGD/Adam/AdamW 全解读、LRScheduler 族、param_groups、梯度累积与裁剪、损失选型及学习率与 batch 配置经验。</description></item><item><title>PyTorch DataLoader 技术解读</title><link>https://steven-yl.github.io/mywebsite/dataloader_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/dataloader_guide/</guid><description>从索引流、取样本、成 batch 三条线讲清 DataLoader 职责，涵盖 Sampler、collate_fn、num_workers、pin_memory 及与 Dataset 的衔接。</description></item><item><title>Pytorch 权重初始化方法</title><link>https://steven-yl.github.io/mywebsite/net_init/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/net_init/</guid><description>全面对比深度学习权重初始化方法的原理、公式推导、优缺点与适用场景，附 PyTorch 代码示例和 Transformer 架构初始化最佳实践。</description></item><item><title>PyTorch Dataset 体系技术文档</title><link>https://steven-yl.github.io/mywebsite/pytorch_dataset_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/pytorch_dataset_guide/</guid><description>覆盖 map-style/IterableDataset、全部内置 Dataset 扩展、图数据与 HF datasets、典型项目扩展模式、padding 与 collate 职责划分，以及与 DataLoader 的衔接。</description></item><item><title>PyTorch 分布式训练与操作工具技术文档</title><link>https://steven-yl.github.io/mywebsite/distributed_training_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/distributed_training_guide/</guid><description>从进程组初始化、DDP 封装、数据分片、集体通信到 Lightning 封装，全面讲解如何在单机多卡与多机多卡场景下正确使用 PyTorch 分布式训练。</description></item><item><title>PyTorch 激活函数</title><link>https://steven-yl.github.io/mywebsite/active_function/</link><pubDate>Tue, 24 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/active_function/</guid><description>本文汇总 Sigmoid、Tanh、ReLU、GELU、Swish 等激活函数，并提供分组图与总览图。</description></item><item><title>PyTorch lr曲线</title><link>https://steven-yl.github.io/mywebsite/lr_function/</link><pubDate>Tue, 24 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/lr_function/</guid><description>lr曲线图</description></item><item><title>扩散模型中的噪声调度（Noise Schedule）—— 完整理论笔记</title><link>https://steven-yl.github.io/mywebsite/schedule/</link><pubDate>Fri, 27 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/schedule/</guid><description>从线性、余弦到 EDM、SNR-based 调度，结合采样器与时间嵌入给出完整工程实践指南。</description></item><item><title>深度学习中的常见归一化方法</title><link>https://steven-yl.github.io/mywebsite/norm/</link><pubDate>Wed, 01 Apr 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/norm/</guid><description>深度学习中的常见归一化方法</description></item><item><title>Analytic Diffusion Studio — 工具模块</title><link>https://steven-yl.github.io/mywebsite/13-utilities/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/13-utilities/</guid><description>Analytic Diffusion Studio — 工具模块</description></item><item><title>Analytic Diffusion Studio — 评估指标与实验流程</title><link>https://steven-yl.github.io/mywebsite/12-metrics-and-evaluation/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/12-metrics-and-evaluation/</guid><description>Analytic Diffusion Studio — 评估指标与实验流程</description></item><item><title>Analytic Diffusion Studio — 基线 UNet 模型</title><link>https://steven-yl.github.io/mywebsite/11-model-baseline-unet/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/11-model-baseline-unet/</guid><description>Analytic Diffusion Studio — 基线 UNet 模型</description></item><item><title>Analytic Diffusion Studio — 最近邻基线</title><link>https://steven-yl.github.io/mywebsite/10-model-nearest-dataset/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/10-model-nearest-dataset/</guid><description>Analytic Diffusion Studio — 最近邻基线</description></item><item><title>Analytic Diffusion Studio — PCA Locality 去噪器</title><link>https://steven-yl.github.io/mywebsite/09-model-pca-locality/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/09-model-pca-locality/</guid><description>Analytic Diffusion Studio — PCA Locality 去噪器</description></item><item><title>Analytic Diffusion Studio — 平滑最优去噪器</title><link>https://steven-yl.github.io/mywebsite/08-model-scfdm/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/08-model-scfdm/</guid><description>Analytic Diffusion Studio — 平滑最优去噪器</description></item><item><title>Analytic Diffusion Studio — 最优贝叶斯去噪器</title><link>https://steven-yl.github.io/mywebsite/07-model-optimal/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/07-model-optimal/</guid><description>Analytic Diffusion Studio — 最优贝叶斯去噪器</description></item><item><title>Analytic Diffusion Studio — Wiener 滤波去噪器</title><link>https://steven-yl.github.io/mywebsite/06-model-wiener/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/06-model-wiener/</guid><description>Analytic Diffusion Studio — Wiener 滤波去噪器</description></item><item><title>Analytic Diffusion Studio — 模型基类与采样循环</title><link>https://steven-yl.github.io/mywebsite/05-models-base/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/05-models-base/</guid><description>Analytic Diffusion Studio — 模型基类与采样循环</description></item><item><title>Analytic Diffusion Studio — 数据模块</title><link>https://steven-yl.github.io/mywebsite/04-data/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/04-data/</guid><description>Analytic Diffusion Studio — 数据模块</description></item><item><title>Analytic Diffusion Studio — 配置系统</title><link>https://steven-yl.github.io/mywebsite/03-configuration/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/03-configuration/</guid><description>Analytic Diffusion Studio — 配置系统</description></item><item><title>Analytic Diffusion Studio — 扩散模型理论基础</title><link>https://steven-yl.github.io/mywebsite/02-diffusion-theory/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/02-diffusion-theory/</guid><description>Analytic Diffusion Studio — 扩散模型理论基础</description></item><item><title>smalldiffusion 技术文档索引</title><link>https://steven-yl.github.io/mywebsite/00_index/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/00_index/</guid><description><![CDATA[<blockquote>
  <p>smalldiffusion 是一个轻量级扩散模型库，用不到 100 行核心代码实现了扩散模型的训练与采样。
本文档对项目进行全面技术解读，从整体架构到每个函数的实现细节。</p>

</blockquote><h2 id="文档结构" class="headerLink">
    <a href="#%e6%96%87%e6%a1%a3%e7%bb%93%e6%9e%84" class="header-mark"></a>文档结构</h2><table>
  <thead>
      <tr>
          <th>文件</th>
          <th>内容</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="01_overview.md" rel="">01_overview.md</a></td>
          <td>项目总览：架构设计、模块关系、扩散模型数学基础</td>
      </tr>
      <tr>
          <td><a href="02_diffusion.md" rel="">02_diffusion.md</a></td>
          <td>核心模块：噪声调度、训练循环、采样算法 (<code>diffusion.py</code>)</td>
      </tr>
      <tr>
          <td><a href="03_data.md" rel="">03_data.md</a></td>
          <td>数据模块：数据集工具、玩具数据集 (<code>data.py</code>)</td>
      </tr>
      <tr>
          <td><a href="04_model_base.md" rel="">04_model_base.md</a></td>
          <td>模型基础：ModelMixin、预测模式修饰器、注意力机制、嵌入层 (<code>model.py</code>)</td>
      </tr>
      <tr>
          <td><a href="05_model_dit.md" rel="">05_model_dit.md</a></td>
          <td>Diffusion Transformer 模型 (<code>model_dit.py</code>)</td>
      </tr>
      <tr>
          <td><a href="06_model_unet.md" rel="">06_model_unet.md</a></td>
          <td>U-Net 模型 (<code>model_unet.py</code>)</td>
      </tr>
      <tr>
          <td><a href="07_examples.md" rel="">07_examples.md</a></td>
          <td>实战示例：从玩具模型到 Stable Diffusion</td>
      </tr>
  </tbody>
</table>
<h2 id="模块依赖关系" class="headerLink">
    <a href="#%e6%a8%a1%e5%9d%97%e4%be%9d%e8%b5%96%e5%85%b3%e7%b3%bb" class="header-mark"></a>模块依赖关系</h2><div class="code-block highlight is-open show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>Analytic Diffusion Studio — 项目总览</title><link>https://steven-yl.github.io/mywebsite/01-overview/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/01-overview/</guid><description>Analytic Diffusion Studio — 项目总览</description></item><item><title>Analytic Diffusion Studio — 技术文档索引</title><link>https://steven-yl.github.io/mywebsite/00-index/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/00-index/</guid><description>Analytic Diffusion Studio — 技术文档索引</description></item><item><title>smalldiffusion 实战示例</title><link>https://steven-yl.github.io/mywebsite/07_examples/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/07_examples/</guid><description><![CDATA[<blockquote>
  <p>本章解读项目提供的所有示例，从 2D 玩具模型到 Stable Diffusion 级别的预训练模型。</p>

</blockquote><h2 id="71-示例总览" class="headerLink">
    <a href="#71-%e7%a4%ba%e4%be%8b%e6%80%bb%e8%a7%88" class="header-mark"></a>7.1 示例总览</h2><table>
  <thead>
      <tr>
          <th>示例</th>
          <th>数据</th>
          <th>模型</th>
          <th>调度</th>
          <th>条件</th>
          <th>运行方式</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>toyexample.ipynb</td>
          <td>Swissroll 2D</td>
          <td>TimeInputMLP</td>
          <td>LogLinear</td>
          <td>无</td>
          <td>Jupyter</td>
      </tr>
      <tr>
          <td>cond_tree_model.ipynb</td>
          <td>TreeDataset 2D</td>
          <td>ConditionalMLP</td>
          <td>LogLinear</td>
          <td>类别标签 + CFG</td>
          <td>Jupyter</td>
      </tr>
      <tr>
          <td>fashion_mnist_dit.py</td>
          <td>FashionMNIST 28×28</td>
          <td>DiT</td>
          <td>DDPM</td>
          <td>无</td>
          <td>accelerate launch</td>
      </tr>
      <tr>
          <td>fashion_mnist_dit_cond.py</td>
          <td>FashionMNIST 28×28</td>
          <td>DiT + CondEmbedder</td>
          <td>DDPM</td>
          <td>类别标签 + CFG</td>
          <td>accelerate launch</td>
      </tr>
      <tr>
          <td>fashion_mnist_unet.py</td>
          <td>FashionMNIST 28×28</td>
          <td>Scaled(Unet)</td>
          <td>LogLinear</td>
          <td>无</td>
          <td>accelerate launch</td>
      </tr>
      <tr>
          <td>cifar_unet.py</td>
          <td>CIFAR-10 32×32</td>
          <td>Scaled(Unet)</td>
          <td>Sigmoid(训练)/LogLinear(采样)</td>
          <td>无</td>
          <td>accelerate launch</td>
      </tr>
      <tr>
          <td>diffusers_wrapper.py</td>
          <td>-</td>
          <td>ModelLatentDiffusion</td>
          <td>LDM</td>
          <td>文本</td>
          <td>Python 模块</td>
      </tr>
      <tr>
          <td>stablediffusion.py</td>
          <td>-</td>
          <td>ModelLatentDiffusion</td>
          <td>LDM</td>
          <td>文本</td>
          <td>python</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="72-玩具模型示例-toyexampleipynb" class="headerLink">
    <a href="#72-%e7%8e%a9%e5%85%b7%e6%a8%a1%e5%9e%8b%e7%a4%ba%e4%be%8b-toyexampleipynb" class="header-mark"></a>7.2 玩具模型示例 (toyexample.ipynb)</h2><h3 id="最小可运行代码" class="headerLink">
    <a href="#%e6%9c%80%e5%b0%8f%e5%8f%af%e8%bf%90%e8%a1%8c%e4%bb%a3%e7%a0%81" class="header-mark"></a>最小可运行代码</h3><div class="code-block highlight is-closed show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">python</p>]]></description></item><item><title>smalldiffusion 模型：model_unet.py</title><link>https://steven-yl.github.io/mywebsite/06_model_unet/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/06_model_unet/</guid><description><![CDATA[<blockquote>
  <p>本文件实现了经典的 U-Net 扩散模型架构，改编自 <a href="https://github.com/luping-liu/PNDM" target="_blank" rel="noopener noreferrer">PNDM</a> 和 <a href="https://github.com/ermongroup/ddim" target="_blank" rel="noopener noreferrer">DDIM</a> 的实现。</p>

</blockquote><h2 id="61-模块结构" class="headerLink">
    <a href="#61-%e6%a8%a1%e5%9d%97%e7%bb%93%e6%9e%84" class="header-mark"></a>6.1 模块结构</h2><div class="code-block highlight is-open show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>smalldiffusion 模型：model_dit.py</title><link>https://steven-yl.github.io/mywebsite/05_model_dit/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/05_model_dit/</guid><description><![CDATA[<blockquote>
  <p>本文件实现了 <a href="https://arxiv.org/abs/2212.09748" target="_blank" rel="noopener noreferrer">DiT (Peebles &amp; Xie, 2022)</a> 架构，一种基于 Transformer 的扩散模型。</p>

</blockquote><h2 id="51-模块结构" class="headerLink">
    <a href="#51-%e6%a8%a1%e5%9d%97%e7%bb%93%e6%9e%84" class="header-mark"></a>5.1 模块结构</h2><div class="code-block highlight is-open show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>smalldiffusion 模型基础：model.py</title><link>https://steven-yl.github.io/mywebsite/04_model_base/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/04_model_base/</guid><description><![CDATA[<blockquote>
  <p>本文件定义了所有模型共享的基类、预测模式修饰器、通用组件（注意力、嵌入）、玩具模型和理想去噪器。</p>

</blockquote><h2 id="41-模块结构" class="headerLink">
    <a href="#41-%e6%a8%a1%e5%9d%97%e7%bb%93%e6%9e%84" class="header-mark"></a>4.1 模块结构</h2><div class="code-block highlight is-closed show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>smalldiffusion 数据模块：data.py</title><link>https://steven-yl.github.io/mywebsite/03_data/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/03_data/</guid><description><![CDATA[<blockquote>
  <p>本文件提供数据集工具函数和三个 2D 玩具数据集，用于快速验证扩散模型的正确性。</p>

</blockquote><h2 id="31-模块结构" class="headerLink">
    <a href="#31-%e6%a8%a1%e5%9d%97%e7%bb%93%e6%9e%84" class="header-mark"></a>3.1 模块结构</h2><div class="code-block highlight is-open show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>smalldiffusion 核心模块：diffusion.py</title><link>https://steven-yl.github.io/mywebsite/02_diffusion/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/02_diffusion/</guid><description><![CDATA[<blockquote>
  <p>本文件是 smalldiffusion 的核心，包含噪声调度（Schedule）、训练循环（training_loop）和采样算法（samples），总计不到 100 行代码。</p>

</blockquote><h2 id="21-模块结构" class="headerLink">
    <a href="#21-%e6%a8%a1%e5%9d%97%e7%bb%93%e6%9e%84" class="header-mark"></a>2.1 模块结构</h2><div class="code-block highlight is-closed show-line-numbers  tw-group tw-my-2">
  <div class="
    
    tw-flex 
    tw-flex-row
    tw-flex-1 
    tw-justify-between 
    tw-w-full tw-bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw-mx-2 
        tw-flex
        tw-flex-row
        tw-flex-1"
      aria-hidden="true">
          <div class="group-[.is-open]:tw-rotate-90 tw-transition-[transform] tw-duration-500 tw-ease-in-out print:!tw-hidden tw-w-min tw-h-min tw-my-1 tw-mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></div>
          <p class="tw-select-none !tw-my-1">text</p>]]></description></item><item><title>smalldiffusion 项目总览</title><link>https://steven-yl.github.io/mywebsite/01_overview/</link><pubDate>Fri, 27 Mar 2026 10:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/01_overview/</guid><description><![CDATA[<h2 id="11-项目定位" class="headerLink">
    <a href="#11-%e9%a1%b9%e7%9b%ae%e5%ae%9a%e4%bd%8d" class="header-mark"></a>1.1 项目定位</h2><p>smalldiffusion 是一个教学与实验导向的扩散模型库，核心训练和采样代码不到 100 行。它的设计目标是：</p>
<ul>
<li>提供可读、可理解的扩散模型实现</li>
<li>支持从 2D 玩具数据到 Stable Diffusion 级别的预训练模型</li>
<li>方便研究者快速实验新的采样算法和模型架构</li>
</ul>
<p>论文参考：<a href="https://arxiv.org/abs/2306.04848" target="_blank" rel="noopener noreferrer">Permenter and Yuan, arXiv:2306.04848</a></p>]]></description></item><item><title>Flow-Matching-Formula</title><link>https://steven-yl.github.io/mywebsite/formula-flow/</link><pubDate>Wed, 04 Mar 2026 12:22:25 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/formula-flow/</guid><description><![CDATA[<h2 id="推导图" class="headerLink">
    <a href="#%e6%8e%a8%e5%af%bc%e5%9b%be" class="header-mark"></a>1 推导图</h2><pre class="mermaid">graph LR;
    A[Flow Matching] --> B("条件概率\边际概率")
    A[Flow Matching] --> C("条件速度场\边际速度场")
    A[Flow Matching] --> D("速度调度器变换")
    A[Flow Matching] --> E("高斯路径下边际速度场的参数化(速度\x_0\x_1\score之间的转换)")
    A[Flow Matching] --> F("边际概率的计算(微分同胚\推前映射\变量替换)")
    A[Flow Matching] --> G("条件引导")

</pre>
<h2 id="关键公式推导" class="headerLink">
    <a href="#%e5%85%b3%e9%94%ae%e5%85%ac%e5%bc%8f%e6%8e%a8%e5%af%bc" class="header-mark"></a>2 关键公式推导</h2><h3 id="联合概率密度与边际概率密度" class="headerLink">
    <a href="#%e8%81%94%e5%90%88%e6%a6%82%e7%8e%87%e5%af%86%e5%ba%a6%e4%b8%8e%e8%be%b9%e9%99%85%e6%a6%82%e7%8e%87%e5%af%86%e5%ba%a6" class="header-mark"></a>2.1 联合概率密度与边际概率密度</h3><ul>
<li>随机向量 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi><mo separator="true">,</mo><mi>Y</mi></mrow><annotation encoding="application/x-tex">X, Y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span></span></span></span>，联合PDF <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mrow><mi>X</mi><mo separator="true">,</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><mi>y</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p_{X,Y}(x,y)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span></span></span></span> 满足边际化性质：
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>X</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∫</mo><msub><mi>p</mi><mrow><mi>X</mi><mo separator="true">,</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><mi>y</mi><mo stretchy="false">)</mo><mi>d</mi><mi>y</mi></mrow><annotation encoding="application/x-tex">p_X(x) = \int p_{X,Y}(x,y) dy</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>Y</mi></msub><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∫</mo><msub><mi>p</mi><mrow><mi>X</mi><mo separator="true">,</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><mi>y</mi><mo stretchy="false">)</mo><mi>d</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">p_Y(y) = \int p_{X,Y}(x,y) dx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord mathnormal">x</span></span></span></span></li>
</ul>
</li>
</ul>
<h3 id="条件概率密度与贝叶斯法则" class="headerLink">
    <a href="#%e6%9d%a1%e4%bb%b6%e6%a6%82%e7%8e%87%e5%af%86%e5%ba%a6%e4%b8%8e%e8%b4%9d%e5%8f%b6%e6%96%af%e6%b3%95%e5%88%99" class="header-mark"></a>2.2 条件概率密度与贝叶斯法则</h3><ul>
<li>条件 PDF 定义：<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mrow><mi>X</mi><mo>∣</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo>∣</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mrow><msub><mi>p</mi><mrow><mi>X</mi><mo separator="true">,</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><mi>y</mi><mo stretchy="false">)</mo></mrow><mrow><msub><mi>p</mi><mi>Y</mi></msub><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow><annotation encoding="application/x-tex">p_{X \mid Y}(x \mid y) = \frac{p_{X,Y}(x,y)}{p_Y(y)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1052em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mrel mtight">∣</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.5525em;vertical-align:-0.52em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0325em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span><span class="mopen mtight">(</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span><span class="mclose mtight">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.5075em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2822em;"><span></span></span></span></span></span></span><span class="mopen mtight">(</span><span class="mord mathnormal mtight">x</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span><span class="mclose mtight">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.52em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>（要求 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>Y</mi></msub><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>&gt;</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">p_Y(y) &gt; 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>）</li>
</ul>
<h3 id="条件概率密度和边际概率密度" class="headerLink">
    <a href="#%e6%9d%a1%e4%bb%b6%e6%a6%82%e7%8e%87%e5%af%86%e5%ba%a6%e5%92%8c%e8%be%b9%e9%99%85%e6%a6%82%e7%8e%87%e5%af%86%e5%ba%a6" class="header-mark"></a>2.3 条件概率密度和边际概率密度</h3><ul>
<li>z：样本数据，x：采样数据</li>
<li>条件概率路径：<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mrow><mi>t</mi><mi mathvariant="normal">∣</mi><mi>Z</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p_{t|Z}(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1052em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mord mtight">∣</span><span class="mord mathnormal mtight" style="margin-right:0.07153em;">Z</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span>（生成 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi><mo>=</mo><mi>z</mi></mrow><annotation encoding="application/x-tex">Z=z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span> 时的条件路径）；</li>
<li>边际概率路径：<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>t</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∫</mo><msub><mi>p</mi><mrow><mi>t</mi><mi mathvariant="normal">∣</mi><mi>Z</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><msub><mi>p</mi><mi>Z</mi></msub><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo><mi>d</mi><mi>z</mi></mrow><annotation encoding="application/x-tex">p_t(x) = \int p_{t|Z}(x|z) p_Z(z) dz</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1602em;vertical-align:-0.3552em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mord mtight">∣</span><span class="mord mathnormal mtight" style="margin-right:0.07153em;">Z</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">Z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span>；</li>
</ul>
<h3 id="条件期望与全期望性质" class="headerLink">
    <a href="#%e6%9d%a1%e4%bb%b6%e6%9c%9f%e6%9c%9b%e4%b8%8e%e5%85%a8%e6%9c%9f%e6%9c%9b%e6%80%a7%e8%b4%a8" class="header-mark"></a>2.4 条件期望与全期望性质</h3><ul>
<li>条件期望 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">E</mi><mo stretchy="false">[</mo><mi>X</mi><mo>∣</mo><mi>Y</mi><mo>=</mo><mi>y</mi><mo stretchy="false">]</mo><mo>=</mo><mo>∫</mo><mi>x</mi><msub><mi>p</mi><mrow><mi>X</mi><mo>∣</mo><mi>Y</mi></mrow></msub><mo stretchy="false">(</mo><mi>x</mi><mo>∣</mo><mi>y</mi><mo stretchy="false">)</mo><mi>d</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">\mathbb{E}[X \mid Y = y] = \int x p_{X \mid Y}(x \mid y) dx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathbb">E</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1602em;vertical-align:-0.3552em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">X</span><span class="mrel mtight">∣</span><span class="mord mathnormal mtight" style="margin-right:0.22222em;">Y</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord mathnormal">x</span></span></span></span>，是“给定 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Y</mi><mo>=</mo><mi>y</mi></mrow><annotation encoding="application/x-tex">Y = y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span> 时，最小二乘意义下最接近 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span></span></span></span> 的函数”；</li>
<li>全期望性质（Tower Property）：<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">E</mi><mo stretchy="false">[</mo><mi mathvariant="double-struck">E</mi><mo stretchy="false">[</mo><mi>X</mi><mo>∣</mo><mi>Y</mi><mo stretchy="false">]</mo><mo stretchy="false">]</mo><mo>=</mo><mi mathvariant="double-struck">E</mi><mo stretchy="false">[</mo><mi>X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\mathbb{E}[\mathbb{E}[X \mid Y]] = \mathbb{E}[X]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathbb">E</span><span class="mopen">[</span><span class="mord mathbb">E</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span><span class="mclose">]]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathbb">E</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="mclose">]</span></span></span></span>——多层期望可简化为单层期望，是后续边际速度场推导的关键工具。</li>
</ul>
<p><strong>全期望性质：</strong>
记 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi><mo stretchy="false">(</mo><mi>Y</mi><mo stretchy="false">)</mo><mo>=</mo><mi mathvariant="double-struck">E</mi><mo stretchy="false">[</mo><mi>X</mi><mo>∣</mo><mi>Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\mu(Y) = \mathbb{E}[X \mid Y]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">μ</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathbb">E</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span><span class="mclose">]</span></span></span></span>（给定 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Y</mi></mrow><annotation encoding="application/x-tex">Y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span></span></span></span> 时 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span></span></span></span> 的条件期望），它是 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Y</mi></mrow><annotation encoding="application/x-tex">Y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span></span></span></span> 的函数（随机变量）。</p>]]></description></item><item><title>ELBO</title><link>https://steven-yl.github.io/mywebsite/elbo/</link><pubDate>Sat, 28 Feb 2026 10:26:59 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/elbo/</guid><description><![CDATA[<div class="featured-image">
                <img src="/mywebsite/posts/images/elbo.webp" referrerpolicy="no-referrer">
            </div><h1 id="elbo-与变分方法详解" class="headerLink">
    <a href="#elbo-%e4%b8%8e%e5%8f%98%e5%88%86%e6%96%b9%e6%b3%95%e8%af%a6%e8%a7%a3" class="header-mark"></a>ELBO 与变分方法详解</h1><h2 id="一动机为什么需要-elbo" class="headerLink">
    <a href="#%e4%b8%80%e5%8a%a8%e6%9c%ba%e4%b8%ba%e4%bb%80%e4%b9%88%e9%9c%80%e8%a6%81-elbo" class="header-mark"></a>一、动机：为什么需要 ELBO？</h2><p>在隐变量生成模型中，观测 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span> 由隐变量 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span> 通过解码器 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p_\phi(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span> 生成，先验为 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">p(z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">p</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span>。**边际似然（证据）**为：</p>
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>log</mi><mo>⁡</mo><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mi>log</mi><mo>⁡</mo><mo>∫</mo><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mtext> </mtext><mi>p</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo><mtext> </mtext><mi>d</mi><mi>z</mi></mrow><annotation encoding="application/x-tex">
\log p_\phi(x) = \log \int p_\phi(x|z)\, p(z)\, dz
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span></span><ul>
<li><strong>理想</strong>：用最大似然估计（MLE）最大化 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\log p_\phi(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span> 来学习解码器参数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi></mrow><annotation encoding="application/x-tex">\phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span></span></span></span>。</li>
<li><strong>障碍</strong>：积分对 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span> 在高维、非线性解码器下<strong>难以计算</strong>（intractable），直接 MLE 不可行。</li>
<li><strong>变分思路</strong>：不直接算 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\log p_\phi(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span>，而是构造一个<strong>可计算的下界</strong>，通过最大化该下界间接增大 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo><msub><mi>p</mi><mi>ϕ</mi></msub><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\log p_\phi(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">ϕ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span>。这个下界就是 <strong>ELBO</strong>（Evidence Lower BOund，证据下界）。</li>
</ul>
<hr>
<h2 id="二变分方法核心近似后验" class="headerLink">
    <a href="#%e4%ba%8c%e5%8f%98%e5%88%86%e6%96%b9%e6%b3%95%e6%a0%b8%e5%bf%83%e8%bf%91%e4%bc%bc%e5%90%8e%e9%aa%8c" class="header-mark"></a>二、变分方法核心：近似后验 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></h2><p>真实后验为：</p>]]></description></item><item><title>Diffusion-Flow-Formula</title><link>https://steven-yl.github.io/mywebsite/formula-diffusion-flow/</link><pubDate>Sat, 28 Feb 2026 10:26:59 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/formula-diffusion-flow/</guid><description><![CDATA[<h2 id="一基本形式前向时间方向" class="headerLink">
    <a href="#%e4%b8%80%e5%9f%ba%e6%9c%ac%e5%bd%a2%e5%bc%8f%e5%89%8d%e5%90%91%e6%97%b6%e9%97%b4%e6%96%b9%e5%90%91" class="header-mark"></a>一、基本形式（前向时间方向）</h2><h3 id="1-flow确定性流ode" class="headerLink">
    <a href="#1-flow%e7%a1%ae%e5%ae%9a%e6%80%a7%e6%b5%81ode" class="header-mark"></a>1. Flow（确定性流，ODE）</h3><ul>
<li>
<p><strong>动力学</strong>：仅漂移，无随机项
</p>
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle mathcolor="#4a9eff"><mi mathvariant="normal">d</mi><msub><mi>X</mi><mi>t</mi></msub><mo>=</mo><msub><mi>u</mi><mi>t</mi></msub><mo stretchy="false">(</mo><msub><mi>X</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mtext> </mtext><mi mathvariant="normal">d</mi><mi>t</mi><mi mathvariant="normal">.</mi></mstyle></mrow><annotation encoding="application/x-tex">
  \color{#4a9eff} \mathrm{d}X_t = u_t(X_t)\,\mathrm{d}t.
  </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord mathrm" style="color:#4a9eff;">d</span><span class="mord" style="color:#4a9eff;"><span class="mord mathnormal" style="margin-right:0.07847em;color:#4a9eff;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight" style="color:#4a9eff;"><span class="mord mathnormal mtight" style="color:#4a9eff;">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:#4a9eff;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord" style="color:#4a9eff;"><span class="mord mathnormal" style="color:#4a9eff;">u</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight" style="color:#4a9eff;"><span class="mord mathnormal mtight" style="color:#4a9eff;">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen" style="color:#4a9eff;">(</span><span class="mord" style="color:#4a9eff;"><span class="mord mathnormal" style="margin-right:0.07847em;color:#4a9eff;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight" style="color:#4a9eff;"><span class="mord mathnormal mtight" style="color:#4a9eff;">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose" style="color:#4a9eff;">)</span><span class="mspace" style="color:#4a9eff;margin-right:0.1667em;"></span><span class="mord mathrm" style="color:#4a9eff;">d</span><span class="mord mathnormal" style="color:#4a9eff;">t</span><span class="mord" style="color:#4a9eff;">.</span></span></span></span></span></li>
<li>
<p><strong>密度演化</strong>:（Fokker–Planck）：<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>X</mi><mi>t</mi></msub><mo>∼</mo><msub><mi>p</mi><mi>t</mi></msub></mrow><annotation encoding="application/x-tex">X_t \sim p_t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> 时
</p>]]></description></item><item><title>Flow Matching Guide and Code 第5章解读：Non-Euclidean Flow Matching</title><link>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-non-euclidean-flow-matching/</link><pubDate>Thu, 05 Mar 2026 00:00:00 +0000</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-non-euclidean-flow-matching/</guid><description>第5章 Non-Euclidean Flow Matching 解读：从动机与黎曼流形设定出发，说明流形上的流、概率路径与连续性方程，边际化技巧（定理10）、RCFM 损失（定理11），以及测地线条件流与基于预度量的条件流；并对照欧氏 FM 与代码8（球面测地线 RCFM）做小结。</description></item><item><title>Generative Modeling via Drifting</title><link>https://steven-yl.github.io/mywebsite/generative-modeling-via-drifting/</link><pubDate>Wed, 04 Mar 2026 00:00:00 +0000</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/generative-modeling-via-drifting/</guid><description><![CDATA[<h2 id="drifting-models-算法原理详细解析含完整公式" class="headerLink">
    <a href="#drifting-models-%e7%ae%97%e6%b3%95%e5%8e%9f%e7%90%86%e8%af%a6%e7%bb%86%e8%a7%a3%e6%9e%90%e5%90%ab%e5%ae%8c%e6%95%b4%e5%85%ac%e5%bc%8f" class="header-mark"></a>Drifting Models 算法原理详细解析（含完整公式）</h2><p>Drifting Models 是一种面向生成式建模的全新范式，核心创新在于将“分布推送”过程从推理阶段转移到训练阶段，通过引入<strong>漂移场（Drifting Field）</strong>  govern 样本分布的演化，最终实现<strong>单步推理（1-NFE）</strong> 下的高质量生成。该算法突破了扩散模型、流匹配等传统方法依赖多步迭代的效率瓶颈，在 ImageNet 256×256 生成任务中达到当前单步方法的最优性能（ latent 空间 FID 1.54，像素空间 FID 1.61），同时可扩展至机器人控制等其他领域。以下从核心思想、算法架构、关键模块、完整公式及实验验证等方面逐层解析。</p>]]></description></item><item><title>Flow Matching Guide and Code</title><link>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code/</link><pubDate>Sat, 28 Feb 2026 10:26:59 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code/</guid><description>&lt;div class="featured-image">
                &lt;img src="/mywebsite/posts/images/flow-matching-guide-and-code.webp" referrerpolicy="no-referrer">
            &lt;/div>《Flow Matching Guide and Code》全文技术解读：从流模型数学基础与欧氏空间 FM（概率路径、速度场、条件流匹配、线性/仿射条件流），到黎曼流形、离散 FM 与 Generator Matching 统一框架，并阐明与扩散模型、去噪分数匹配的关系。</description></item><item><title>An Introduction to Flow Matching and Diffusion Models</title><link>https://steven-yl.github.io/mywebsite/an-introduction-to-flow-matching-and-diffusion-models/</link><pubDate>Sat, 28 Feb 2026 10:26:59 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/an-introduction-to-flow-matching-and-diffusion-models/</guid><description>&lt;div class="featured-image">
                &lt;img src="/mywebsite/posts/images/an-introduction-to-flow-matching-and-diffusion-models.webp" referrerpolicy="no-referrer">
            &lt;/div>《An Introduction to Flow Matching and Diffusion Models》全文技术解读：从生成即采样与 ODE/SDE 基础出发，系统介绍流模型与扩散模型、连续性方程与福克-普朗克方程、流匹配与得分匹配训练目标及其与 DDPM 的对应，并涵盖条件生成、无分类器引导（CFG）与 U-Net/DiT 等架构。</description></item><item><title>Flow Matching Guide and Code: Discrete Flow Matching</title><link>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-discrete-flow-matching/</link><pubDate>Thu, 05 Mar 2026 00:00:00 +0000</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-discrete-flow-matching/</guid><description><![CDATA[<p>我们来详细整理并解释这段关于连续时间马尔可夫链（CTMC）的内容，使其更易于理解。</p>
<hr>
<h2 id="6-连续时间马尔可夫链模型" class="headerLink">
    <a href="#6-%e8%bf%9e%e7%bb%ad%e6%97%b6%e9%97%b4%e9%a9%ac%e5%b0%94%e5%8f%af%e5%a4%ab%e9%93%be%e6%a8%a1%e5%9e%8b" class="header-mark"></a>6. 连续时间马尔可夫链模型</h2><h3 id="核心思想ctmc-是什么" class="headerLink">
    <a href="#%e6%a0%b8%e5%bf%83%e6%80%9d%e6%83%b3ctmc-%e6%98%af%e4%bb%80%e4%b9%88" class="header-mark"></a>核心思想：CTMC 是什么？</h3><p>CTMC 是一种用于生成<strong>离散数据</strong>（比如文本、类别数据）的模型。你可以把它想象成一个在有限个离散状态之间随时间跳转的“粒子”，它按照一定的“速率”从一个状态跳到另一个状态。这与之前讨论的“流模型”（用于连续数据，如图像）形成对比，CTMC 是后续“离散流匹配”模型的基础。</p>]]></description></item><item><title>机械臂控制方法</title><link>https://steven-yl.github.io/mywebsite/arm_control/</link><pubDate>Sun, 22 Mar 2026 12:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/arm_control/</guid><description>从位置/速度/力/导纳/阻抗总览出发，展开阻抗与导纳对比、期望轨迹与力控实现、末端与关节力检测、重力/摩擦/惯性估计、零空间融合及拖动示教，附公式与工程要点</description></item><item><title>Loss Functions：系统化整理</title><link>https://steven-yl.github.io/mywebsite/loss_type/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/loss_type/</guid><description>本笔记从任务视角覆盖主流 Loss Functions，包括经典方法、现代变体以及实际组合策略，便于快速对照与选型。</description></item><item><title>KL 散度与离散流匹配中的广义 KL 损失</title><link>https://steven-yl.github.io/mywebsite/kl_div/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/kl_div/</guid><description>本文把 KL 散度相关的几个核心概念串起来，给出离散流匹配中广义 KL 损失的直观解释与 PyTorch 实现示例。</description></item><item><title>todo</title><link>https://steven-yl.github.io/mywebsite/todo/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/todo/</guid><description>收集一个外部链接，后续用于整理与更新。</description></item><item><title>9大思维模型与方法论：从理论到实践的完整指南</title><link>https://steven-yl.github.io/mywebsite/thinking-models/</link><pubDate>Mon, 16 Mar 2026 13:50:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/thinking-models/</guid><description><![CDATA[<h1 id="9大思维模型与方法论从理论到实践的完整指南" class="headerLink">
    <a href="#9%e5%a4%a7%e6%80%9d%e7%bb%b4%e6%a8%a1%e5%9e%8b%e4%b8%8e%e6%96%b9%e6%b3%95%e8%ae%ba%e4%bb%8e%e7%90%86%e8%ae%ba%e5%88%b0%e5%ae%9e%e8%b7%b5%e7%9a%84%e5%ae%8c%e6%95%b4%e6%8c%87%e5%8d%97" class="header-mark"></a>9大思维模型与方法论：从理论到实践的完整指南</h1><blockquote>
  <p>思维模型是我们理解世界、分析问题、做出决策的认知框架。掌握多种思维模型，就像拥有多套&quot;认知工具&quot;，能够从不同角度审视问题，避免思维盲区，做出更明智的决策。</p>]]></description></item><item><title>DiffusionDriveV2 代码结构图</title><link>https://steven-yl.github.io/mywebsite/diffusiondrivev2_code_structure/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/diffusiondrivev2_code_structure/</guid><description>通过目录树与模块依赖关系，梳理 DiffusionDrive v2（RL/Selection 相关模型及扩散模块）在工程中的位置与调用链路。</description></item><item><title>DiffusionDriveV2 网络结构图</title><link>https://steven-yl.github.io/mywebsite/diffusiondrivev2_network/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/diffusiondrivev2_network/</guid><description>本文以结构图的方式梳理 DiffusionDrive V2 的关键模块与连接关系：双流骨干特征融合、Transformer Decoder×3、扩散式 TrajectoryHead 的截断生成以及粗筛-精筛评分流水线。</description></item><item><title>Consistency Model</title><link>https://steven-yl.github.io/mywebsite/consistency-model/</link><pubDate>Fri, 27 Feb 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/consistency-model/</guid><description><![CDATA[<div class="featured-image">
                <img src="/mywebsite/posts/images/consistency-model.webp" referrerpolicy="no-referrer">
            </div><p>Consistency Model 技术文档（原理 + 自洽性 + 蒸馏/直接训练 + 采样 + 对比）</p>
<p>本文档为正式技术规格文档，系统介绍 Consistency Model 的核心思想、自洽性定义、两种训练范式（Consistency Distillation / Consistency Training）、一步与多步采样，以及与扩散模型、MeanFlow 的对比。</p>]]></description></item><item><title>The Principles of Diffusion Models</title><link>https://steven-yl.github.io/mywebsite/the-principles-of-diffusion-models/</link><pubDate>Sat, 28 Feb 2026 10:26:59 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/the-principles-of-diffusion-models/</guid><description>&lt;div class="featured-image">
                &lt;img src="/mywebsite/posts/images/the-principles-of-diffusion-models.webp" referrerpolicy="no-referrer">
            &lt;/div>《The Principles of Diffusion Models》（arXiv:2510.21890）全文技术解读：从前向破坏过程与反向生成出发，系统梳理扩散模型的三种表述——变分视角（VAE→DDPM）、基于分数的视角（EBM→NCSN→分数 SDE）、基于流的视角（NF→流匹配），阐明条件化技巧与福克–普朗克方程下的统一；并涵盖引导生成、数值求解器、蒸馏与从零学习的流映射模型（CM/CTM/MF）等。</description></item><item><title>Flow Matching Guide and Code 第5章解读：FlatTorus Riemannian Flow Matching 训练逻辑技术文档</title><link>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-flattorus-riemannian-flow-matching/</link><pubDate>Mon, 10 Jun 2024 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-flattorus-riemannian-flow-matching/</guid><description>平坦环面 M=[0,2π)² 上 Riemannian Flow Matching 的训练目标、概率路径、损失形式及实现细节的技术文档。</description></item><item><title>OpenClaw 安装文件与目录结构总览</title><link>https://steven-yl.github.io/mywebsite/openclaw/</link><pubDate>Sun, 09 Jun 2024 00:00:00 +0800</pubDate><author><name>Steven</name></author><guid>https://steven-yl.github.io/mywebsite/openclaw/</guid><description><![CDATA[<h2 id="openclaw-安装文件汇总" class="headerLink">
    <a href="#openclaw-%e5%ae%89%e8%a3%85%e6%96%87%e4%bb%b6%e6%b1%87%e6%80%bb" class="header-mark"></a>OpenClaw 安装文件汇总</h2><h3 id="一核心安装文件npm全局安装" class="headerLink">
    <a href="#%e4%b8%80%e6%a0%b8%e5%bf%83%e5%ae%89%e8%a3%85%e6%96%87%e4%bb%b6npm%e5%85%a8%e5%b1%80%e5%ae%89%e8%a3%85" class="header-mark"></a>一、核心安装文件（npm全局安装）</h3><table>
  <thead>
      <tr>
          <th>文件名/目录</th>
          <th>位置</th>
          <th>解释</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>openclaw</code></td>
          <td><code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/bin/</code></td>
          <td>主CLI可执行文件</td>
      </tr>
      <tr>
          <td><code>package.json</code></td>
          <td><code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/</code></td>
          <td>npm包信息与依赖</td>
      </tr>
      <tr>
          <td><code>docs/</code></td>
          <td><code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/docs/</code></td>
          <td>官方文档目录</td>
      </tr>
      <tr>
          <td><code>skills/</code></td>
          <td><code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/skills/</code></td>
          <td>内置技能库目录</td>
      </tr>
      <tr>
          <td><code>src/</code></td>
          <td><code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/src/</code></td>
          <td>源代码目录</td>
      </tr>
  </tbody>
</table>
<h3 id="二用户配置目录首次运行后创建" class="headerLink">
    <a href="#%e4%ba%8c%e7%94%a8%e6%88%b7%e9%85%8d%e7%bd%ae%e7%9b%ae%e5%bd%95%e9%a6%96%e6%ac%a1%e8%bf%90%e8%a1%8c%e5%90%8e%e5%88%9b%e5%bb%ba" class="header-mark"></a>二、用户配置目录（首次运行后创建）</h3><table>
  <thead>
      <tr>
          <th>文件名/目录</th>
          <th>位置</th>
          <th>解释</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>config/</code></td>
          <td><code>~/.openclaw/config/</code></td>
          <td>配置文件目录</td>
      </tr>
      <tr>
          <td><code>models.json</code></td>
          <td><code>~/.openclaw/config/models.json</code></td>
          <td>模型配置（API密钥、端点等）</td>
      </tr>
      <tr>
          <td><code>providers.json</code></td>
          <td><code>~/.openclaw/config/providers.json</code></td>
          <td>服务提供商配置</td>
      </tr>
      <tr>
          <td><code>channels.json</code></td>
          <td><code>~/.openclaw/config/channels.json</code></td>
          <td>消息频道配置</td>
      </tr>
      <tr>
          <td><code>workspace/</code></td>
          <td><code>~/.openclaw/workspace/</code></td>
          <td>用户工作空间根目录</td>
      </tr>
      <tr>
          <td><code>logs/</code></td>
          <td><code>~/.openclaw/logs/</code></td>
          <td>系统日志目录</td>
      </tr>
      <tr>
          <td><code>data/</code></td>
          <td><code>~/.openclaw/data/</code></td>
          <td>应用数据存储目录</td>
      </tr>
  </tbody>
</table>
<h3 id="三工作空间文件助手个性化" class="headerLink">
    <a href="#%e4%b8%89%e5%b7%a5%e4%bd%9c%e7%a9%ba%e9%97%b4%e6%96%87%e4%bb%b6%e5%8a%a9%e6%89%8b%e4%b8%aa%e6%80%a7%e5%8c%96" class="header-mark"></a>三、工作空间文件（助手个性化）</h3><table>
  <thead>
      <tr>
          <th>文件名</th>
          <th>位置</th>
          <th>解释</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>SOUL.md</code></td>
          <td><code>~/.openclaw/workspace/SOUL.md</code></td>
          <td>助手&quot;灵魂&quot;文件（个性、行为准则）</td>
      </tr>
      <tr>
          <td><code>USER.md</code></td>
          <td><code>~/.openclaw/workspace/USER.md</code></td>
          <td>用户信息文件</td>
      </tr>
      <tr>
          <td><code>IDENTITY.md</code></td>
          <td><code>~/.openclaw/workspace/IDENTITY.md</code></td>
          <td>助手身份定义（名称、表情等）</td>
      </tr>
      <tr>
          <td><code>TOOLS.md</code></td>
          <td><code>~/.openclaw/workspace/TOOLS.md</code></td>
          <td>本地工具配置笔记</td>
      </tr>
      <tr>
          <td><code>MEMORY.md</code></td>
          <td><code>~/.openclaw/workspace/MEMORY.md</code></td>
          <td>助手长期记忆（仅主会话加载）</td>
      </tr>
      <tr>
          <td><code>AGENTS.md</code></td>
          <td><code>~/.openclaw/workspace/AGENTS.md</code></td>
          <td>工作空间使用指南</td>
      </tr>
      <tr>
          <td><code>HEARTBEAT.md</code></td>
          <td><code>~/.openclaw/workspace/HEARTBEAT.md</code></td>
          <td>心跳任务清单</td>
      </tr>
      <tr>
          <td><code>BOOTSTRAP.md</code></td>
          <td><code>~/.openclaw/workspace/BOOTSTRAP.md</code></td>
          <td>首次启动引导文件（完成后删除）</td>
      </tr>
      <tr>
          <td><code>memory/</code></td>
          <td><code>~/.openclaw/workspace/memory/</code></td>
          <td>每日记忆文件目录</td>
      </tr>
      <tr>
          <td><code>YYYY-MM-DD.md</code></td>
          <td><code>~/.openclaw/workspace/memory/YYYY-MM-DD.md</code></td>
          <td>每日记忆文件（按日期）</td>
      </tr>
  </tbody>
</table>
<h3 id="四环境与运行时文件" class="headerLink">
    <a href="#%e5%9b%9b%e7%8e%af%e5%a2%83%e4%b8%8e%e8%bf%90%e8%a1%8c%e6%97%b6%e6%96%87%e4%bb%b6" class="header-mark"></a>四、环境与运行时文件</h3><table>
  <thead>
      <tr>
          <th>文件名</th>
          <th>位置</th>
          <th>解释</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>.openclawrc</code></td>
          <td><code>~/.openclawrc</code> 或 <code>~/.config/openclaw/config.json</code></td>
          <td>环境配置文件</td>
      </tr>
      <tr>
          <td>环境变量</td>
          <td>系统环境</td>
          <td>OPENCLAW_WORKSPACE, OPENCLAW_MODEL等</td>
      </tr>
      <tr>
          <td>PID文件</td>
          <td>系统临时目录</td>
          <td>网关守护进程的进程ID文件</td>
      </tr>
      <tr>
          <td>会话缓存</td>
          <td>系统临时目录</td>
          <td>运行时会话状态缓存</td>
      </tr>
  </tbody>
</table>
<h3 id="五技能文件示例" class="headerLink">
    <a href="#%e4%ba%94%e6%8a%80%e8%83%bd%e6%96%87%e4%bb%b6%e7%a4%ba%e4%be%8b" class="header-mark"></a>五、技能文件（示例）</h3><table>
  <thead>
      <tr>
          <th>技能名</th>
          <th>位置</th>
          <th>解释</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>1password/</code></td>
          <td><code>~/.nvm/.../openclaw/skills/1password/</code></td>
          <td>1Password CLI集成技能</td>
      </tr>
      <tr>
          <td><code>weather/</code></td>
          <td><code>~/.nvm/.../openclaw/skills/weather/</code></td>
          <td>天气查询技能</td>
      </tr>
      <tr>
          <td><code>obsidian/</code></td>
          <td><code>~/.nvm/.../openclaw/skills/obsidian/</code></td>
          <td>Obsidian笔记技能</td>
      </tr>
      <tr>
          <td><code>SKILL.md</code></td>
          <td>各技能目录下的<code>SKILL.md</code></td>
          <td>技能使用说明文档</td>
      </tr>
  </tbody>
</table>
<h3 id="六当前你的安装状态" class="headerLink">
    <a href="#%e5%85%ad%e5%bd%93%e5%89%8d%e4%bd%a0%e7%9a%84%e5%ae%89%e8%a3%85%e7%8a%b6%e6%80%81" class="header-mark"></a>六、当前你的安装状态</h3><table>
  <thead>
      <tr>
          <th>项目</th>
          <th>状态</th>
          <th>说明</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>安装版本</strong></td>
          <td>2026.3.2 (85377a2)</td>
          <td>最新稳定版</td>
      </tr>
      <tr>
          <td><strong>Node版本</strong></td>
          <td>v22.22.1</td>
          <td>通过nvm管理</td>
      </tr>
      <tr>
          <td><strong>工作空间</strong></td>
          <td>已初始化</td>
          <td>包含所有模板文件</td>
      </tr>
      <tr>
          <td><strong>模型配置</strong></td>
          <td>已配置</td>
          <td>DeepSeek Chat API</td>
      </tr>
      <tr>
          <td><strong>技能加载</strong></td>
          <td>正常</td>
          <td>内置技能可用</td>
      </tr>
      <tr>
          <td><strong>API问题</strong></td>
          <td>Amazon Bedrock缺失</td>
          <td>不影响核心功能</td>
      </tr>
  </tbody>
</table>
<h3 id="七重要路径总结" class="headerLink">
    <a href="#%e4%b8%83%e9%87%8d%e8%a6%81%e8%b7%af%e5%be%84%e6%80%bb%e7%bb%93" class="header-mark"></a>七、重要路径总结</h3><ol>
<li><strong>CLI命令</strong>: <code>~/.nvm/versions/node/v22.22.1/bin/openclaw</code></li>
<li><strong>配置目录</strong>: <code>~/.openclaw/config/</code></li>
<li><strong>工作空间</strong>: <code>~/.openclaw/workspace/</code></li>
<li><strong>技能目录</strong>: <code>~/.nvm/versions/node/v22.22.1/lib/node_modules/openclaw/skills/</code></li>
<li><strong>日志目录</strong>: <code>~/.openclaw/logs/</code></li>
</ol>
<h2 id="openclaw-技能skills技术说明列表" class="headerLink">
    <a href="#openclaw-%e6%8a%80%e8%83%bdskills%e6%8a%80%e6%9c%af%e8%af%b4%e6%98%8e%e5%88%97%e8%a1%a8" class="header-mark"></a>OpenClaw 技能（Skills）技术说明列表</h2><h3 id="技能概览" class="headerLink">
    <a href="#%e6%8a%80%e8%83%bd%e6%a6%82%e8%a7%88" class="header-mark"></a>技能概览</h3><p>OpenClaw 技能是模块化的功能扩展，每个技能提供特定领域的工具和自动化能力。</p>]]></description></item><item><title>Prompt 汇总与记录</title><link>https://steven-yl.github.io/mywebsite/prompt_guide/</link><pubDate>Thu, 12 Mar 2026 00:00:00 +0800</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/prompt_guide/</guid><description>本文用于汇总和记录日常使用的 Prompt，按场景分类，方便在 Cursor、Claude、ChatGPT 等工具中复用与迭代。文末提供&lt;strong>单条记录模板&lt;/strong>，新增时复制模板填写即可。</description></item><item><title>Flow Matching Guide and Code 第5章解读：指数映射-对数映射-测地线条件流</title><link>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-geodesic-conditional-flow/</link><pubDate>Thu, 05 Mar 2026 00:00:00 +0000</pubDate><author><name>Steven</name><uri>https://github.com/steven-yl</uri></author><guid>https://steven-yl.github.io/mywebsite/flow-matching-guide-and-code-5-geodesic-conditional-flow/</guid><description>&lt;p>用最通俗的话说一遍&lt;strong>指数映射、对数映射和测地线条件流&lt;/strong>在干什么。&lt;/p></description></item></channel></rss>