<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>RMan&#39;s Blog</title>
  
  
  <link href="/atom.xml" rel="self"/>
  
  <link href="https://www.rman.top/"/>
  <updated>2026-03-13T01:50:06.921Z</updated>
  <id>https://www.rman.top/</id>
  
  <author>
    <name>Linhao Luo</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>GFM-RAG: 用于大语言模型检索增强的图基础模型</title>
    <link href="https://www.rman.top/2025/03/01/gfm-rag/"/>
    <id>https://www.rman.top/2025/03/01/gfm-rag/</id>
    <published>2025-03-01T04:42:40.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>原标题：GFM-RAG: Graph Foundation Model for Retrieval Augmented Generation</p><p>论文链接：<a href="https://arxiv.org/pdf/2502.01113">https://arxiv.org/pdf/2502.01113</a></p><p>项目主页：<a href="https://rmanluo.github.io/gfm-rag/">https://rmanluo.github.io/gfm-rag/</a></p><p><strong>TL;DR</strong>: GFM-RAG是第一个适用于大语言模型检索增强的图基础模型。</p><h2 id="摘要"><a href="#摘要" class="headerlink" title="摘要"></a>摘要</h2><p>检索增强生成（RAG）在将知识集成到大语言模型（LLM）方面已被证明是有效的。然而，传统的RAG难以捕捉知识片段之间的复杂关系，这限制了它们在需要集成多来源知识的复杂推理中的表现。最近，图增强检索增强生成（GraphRAG）构建图结构来显式地对这些关系建模，从而实现更有效和高效的检索器。然而，它的性能仍然受到图结构内的噪声和不完整性的阻碍。为了解决这个问题，我们引入了一种用于检索增强生成的图基础模型（GFM）。GFM-RAG由图神经网络作为基本架构，该网络可以对图结构进行推理，以捕获复杂的查询-知识关系。具有8M参数的GFM在包含60个知识图、超过14M个三元组和700k个文档的大规模数据集上经历了两个阶段的训练过程。这为GFM-RAG带来了更强的性能和通用性，使其成为第一个适用于不可见数据集的图基础模型，无需任何微调即可进行检索。</p><h2 id="主要贡献"><a href="#主要贡献" class="headerlink" title="主要贡献"></a>主要贡献</h2><ol><li>文章提出了一种适用于大语言模型检索增强的图基础模型（GFM-RAG）,该模型由一种与查询依赖GNN提供支持，可以在单个步骤内实现高效的多步检索。</li><li>文章训练了一个参数量为8M的模型，标志着第一个可以直接应用于各种未知数据集的检索增强生成的图基础模型的诞生。</li><li>我们在三个多跳QA数据集和七个特定领域RAG数据集上评估了GFM-RAG，它在所有数据集上实现了最先进的性能，证明了它的有效、高效、通用性，以及成为进一步增强生成研究的基础模型的潜力。</li></ol><h2 id="模型"><a href="#模型" class="headerlink" title="模型"></a>模型</h2><p>GFM-RAG由三个主要部分组成：A. 构建知识图谱索引，从文档语料库中构建知识图谱索引；B. 图基础模型检索器（GFM retriever），在大规模数据集上预先训练，可根据任何用户查询和知识图谱索引检索文档；C. 文档排序和答案生成，对检索到的文档进行排序并生成最终答案。具体的GFM-RAG的框架以及图基础模型的训练过程如图1所示。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301125805-2025-03-01-12-58-06.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">图1 GFM-RAG的框架以及图基础模型的训练过程</div></center><h3 id="KG-index构建"><a href="#KG-index构建" class="headerlink" title="KG-index构建"></a>KG-index构建</h3><p>给定一组文档$D$，首先从文档中提取实体E和关系$R$以形成三元组$T$。然后，构造到文档的实体倒排索引$M\in{0,1}^{|E|\times|D|}$来记录每个文档中提到的实体。为了更好地捕捉知识之间的联系，需要进一步进行实体解析(entity resolution) ，在语义相似的实体之间添加额外的边$T^+$。</p><h3 id="图基础模型（GFM）检索器"><a href="#图基础模型（GFM）检索器" class="headerlink" title="图基础模型（GFM）检索器"></a>图基础模型（GFM）检索器</h3><p>查询依赖GNNs在捕获查询特定信息和对未见图的可泛化性方面表现出色，这对于GFM检索器至关重要，它允许GFM检索器根据用户查询动态调整消息传递过程，并在图中找到最相关的信息。可以表述为：$H_q^L=GNN_q(q,G,H^0)$，其中$H^0\in\mathbb{R}^{|E|\times d}$是初始实体特征，$G$是知识图谱，$q$是查询，$H_q^L$表示在查询$q$条件下经过$L$层查询以来的消息传递后更新的实体表示。</p><h4 id="查询初始化"><a href="#查询初始化" class="headerlink" title="查询初始化"></a>查询初始化</h4><p>给定一个查询$q$，先用文本嵌入模型将其编码成一个查询向量：$\mathbf{q}=\text{SentenceEmb}(q),\mathbf{q}\in\mathbb{R}^{d}$。然后用其初始化实体表示：</p><script type="math/tex; mode=display">H^0 = \begin{cases}        \mathbf{q}, & e\in E_q, \\        \mathbf{0}, & \text{otherwise}.    \end{cases}</script><p>其中$E_q$是查询$q$中的提到实体集合。</p><h4 id="查询依赖信息传播"><a href="#查询依赖信息传播" class="headerlink" title="查询依赖信息传播"></a>查询依赖信息传播</h4><p>查询依赖的消息传递将从问题实体向知识图中的其他实体传播信息，以捕捉它们与查询的相关性。</p><script type="math/tex; mode=display">三元组信息传递：m_e^{l+1} = \text{Msg}(h_e^l,g^{l+1}(h_r^l),h_{e'}^l), (e,r,e')\in G,\\实体信息聚合：h_e^{l+1} = \text{Update}(h_e^l,\text{Agg}(\{m_{e'}^{l+1} | e'\in N_r(e),r\in R\})).</script><p>经过$L$层消息传递后，最后的MLP层结合sigmoid函数将实体嵌入映射到与查询的相关性得分。</p><script type="math/tex; mode=display">P_q = \sigma(\text{MLP}(H_q^L)),~P_q\in\mathbb{R}^{|E|\times 1}</script><h4 id="训练目标"><a href="#训练目标" class="headerlink" title="训练目标"></a>训练目标</h4><p>GFM检索器的训练目标是最大化相关实体与查询的似然，可以通过最小化二进制交叉熵（binarycross-entropy, BCE）损失来优化：</p><script type="math/tex; mode=display">L_{\text{BCE}} = -\frac{1}{|A_q|}\sum_{e\in A_q} \log P_q(e) - \frac{1}{|E^{\texttt{-}}|}\sum_{|E^{\texttt{-}}|} \log (1-P_q(e)),</script><p>其中$A_q$表示与查询q相关的目标实体集合，$E^{\texttt{-}}$是负样本实体集合。</p><p>然而，由于目标实体的稀疏性，BCE损失可能存在梯度消失问题。为了解决这个问题，我们进一步引入了排序损失来最大化正负实体之间的差值：</p><script type="math/tex; mode=display">L_{\text{RANK}} = - \frac{1}{|A_q|}\sum_{e\in A_q} \frac{P_q(e)}{\sum_{e'\in E^{\texttt{-}}} P_q(e')}</script><p>最终的训练目标是BCE损失和排名损失的加权组合：</p><script type="math/tex; mode=display">L = \alpha L_{\text{BCE}} + (1-\alpha) L_{\text{RANK}}</script><h4 id="训练任务"><a href="#训练任务" class="headerlink" title="训练任务"></a>训练任务</h4><p>GFM-RAG的训练分为两个阶段：1）自监督预训练阶段，通过在大规模知识图谱上采样的三元组生成人造查询进行训练，增强其图推理的能力；2）微调阶段，在真实标注的数据集上进行微调，以提高模型在下游任务的性能和泛化能力。</p><h3 id="文档排序和答案生成"><a href="#文档排序和答案生成" class="headerlink" title="文档排序和答案生成"></a>文档排序和答案生成</h3><p>给定GFM检索器预测的实体相关性得分$P_q\in\mathbb{R}^{|E|\times 1}$，我们首先检索相关度得分最高的top-T实体$E_q^{T}$如下：</p><script type="math/tex; mode=display">E_q^{T} = \arg\text{top-}T(P_q),~E_q^{T}=\{e_1,\ldots,e_T\}</script><p>这些检索到的实体被文档排序器用来获得最终的文档。为了减少热门实体的影响，我们通过它们作为文档倒排索引M\in{0,1}^{|E|\times|D|}中提到的实体的频率的倒数来对实体进行加权，并通过将权重相加来计算最终的文档相关性分数：</p><script type="math/tex; mode=display">F_e = \begin{cases}        \frac{1}{\sum_{d\in D} M[e,d]}, & e\in E_q^{T}, \\        0, & \text{otherwise},    \end{cases} \\P_d = M^{\top}F_e,~P_d\in\mathbb{R}^{|D|\times 1}</script><p>根据文档相关性得分$P_d$检索top-K文档，并以检索增强生成方式馈送到LLM的上下文中，以生成最终答案：</p><script type="math/tex; mode=display">D^K = \arg\text{top-}K(P_d),~D^K=\{D_1,\ldots,D_K\}, \\    a = \text{LLM}(q,D^K).</script><h2 id="实验设置"><a href="#实验设置" class="headerlink" title="实验设置"></a>实验设置</h2><h3 id="数据集"><a href="#数据集" class="headerlink" title="数据集"></a>数据集</h3><p>首先评估了GFM-RAG在三种广泛使用的多跳QA数据集上的有效性，包括Hot-potQA、MuSiQue、2WikiMultiHopQA (2Wiki)。</p><p>此外，文章还评估了GFM-RAG在来自三个领域的七个RAG数据集上的性能，以此来证明GFM-RAG作为基础模型的通用性。(1) biomedical: PubMedQ; (2) customer support: DelucionQ, TechQ, ExpertQA, EManual; (3) general knowledge: MS Marco, HAGRID。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301142814-2025-03-01-14-28-15.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表1 用于测试的数据集与知识图谱索引的统计</div></center><h3 id="对比方法"><a href="#对比方法" class="headerlink" title="对比方法"></a>对比方法</h3><p>在实验中，文章与三个类别下几个广泛使用的检索方法进行了比较：</p><p>（1）单步朴素方法：BM2、Contriever、GTR、ColBERTv2、RAPTOR、Proposition；</p><p>（2）图增强方法：LightRAG、HippoRAG；</p><p>（3）多步骤方法：IRCoT。</p><h3 id="评价指标"><a href="#评价指标" class="headerlink" title="评价指标"></a>评价指标</h3><p>对于检索性能，文章使用recall@2 (R@2)和recall@5 (R@5)作为评估指标。</p><p>对于最终的QA性能，文章使用之前研究中的EM分数和F1分数。</p><h3 id="实现细节"><a href="#实现细节" class="headerlink" title="实现细节"></a>实现细节</h3><p>GFM检索器由6个与查询相关的消息传递层实现，隐藏维度设置为512。采用预训练的all-mpnet-v2作为句子嵌入模型。GFM检索器的总参数为8M，在8台NVIDIA A100(80G)上进行训练，batch size为4，learning rate为5e-4, loss weight α= 0.3。训练数据包含60公斤数和超过14M个三元组，这些三元组是从训练集中提取的700k个文档中构建的。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301142725-2025-03-01-14-27-25.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表2 用于训练的查询文档与知识图谱的统计</div></center><h2 id="实验结果"><a href="#实验结果" class="headerlink" title="实验结果"></a>实验结果</h2><h3 id="检索性能"><a href="#检索性能" class="headerlink" title="检索性能"></a>检索性能</h3><p>文章首先对三个多跳QA数据集的基线进行了GFM-RAG检索性能的评估。如表3所示，GFM-RAG在所有数据集上都取得了最好的性能，在HotpotQA、MuSiQue和2Wiki上R@2分别比SOTA IRCoT + HippoRAG高出16.8%、8.3%和19.8%。实验结果证明了GFM-RAG在多跳检索中的有效性。从结果可以看出，图增强的HippoRAG优于单纯的单步检索器（如BM25、RAPTOR），这凸显了图结构在多跳检索中的重要性。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301143040-2025-03-01-14-30-40.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表3 检索性能比较</div></center><h3 id="问答性能"><a href="#问答性能" class="headerlink" title="问答性能"></a>问答性能</h3><p>第二，文章评估了GFM-RAG的QA性能，这直接影响了用户的检索质量。文章选用GPT-4o-mini作为大语言模型，并使用检索到的前5个文档生成答案。从表4所示的结果来看，单步GFM-RAG已经在所有其他基线上取得了最先进的性能。同时，我们还将GFM-RAG与IRCoT相结合，进行多步检索和推理，进一步提高了EM在三个数据集上的性能，分别提高了8.5%、21.2%和3.9%。结果表明，GFM-RAG与任意多步框架在多跳推理任务中的有效性和良好的兼容性。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301143208-2025-03-01-14-32-08.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表4 问答性能对比</div></center><h3 id="效率分析"><a href="#效率分析" class="headerlink" title="效率分析"></a>效率分析</h3><p>GFM-RAG在单步进行多步推理方面取得了很高的效率。如表5所示，朴素的单步推理方法效率最高，但性能并不令人满意。诚然，多步骤框架IRCoT可以提高性能，但由于要使用LLMs进行迭代检索和推理，其计算成本较高。相比之下，GFM-RAG在单步GNN推理中进行多跳推理，比单步方法更有效，比多步方法更高效。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301143307-2025-03-01-14-33-08.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表5 检索效率和性能比较</div></center><h3 id="消融实验"><a href="#消融实验" class="headerlink" title="消融实验"></a>消融实验</h3><p>文章进行了消融研究，来考察GFM-RAG中不同组成部分的有效性，包括不同的句子嵌入模型（表6）、预训练策略（表7）和损失加权策略（表8）。结果表明，GFM-RAG对不同的句子嵌入模型并不敏感，预训练策略和损失加权策略对GFM-RAG的性能都至关重要。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301143451-2025-03-01-14-34-51.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表6 GFM-RAG中使用的不同句子嵌入模型的比较</div></center><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301143510-2025-03-01-14-35-10.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表7 GFM-RAG中预训练和微调的有效性</div></center><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08); width: 60%;"     src="https://image.rman.top/blog/20250301143529-2025-03-01-14-35-29.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表8 GFM-RAG中损失加权策略的影响</div></center><h3 id="模型的可泛化性"><a href="#模型的可泛化性" class="headerlink" title="模型的可泛化性"></a>模型的可泛化性</h3><p>为了证明GFM-RAG作为基础模型的通用性，文章在不做任何微调的情况下，在七个特定领域的RAG数据集上测试了GFM-RAG的性能（R@5）。首先，根据每个数据集中的文档建立知识图谱索引。接着，在给定查询的情况下，我们使用预先训练好的GFM Retriever，在相应KG-index的帮助下检索出Top-K文档。如图2所示，GFM-RAG在所有数据集上都取得了最佳性能，平均比SOTA HippoRAG高出18.9%，证明了GFM-RAG作为基础模型的通用性，无需任何微调即可直接应用于各种未见数据集。此外，表9中的结果表明，GFM-RAG具有很强的可移植性，可在特定领域数据集上进行微调，从而进一步提高性能。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08); width: 60%;"     src="https://image.rman.top/blog/20250301143829-2025-03-01-14-38-30.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">图2 模型性能和通用性比较。</div></center><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301144001-2025-03-01-14-40-02.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表9 模型性能（R@5）和可迁移性比较</div></center><h3 id="模型性能缩放定律"><a href="#模型性能缩放定律" class="headerlink" title="模型性能缩放定律"></a>模型性能缩放定律</h3><p>我们进一步研究了GFM-RAG的神经缩放定律，它量化了模型性能如何随训练数据规模和模型参数大小而增长。如图3所示，GFM-RAG的性能（MRR：z）与训练数据（x）和模型大小（y）呈良好的比例关系：$z \propto 0.24x^{0.05} + 0.11y^{0.03}$，可以用幂律缩放定律来拟合。结果表明了GFM-RAG作为基础模型的可扩展性和进一步提升的潜力。</p><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08); width: 60%;"     src="https://image.rman.top/blog/20250301144239-2025-03-01-14-42-39.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">图3 GFM-RAG的模型性能缩放定律。</div></center><h3 id="模型的可解释性"><a href="#模型的可解释性" class="headerlink" title="模型的可解释性"></a>模型的可解释性</h3><p>GFM-RAG由于多层的GNN结构，使其具有很好的多跳推理能力。我们可以通过展现GNN捕捉到的重要路径信息，来解释其推理过程。路径对最终预测的重要性可以通过最终预测分对每一层（跳）的三元组的偏导数来量化。</p><p>如图4所示，GFM-RAG在多跳推理中捕捉到了重要的路径信息，这有助于解释模型的推理流程。</p><script type="math/tex; mode=display">s_1,s_2,\ldots,s_L=\arg\mathop{\text{top-}}k\frac{\partial p_e(q)}{\partial s_l}</script><center>    <img style="border-radius: 0.3125em;    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);"     src="https://image.rman.top/blog/20250301144616-2025-03-01-14-46-16.png">    <br>    <div style="color:orange; border-bottom: 1px solid #d9d9d9;    display: inline-block;    color: #999;    padding: 2px;">表10 GFM捕获的用于多跳推理的重要路径。</div></center><h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><p>这篇文章介绍了首个用于检索增强生成的图基础模型。通过利用知识图索引，GFM-RAG对知识与文档之间的复杂关系进行了明确建模，从而促进了更有效、更高效的检索过程。依赖于在大规模数据集上进行预训练的GNN，GFM-RAG可以有效地对图结构执行多跳推理，从而在一个步骤中找到相关的知识边。在三个基准数据集和七个特定领域数据集上进行的广泛实验表明，GFM-RAG在有效性、效率和通用性方面明显优于最先进的方法。同时，GFM-RAG符合扩展规律，这也表明它有潜力扩展到更大的数据集。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;原标题：GFM-RAG: Graph Foundation Model for Retrieval Augmented Generation&lt;/p&gt;
&lt;p&gt;论文链接：&lt;a href=&quot;https://arxiv.org/pdf/2502.01113&quot;&gt;https://arx
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="KG" scheme="https://www.rman.top/tags/KG/"/>
    
      <category term="NLP" scheme="https://www.rman.top/tags/NLP/"/>
    
      <category term="GFM" scheme="https://www.rman.top/tags/GFM/"/>
    
      <category term="LLM" scheme="https://www.rman.top/tags/LLM/"/>
    
      <category term="RAG" scheme="https://www.rman.top/tags/RAG/"/>
    
      <category term="GNN" scheme="https://www.rman.top/tags/GNN/"/>
    
  </entry>
  
  <entry>
    <title>在docker中运行cisco anyconnect并支持使用sso + 2fa 登录</title>
    <link href="https://www.rman.top/2023/12/20/docker-openconnect-sso/"/>
    <id>https://www.rman.top/2023/12/20/docker-openconnect-sso/</id>
    <published>2023-12-20T01:35:33.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>学校使用了cisco anyconnect作为VPN，但是其不支持修改路由，必须使用全局代理，极大降低了正常网络访问的速度。于是就打算将其运行在docker中，通过代理的方式访问。</p><p>简单搜搜索了一下，发现有<a href="https://www.infradead.org/openconnect/">openconnect</a>这个开源的解决方案。但是使用后发现，学校的VPN使用了sso + 2fa的登录方式，openconnect并不支持。</p><p>进一步搜索之后，发现了<a href="https://github.com/vlaci/openconnect-sso">openconnect-sso</a>这个项目，其在openconnect基础上封装了一层，调用网页浏览器，支持sso + 2fa登录。因此我打算将其封装到docker中，并通过X11访问网页浏览器，完成认证。</p><h2 id="Docker-openconnect-sso"><a href="#Docker-openconnect-sso" class="headerlink" title="Docker-openconnect-sso"></a>Docker-openconnect-sso</h2><p>最终项目地址：<a href="https://github.com/RManLuo/docker-openconnect-sso">https://github.com/RManLuo/docker-openconnect-sso</a></p><h2 id="使用方法"><a href="#使用方法" class="headerlink" title="使用方法"></a>使用方法</h2><h3 id="配置docker环境"><a href="#配置docker环境" class="headerlink" title="配置docker环境"></a><a href="https://docs.docker.com/get-docker/">配置docker环境</a></h3><h3 id="配置X11环境"><a href="#配置X11环境" class="headerlink" title="配置X11环境"></a>配置X11环境</h3><h4 id="Windows"><a href="#Windows" class="headerlink" title="Windows"></a><a href="https://sourceforge.net/projects/vcxsrv/">Windows</a></h4><blockquote><p><a href="https://www.cnblogs.com/KylinBlog/p/16588037.html">教程</a></p><ol><li>在 Windows 上下载 VcXsrv 并安装</li><li>第一步的设置窗口状态怎么选关系不大，我一般是用 One large window ，默认的 Multiple windows 在多屏情况下显示会有一些问题。然后 Display number 可以用默认的 -1 ，或者设置成 0 </li><li>下一步，选择 Start no client 。</li><li>下一步，选项全部勾上 (特别是“Disable access control”)，Additional parameters 不用管。</li></ol></blockquote><h4 id="Mac"><a href="#Mac" class="headerlink" title="Mac"></a><a href="https://sourceforge.net/projects/xquartz/">Mac</a></h4><blockquote><p><a href="https://www.wuweixin.com/2022/02/23/macos-install-and-using-xquartz/">教程</a></p><ol><li>安装XQuartz: <code>brew install xquartz --cask</code></li><li>安装后通过 应用-实用工具-XQuartz 可启动 XQuartz 程序</li><li>在命令行中设置 DISPLAY 环境变量：<code>export DISPLAY=:0</code>，关闭access control：<code>xhost +</code></li></ol></blockquote><h3 id="启动docker容器"><a href="#启动docker容器" class="headerlink" title="启动docker容器"></a>启动docker容器</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -itd --privileged --name=anyconnect-sso-x11 -v /dev/shm:/dev/shm -v /tmp/.X11-unix:/tmp/.X11-unix -e SERVER_NAME=<span class="variable">$&#123;SERVER_NAME&#125;</span> -e USER_NAME=<span class="variable">$&#123;USER_NAME&#125;</span> -e DISPLAY=host.docker.internal:0.0 -p 127.0.0.1:10081:1080 --restart=unless-stopped rmanluo/openconnect-sso-x11:latest</span><br></pre></td></tr></table></figure><p>请将 SERVER_NAME 和 USER_NAME 替换为您自己的。</p><p>样例：</p><blockquote><p>docker run -itd —privileged —name=anyconnect-sso-x11 -v /dev/shm:/dev/shm -v /tmp/.X11-unix:/tmp/.X11-unix -e SERVER_NAME=vpn.xx.edu -e USER_NAME=xxx@xx.edu -e DISPLAY=host.docker.internal:0.0 -p 127.0.0.1:10081:1080 —restart=unless-stopped rmanluo/openconnect-sso-x11:latest</p></blockquote><p>理论会弹出浏览器窗口，输入密码即可登录。</p><blockquote><p>Note 如果未弹出浏览器窗口，请检查X11是否配置正确。 </p></blockquote><p><img src="https://github.com/RManLuo/docker-openconnect-sso/raw/master/resources/login.png" alt=""></p><p>完成2FA验证</p><p><img src="https://github.com/RManLuo/docker-openconnect-sso/raw/master/resources/2fa.png" alt=""></p><p>docker会在本地10081端口启动socks5代理，可以通过代理访问内网资源。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;学校使用了cisco anyconnect作为VPN，但是其不支持修改路由，必须使用全局代理，极大降低了正常网络访问的速度。于是就打算将其运行在docker中，通过代理的方式访问。&lt;/p&gt;
&lt;p&gt;简单搜搜索了一下，发现有&lt;a href=&quot;https://www.infrad
      
    
    </summary>
    
    
      <category term="技术分享" scheme="https://www.rman.top/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/"/>
    
    
      <category term="cisco" scheme="https://www.rman.top/tags/cisco/"/>
    
      <category term="VPN" scheme="https://www.rman.top/tags/VPN/"/>
    
      <category term="docker" scheme="https://www.rman.top/tags/docker/"/>
    
  </entry>
  
  <entry>
    <title>Editing Language Model-based Knowledge Graph Embeddings</title>
    <link href="https://www.rman.top/2023/05/23/Edit-PLM-KGE/"/>
    <id>https://www.rman.top/2023/05/23/Edit-PLM-KGE/</id>
    <published>2023-05-23T02:25:44.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h2><ol><li><p>KGs store facts in their graph structure. KGs embedding represents KGs in a low-dimension vector space which preserves the inherent structure of KGs.</p></li><li><p>Recent studies apply PLMs to encode text information and generate representations for long-tail and emerging entities.</p></li><li><p><strong>KG embeddings with PLMs are usually deployed as static, which is challenging to modify without re-training.</strong></p><p><img src="https://image.rman.top/blog202305231021500.png" alt=""></p></li></ol><h2 id="KG-embeddings-editing"><a href="#KG-embeddings-editing" class="headerlink" title="KG embeddings editing"></a>KG embeddings editing</h2><p>Editing language model-based KG embeddings, which aims to enable <strong>data-efficient and fast updates to KG embeddings for a small region of parametric space</strong> without influencing the performance of the rest.</p><p><img src="https://image.rman.top/blog202305231021501.png" alt=""></p><p>KG embeddings editing= <em>learning-to-update</em> problems.</p><h2 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h2><ol><li>Propose a new task of editing language model-based KG embeddings and present twodatasets.</li><li>Introduce the KGEditor that can efficiently modify incorrect knowledge or add new knowledge.</li></ol><h2 id="Methodology"><a href="#Methodology" class="headerlink" title="Methodology"></a>Methodology</h2><h3 id="Task-Definition"><a href="#Task-Definition" class="headerlink" title="Task Definition"></a>Task Definition</h3><p>KG: $G=(\mathcal{E},\mathcal{R},\mathcal{T})$</p><p><strong>EDIT task</strong>: $(h,r,y,a)$ or $(y,r,h,a)$, $y$ denote the wrong or outdated entity, $a$ denote the target entity we want to replace.</p><p>Example:<br><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;Barack Obama, president of, U.S.A.&gt; =&gt; &lt;Barack Obama, president of, U.S.A., Joe Biden&gt;</span><br></pre></td></tr></table></figure><br><strong>ADD task: </strong>Implement new knowledge into the model</p><p><img src="https://image.rman.top/blog202305231021502.png" alt=""></p><h3 id="Evaluation-principles"><a href="#Evaluation-principles" class="headerlink" title="Evaluation principles:"></a><strong>Evaluation principles:</strong></h3><ol><li><p>Knowledge reliability: edited or newly added knowledge should be correctly inferred=&gt; Knowledge graph completion metrics: <strong>Success\@1</strong></p></li><li><p>Knowledge locality: editing KG embeddings will not affect the rest of other facts=&gt; <strong>Retain Knowledge (RK\@k).</strong></p><p><img src="https://image.rman.top/blog202305231021503.png" alt=""></p><p>The entities predicted by the original model are still correctly inferred by the edited model.</p><p><strong>Edited Knowledge Rate of Change </strong>and <strong>Retaining Knowledge Rate of Change</strong></p><p><img src="https://image.rman.top/blog202305231021504.png" alt=""></p></li><li><p>Knowledge efficiency: modify a model with low training resources=&gt;<strong>number of tuning parameters</strong></p></li></ol><h3 id="Datasets"><a href="#Datasets" class="headerlink" title="Datasets"></a>Datasets</h3><p><img src="https://image.rman.top/blog202305231021505.png" alt=""></p><p>Pre-process: Remove simple facts can be easily predicted by PLMs.</p><p>Edit task:</p><ol><li>Training: KGs generated by link prediction model (could contain error)</li><li>Testing: original KGs</li></ol><p>ADD task:</p><ol><li>Training: original KGs.</li><li>Testing: inductive new facts.</li></ol><h3 id="PLMs-based-KGE"><a href="#PLMs-based-KGE" class="headerlink" title="PLMs-based KGE"></a>PLMs-based KGE</h3><p>Finetuning KGE</p><p><img src="https://image.rman.top/blog202305231021506.png" alt=""></p><p><img src="https://image.rman.top/blog202305231021507.png" alt=""></p><p>Prompt tuning KGE</p><p><img src="https://image.rman.top/blog202305231021508.png" alt=""></p><p><img src="https://image.rman.top/blog202305231021509.png" alt=""></p><h3 id="KGE-Editing-baselines"><a href="#KGE-Editing-baselines" class="headerlink" title="KGE Editing baselines"></a>KGE Editing baselines</h3><p>External model-based editor</p><p>Edit wrong knowledge in language models by utilizing a hyper network to <strong>predict the weight update</strong> during inference.</p><p><img src="https://image.rman.top/blog202305231021510.png" alt="">Cons: Need to fine tune a large number of parameters.</p><p>Additional parameter-based editor</p><p>Modify the output by another small model.</p><p><img src="https://image.rman.top/blog202305231021511.png" alt=""></p><p>Cons:Poor in performance.</p><h4 id="KGE-editor"><a href="#KGE-editor" class="headerlink" title="KGE editor"></a>KGE editor</h4><p><img src="https://image.rman.top/blog202305231021512.png" alt=""></p><p><img src="https://image.rman.top/blog202305231021513.png" alt=""></p><h2 id="Results"><a href="#Results" class="headerlink" title="Results"></a>Results</h2><p><img src="https://image.rman.top/blog202305231021367.png" alt=""></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;KGs store facts in their grap
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="PLM" scheme="https://www.rman.top/tags/PLM/"/>
    
      <category term="KG" scheme="https://www.rman.top/tags/KG/"/>
    
      <category term="NLP" scheme="https://www.rman.top/tags/NLP/"/>
    
  </entry>
  
  <entry>
    <title>Incorporating Structured Sentences with Time-enhanced BERT for Fully-inductive Temporal Relation Prediction</title>
    <link href="https://www.rman.top/2023/04/24/Time-enhanced-BERT-for-KGC/"/>
    <id>https://www.rman.top/2023/04/24/Time-enhanced-BERT-for-KGC/</id>
    <published>2023-04-24T06:08:17.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Motivations"><a href="#Motivations" class="headerlink" title="Motivations"></a>Motivations</h2><ol><li>Traditional embedding-based TKGC models (TKGE) rely on structured connections cannot handle unseen entities.</li><li>Symbolic rule methods suffer from inflexibility of symbolic logic.</li><li>PLMs are pre-trained in large-scale corpora, so they are not adapted to particular domains and cannot handle temporally-scoped facts.</li></ol><h2 id="Previous-works"><a href="#Previous-works" class="headerlink" title="Previous works"></a>Previous works</h2><p><strong>TLogic</strong> utilizes temporal random walks to get temporal logical rules in symbolic form. When TLogic applies the found rules to answer questions, it must precisely match each relation and timestamp in the rules, including relation types, relation order and time order. If there are no matching body groundings in the graph, then no answers will be predicted for the given questions.</p><p><img src="https://image.rman.top/blog20230424135121.png" alt=""></p><p><img src="https://image.rman.top/blog20230424135122.png" alt=""></p><p>Previous PLMs are treated as a simple text encoder to incorporate text information, which ignores the structure information.</p><p><img src="https://image.rman.top/blog20230424135123.png" alt=""></p><h2 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h2><ol><li>Propose SST-BERT, a model that incorporates <strong>Structured Sentences</strong> (constructed from relation paths and historical descriptions) with <strong>Time-enhanced BERT</strong></li><li>The structured sentences enable SST-BERT to learn in semantic space, overcoming the symbolic restrictions in TLogic.</li><li>Propose a pre-training task that involves <strong>time masking</strong> to enable SST-BERT to focus on time-sensitive facts.</li></ol><h2 id="Methods"><a href="#Methods" class="headerlink" title="Methods"></a>Methods</h2><p><img src="https://image.rman.top/blog20230424135124.png" alt=""></p><h3 id="Structured-sentences"><a href="#Structured-sentences" class="headerlink" title="Structured sentences"></a>Structured sentences</h3><p><img src="https://image.rman.top/blog20230424135125.png" alt=""></p><p>They convert symbolic edges into natural language sentences and capture the semantic logic hidden behind the relation paths.</p><p><em>Limitations: need to define a prompt template for each relation type.</em></p><p>They argue that the old facts in the perspective of time offer vital background information for the target quadruples</p><p>They randomly select one edge which is not included in the relation paths as an old fact and regard it as a historical description to reflect the evolution of facts.</p><p>Usually, these historical descriptions are semantically relevant to target quadruples and act as rich historical knowledge related to target entities. Furthermore, in the fully-inductive setting, the degrees of most entities are small, which means the ideal paths connecting target entities are limited and result in little information</p><h2 id="Time-Masking-Pre-training-Module"><a href="#Time-Masking-Pre-training-Module" class="headerlink" title="Time Masking Pre-training Module"></a>Time Masking Pre-training Module</h2><p>PLMs are pre-trained in noisy and generally purposed opendomain corpora, so PLMs are not effective for applications on timespecific downstream tasks</p><p><strong>Construct pre-training corpus using structured sentences extracted from all training quadruples.</strong></p><p>Because each edge in the training TKGs is considered positive, all the generated sentences for it can be regarded as logically supporting the establishment of the edge to some extent.</p><h3 id="Time-masking-pre-training"><a href="#Time-masking-pre-training" class="headerlink" title="Time-masking pre-training"></a>Time-masking pre-training</h3><p>They focus on the time tokens, and 25% of the temporal expressions in $T$ are randomly sampled.</p><p><img src="https://image.rman.top/blog20230424135126.png" alt=""></p><h2 id="TempBert-Scoring-Module"><a href="#TempBert-Scoring-Module" class="headerlink" title="TempBert Scoring Module"></a>TempBert Scoring Module</h2><p><img src="https://image.rman.top/blog20230424135127.png" alt=""></p><p>Use embedding at [CLS] generated by PLMs as entity/relation representations.</p><p><img src="https://image.rman.top/blog20230424135128.png" alt=""></p><p>Time-encoding</p><p><img src="https://image.rman.top/blog20230424135129.png" alt=""></p><p>Score functions</p><p><img src="https://image.rman.top/blog20230424135130.png" alt=""></p><h2 id="Training-Objects"><a href="#Training-Objects" class="headerlink" title="Training Objects"></a>Training Objects</h2><p><img src="https://image.rman.top/blog20230424135131.png" alt=""></p><p>For each quadruple, we can have $N$ sentences, which denotes $N$ predictions. Weight them by timestamps.</p><p><img src="https://image.rman.top/blog20230424135132.png" alt=""></p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><p>Transductive</p><p><img src="https://image.rman.top/blog20230424135133.png" alt="">Inductive</p><p><img src="https://image.rman.top/blog20230424135134.png" alt="">Explainability</p><p><img src="https://image.rman.top/blog20230424135135.png" alt=""></p><h2 id="Problems"><a href="#Problems" class="headerlink" title="Problems"></a>Problems</h2><p>Information leakage in the pretrained PLMs?</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Motivations&quot;&gt;&lt;a href=&quot;#Motivations&quot; class=&quot;headerlink&quot; title=&quot;Motivations&quot;&gt;&lt;/a&gt;Motivations&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;Traditional embedding-based 
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="知识图谱" scheme="https://www.rman.top/tags/%E7%9F%A5%E8%AF%86%E5%9B%BE%E8%B0%B1/"/>
    
      <category term="BERT" scheme="https://www.rman.top/tags/BERT/"/>
    
      <category term="预训练语言模型" scheme="https://www.rman.top/tags/%E9%A2%84%E8%AE%AD%E7%BB%83%E8%AF%AD%E8%A8%80%E6%A8%A1%E5%9E%8B/"/>
    
      <category term="时序" scheme="https://www.rman.top/tags/%E6%97%B6%E5%BA%8F/"/>
    
  </entry>
  
  <entry>
    <title>Discriminative Jackknife: Quantifying Uncertainty in Deep Learning via Higher-Order Influence Functions</title>
    <link href="https://www.rman.top/2022/10/23/jackknife/"/>
    <id>https://www.rman.top/2022/10/23/jackknife/</id>
    <published>2022-10-23T07:06:43.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h2><p><strong>TL;DR: The major motivation behind this method is: they use Jackknife to estimate the distribution of error, then it use a threshold to find the upper- and lower-bound of the error in the distribution, which is used for quantifying the uncertainty.</strong></p><p>Quantifying the uncertainty over the predictions of existing deep learning models remains a challenging problem.</p><p>Deep learning models are increasingly popular in various application domains. A key question often asked of such model is “Can we trust this particular model prediction?” This is highly relevant applications wherein predictions are used to inform critical decision-making.</p><p>Existing methods for uncertainty estimation are based on Bayesian neural network. They do not guarantee (1) <em>cover</em> the true prediction targets with high probability (2) <em>discriminate</em> between high- and low-confidence prediction.</p><p><img src="https://image.rman.top/blog/20221023160357-2022-10-23-16-03-58.png" alt="20221023160357-2022-10-23-16-03-58"></p><ul><li><p><strong>Frequentist coverage</strong>: denotes whether the estimated confidence interval cover the data points.</p></li><li><p><strong>Discrimination</strong>: denotes whether the model is able to discriminate<br>high-confidence predictions (regions with dense training data) and low-confidence ones (regions with scarce training data).</p></li></ul><p>Existing methods for uncertainty estimation are based predominantly on Bayesian neural networks. </p><ul><li>Bayesian neural networks require significant modifications to the training procedure. </li><li>Approximate the posterior distributions could jeopardize both the coverage and discrimination performance of the resulting credible intervals.</li></ul><h2 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h2><ul><li><p>Propose the <em>discriminative jackknife</em> (DJ) to estimate the uncertainty over samples inspired by the jackknife leave-one-out (LOO) re-sampling procedure </p></li><li><p>To avoid exhaustively re-training the model for each sample, they adopt the <em>high-order influence function</em> to approximate the impact of each sample.</p></li><li><p>DJ is post-hoc to the model training. It is capable of improving coverage and discrimination without any modifications to the underlying predictive model.</p></li></ul><h2 id="Preliminaries"><a href="#Preliminaries" class="headerlink" title="Preliminaries"></a>Preliminaries</h2><h3 id="Learning-setup"><a href="#Learning-setup" class="headerlink" title="Learning setup"></a>Learning setup</h3><p>Considering a standard supervised learning setup, we try to minimize the prediction loss on the training data $\mathcal{D}<em>n = {(x_i, y_i)}</em>{i=1}^n$.<br><img src="https://image.rman.top/blog/20221023163759-2022-10-23-16-37-59.png" alt="20221023163759-2022-10-23-16-37-59"></p><h3 id="Uncertainty-Quantification"><a href="#Uncertainty-Quantification" class="headerlink" title="Uncertainty Quantification"></a>Uncertainty Quantification</h3><p><strong>We aim to estimate the uncertainty in the model’s prediction though the pointwise confidence interval $\mathcal{C}(x;\hat{\theta})$</strong>.<br><img src="https://image.rman.top/blog/20221023164043-2022-10-23-16-40-43.png" alt="20221023164043-2022-10-23-16-40-43"><br>The degree of uncertainty in the model’s prediction is quantified by the <em>interval width</em><br><img src="https://image.rman.top/blog/20221023164130-2022-10-23-16-41-31.png" alt="20221023164130-2022-10-23-16-41-31"></p><h4 id="Frequentist-coverage"><a href="#Frequentist-coverage" class="headerlink" title="Frequentist coverage"></a>Frequentist coverage</h4><p>This is satisfied if the confidence  interval $\mathcal{C}(x;\hat{\theta})$ covers the true target $y$ with a prespecified coverage probability of $(1-\alpha), \alpha \in (0,1)$.<br><img src="https://image.rman.top/blog/20221023164623-2022-10-23-16-46-23.png" alt="20221023164623-2022-10-23-16-46-23"></p><h4 id="discrimination"><a href="#discrimination" class="headerlink" title="discrimination"></a>discrimination</h4><p>The confidence interval is wider for test points with less accurate predictions.<br><img src="https://image.rman.top/blog/20221023165455-2022-10-23-16-54-55.png" alt="20221023165455-2022-10-23-16-54-55"></p><h2 id="Discriminative-Jackknife"><a href="#Discriminative-Jackknife" class="headerlink" title="Discriminative Jackknife"></a>Discriminative Jackknife</h2><h3 id="Classical-Jackknife"><a href="#Classical-Jackknife" class="headerlink" title="Classical Jackknife"></a>Classical Jackknife</h3><p>The jackknife quantifies predictive uncertainty in terms of the average prediction error, which is estimated via leave-one-out (LOO) construction found by systematically leaving out each sample in $\mathcal{D}_n$, and evaluating the error of the restrained model on the left-out samples.</p><p>For a target coverage of $(1-\alpha)$, the native jackknife is<br><img src="https://image.rman.top/blog/20221023170543-2022-10-23-17-05-43.png" alt="20221023170543-2022-10-23-17-05-43"><br><img src="https://image.rman.top/blog/20221023170626-2022-10-23-17-06-27.png" alt="20221023170626-2022-10-23-17-06-27"><br>$\mathcal{\hat Q}_\alpha^+(\mathcal{R})$: $(1-\alpha)(n+1)$-th smallest element of $\mathcal{R}$.</p><p>The interval width is constant, which renders discrimination impossible.<br><img src="https://image.rman.top/blog/20221023171754-2022-10-23-17-17-54.png" alt="20221023171754-2022-10-23-17-17-54"></p><h3 id="DJ-Confidence-Intervals"><a href="#DJ-Confidence-Intervals" class="headerlink" title="DJ Confidence Intervals"></a>DJ Confidence Intervals</h3><p><img src="https://image.rman.top/blog/20221023172307-2022-10-23-17-23-07.png" alt="20221023172307-2022-10-23-17-23-07"><br>The $\mathcal{G}_{\alpha,\gamma}$ is a quantile function applied on the elements of the sets of <em>marginal prediction errors $\mathcal{R}$</em> and <em>local prediction variability $\mathcal{V}$</em>. </p><ul><li><p>The prediction error is constant, i.e., does not depend on $x$, hence it only contributes to coverage but does not contribute to discrimination.</p></li><li><p>The local variability term depends on $x$, hence it fully determines the discrimination performance.</p></li></ul><p><img src="https://image.rman.top/blog/20221023175514-2022-10-23-17-55-14.png" alt="20221023175514-2022-10-23-17-55-14"></p><p>The confidence interval is bounded by<br><img src="https://image.rman.top/blog/20221023175929-2022-10-23-17-59-29.png" alt="20221023175929-2022-10-23-17-59-29"></p><h3 id="Efficient-Implementation-via-Influence-Functions"><a href="#Efficient-Implementation-via-Influence-Functions" class="headerlink" title="Efficient Implementation via Influence Functions"></a>Efficient Implementation via Influence Functions</h3><p><img src="https://image.rman.top/blog/20221023224929-2022-10-23-22-49-29.png" alt="20221023224929-2022-10-23-22-49-29"></p><p>Approximate the $\hat\theta_i$ using the high-order influence function.<br>Influence functions enable efficient computation of the effect of a training data point $(x_i,y_i)$ on $\hat\theta$. This is achieved by evaluating the change in $\hat\theta$, if $(x_i,y_i)$ was up-weighted by a small factor $\epsilon$.</p><p><img src="https://image.rman.top/blog/20221023232505-2022-10-23-23-25-06.png" alt="20221023232505-2022-10-23-23-25-06"><br><img src="https://image.rman.top/blog/20221023233142-2022-10-23-23-31-42.png" alt="20221023233142-2022-10-23-23-31-42"><br>Removing a training point is equivalent to upweighting it by $\frac{-1}{n}$.<br><img src="https://image.rman.top/blog/20221023233701-2022-10-23-23-37-01.png" alt="20221023233701-2022-10-23-23-37-01"><br><img src="https://image.rman.top/blog/20221023231913-2022-10-23-23-19-13.png" alt="20221023231913-2022-10-23-23-19-13"></p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><p><img src="https://image.rman.top/blog/20221023235450-2022-10-23-23-54-52.png" alt="20221023235450-2022-10-23-23-54-52"><br><img src="https://image.rman.top/blog/20221023235509-2022-10-23-23-55-10.png" alt="20221023235509-2022-10-23-23-55-10"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;TL;DR: The major motivation be
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="不确定估计" scheme="https://www.rman.top/tags/%E4%B8%8D%E7%A1%AE%E5%AE%9A%E4%BC%B0%E8%AE%A1/"/>
    
  </entry>
  
  <entry>
    <title>如何理解时序点过程</title>
    <link href="https://www.rman.top/2022/03/04/temporal-process/"/>
    <id>https://www.rman.top/2022/03/04/temporal-process/</id>
    <published>2022-03-04T06:02:53.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<h2 id="什么是时序点过程："><a href="#什么是时序点过程：" class="headerlink" title="什么是时序点过程："></a>什么是时序点过程：</h2><p>现实世界中有这么个问题：有这么一系列历史事件，每个事件都有其对应的发生时间，也有其所属的事件类型，基于这一系列历史事件，预测下一个要发生的是什么类型的事件，以及其发生的时间。</p><p>点过程可以对一系列历史事件建模，来解决此预测问题。</p><p><img src="https://image.rman.top/blog20220304141302.jpg" alt="以机器学习的视角来看时序点过程的最新进展"></p><h2 id="时序点过程的计算："><a href="#时序点过程的计算：" class="headerlink" title="时序点过程的计算："></a>时序点过程的计算：</h2><p>给定一系列历史事件：</p><p><img src="https://image.rman.top/blog20220304141303.jpg" alt="S = { (ti, di) %  D} "></p><p>点过程的核心是强度函数$\lambda(t)$，其定义方式如下</p><p><img src="https://image.rman.top/blog20220304141304.jpg" alt="history  Mt) = lim  event number  At  dt  Events  Intensity R(t) "></p><p>定义方式是由极短时间内的平均发生事件次数除以时间段长度。其表示的含义是在给定一段历史事件的序列时，<strong>在之后的极小的一段时间中事件发生的概率。</strong></p><p>又由于随着时间的推移，事件可能在之后任意一个时间点发生，对于在这个极小的时间段中事件发生的概率我们又可以定义为：</p><p><img src="https://image.rman.top/blog20220304141305.jpg" alt="history  A(tl t)  density function  1—  Cumulative distribution function  Survival function "></p><p>其表示的是事件在时间t当下发生的的概率除以时间t到未来中发生的概率。</p><p>又由于</p><script type="math/tex; mode=display">f^*(t)=\frac{dF^*(t)}{dt}</script><p>所以</p><script type="math/tex; mode=display">\lambda(t)=\frac{\frac{dF^*(t)}{1-F^*(t)}}{1-F^*(t)}=-\frac{d}{dt}log(1-F^*(t))\\(因为\frac{d}{dx}ln(1-f(x))=\frac{f'(x)}{1-f(x)})</script><p>因此生存函数$S^*(t)$的定义如下：</p><p><img src="https://image.rman.top/blog20220304141306.jpg" alt="exp  ti—l "></p><p><img src="https://image.rman.top/blog20220304141307.jpg" alt="Relation between f* ,  ti  ( -ftt  (t) exp  Central quantity "></p><p>因此事件发生的概率密度可以写成：</p><p><img src="https://image.rman.top/blog20220304141308.jpg" alt="img"></p><p>就此，我们只需要定义强度函数$\lambda(t)$就可以得到事件在每一个时刻的发生概率，然后用优化似然函数的方式得到具体的参数。</p><p><img src="https://image.rman.top/blog20220304141309.jpg" alt="log f (h, t2,  to "></p><h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><ol><li><a href="https://thinklab.sjtu.edu.cn/src/pp_survey.pdf">Recent Advance in Temporal Point Process: from Machine Learning Perspective</a></li><li><a href="https://thinklab.sjtu.edu.cn/TPP_Tutor_IJCAI19.html">Temporal Point Processes Learning for Event Sequences</a></li><li><a href="https://zhuanlan.zhihu.com/p/110171621">时序点过程学习笔记</a></li><li><a href="https://zhuanlan.zhihu.com/p/133048880">AICUG公开课笔记|时序点过程在游戏玩家行为事件预测中的应用</a></li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;什么是时序点过程：&quot;&gt;&lt;a href=&quot;#什么是时序点过程：&quot; class=&quot;headerlink&quot; title=&quot;什么是时序点过程：&quot;&gt;&lt;/a&gt;什么是时序点过程：&lt;/h2&gt;&lt;p&gt;现实世界中有这么个问题：有这么一系列历史事件，每个事件都有其对应的发生时间，也有其所
      
    
    </summary>
    
    
      <category term="科研经验" scheme="https://www.rman.top/categories/%E7%A7%91%E7%A0%94%E7%BB%8F%E9%AA%8C/"/>
    
    
      <category term="时序点过程" scheme="https://www.rman.top/tags/%E6%97%B6%E5%BA%8F%E7%82%B9%E8%BF%87%E7%A8%8B/"/>
    
      <category term="Temporal Point Process" scheme="https://www.rman.top/tags/Temporal-Point-Process/"/>
    
  </entry>
  
  <entry>
    <title>如何审稿期刊论文</title>
    <link href="https://www.rman.top/2022/01/25/journal-review/"/>
    <id>https://www.rman.top/2022/01/25/journal-review/</id>
    <published>2022-01-25T03:33:32.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>之前审过几篇会议论文，但是对期刊的审稿还不是很了解。这次帮老师审阅一个期刊的文章，在这里把老师指导的几点期刊审阅经验进行总结。</p><h2 id="总体浏览"><a href="#总体浏览" class="headerlink" title="总体浏览"></a>总体浏览</h2><p>期刊论文通常篇幅较长，审稿时候可以做的决断从好到坏有3个：minor revision, major revision (有些期刊为reject &amp; resubmit), reject.  </p><p>看完文章之后可以大概心里做个if-else的判断，是否直接reject 或者给作者修改机会。如果一个文章在idea, 实验，写作方面较差，则可以直接拒绝。或者一个文章虽然写得还行，但是期刊level 很高，文章不达到要求（比如理论不充足，没有足够多contribution)，也可以拒绝。当觉得文章还可以，值得给一个修改机会时候。 </p><h2 id="审稿意见"><a href="#审稿意见" class="headerlink" title="审稿意见"></a>审稿意见</h2><p>审稿意见通常包括两部分：一段summary, 总结文章研究内容+总体评价。第二部分是actionable comments。写期刊审稿意见时，<strong>应该侧重于给actionable comments, 即作者看完应该能知道怎么修改的comments。不要给模凌两可的意见或者一味批评而读者不知道如何改的意见。</strong></p><p>actionable item 分几类：</p><ol><li><p>一类是clarification, 这些只需要做简单修改；</p></li><li><p>一类是添加内容，比如加motivation，加某个东西的介绍，加时间复杂度分析，指出和xx 工作的区别；</p></li><li><p>一类是对比，比如数据集太小，试验不充分，需要加更大数据集；比如baseline 太旧，需要加新的。</p></li></ol><p>还有一类其实更难的，是novelty 不足，idea 不新，这个基本就差不多可以拒了。</p><p>和会议审稿不同，审期刊没必要列3点positive comments 和3点negative comments. 为什么呢，因为这些不是actionable comments.</p><p> 由于期刊通常需要多次修改才能被接收。所以一般第一审给major revision。然后第二次可以是minor, 第三次是accept. 当然如果质量很好，可以在R1时候给accept.</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;之前审过几篇会议论文，但是对期刊的审稿还不是很了解。这次帮老师审阅一个期刊的文章，在这里把老师指导的几点期刊审阅经验进行总结。&lt;/p&gt;
&lt;h2 id=&quot;总体浏览&quot;&gt;&lt;a href=&quot;#总体浏览&quot; class=&quot;headerlink&quot; title=&quot;总体浏览&quot;&gt;&lt;/a&gt;总体浏
      
    
    </summary>
    
    
      <category term="科研经验" scheme="https://www.rman.top/categories/%E7%A7%91%E7%A0%94%E7%BB%8F%E9%AA%8C/"/>
    
    
      <category term="期刊审稿" scheme="https://www.rman.top/tags/%E6%9C%9F%E5%88%8A%E5%AE%A1%E7%A8%BF/"/>
    
  </entry>
  
  <entry>
    <title>Ubuntu Apache 搭建WebDav网盘</title>
    <link href="https://www.rman.top/2022/01/20/webdav/"/>
    <id>https://www.rman.top/2022/01/20/webdav/</id>
    <published>2022-01-20T10:12:19.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>移动大法良心给了家庭宽带IPV6地址，从此能在里服务器快乐的挂着种子下视频，然后在世界任意角落通过IPV6地址访问看视频了（客户端IPV6地址可以用Cloudfare Warp或者VPS解决）。</p><blockquote><p>移动竟然没有对IPV6限速，我挂种子可以轻易跑出G口的网速。</p><p><img src="https://image.rman.top/blog20220120184211.png" alt="image-20220120183152195"></p></blockquote><p>之前家里的NAS是用SMB协议进行串流的，在局域网的时候SMB速度还行，但是变成公网之后SMB速度就太感人了。通过调研了FTP，SMB，WebDAV之后发现，WebDAV是在HTTP协议之上研发的，相比SMB有很好的文件传输效率，同时又有比FTP更高的安全性。因此研究如何在Ubuntu上部署WebDAV网盘，方便串流视频。</p><p>自己测试表明WebDAV基本可以跑满带宽（50M），SMB协议则只有8M左右。</p><p>WebDAV</p><p><img src="https://image.rman.top/blog20220120183319.png" alt="image-20220120183315622"></p><p>SMB</p><p><img src="https://image.rman.top/blog20220120183402.png" alt="image-20220120183400760"></p><p>在Ubuntu上使用的WebDAV的方法有多种：Apache2，Nginx，Caddy。Nginx和Caddy都需要额外安装模块才能实现最完整的WebDAV功能（下载、上传、修改），因此我推荐使用Apache部署WebDAV。</p><h2 id="安装apache2"><a href="#安装apache2" class="headerlink" title="安装apache2"></a>安装apache2</h2><p>使用apt安装 apache2</p><p><code>sudo apt install apache2</code></p><p>激活 WebDAV 相关组件</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a2enmod dav_fs</span><br><span class="line">a2enmod dav </span><br></pre></td></tr></table></figure><h2 id="创建配置文件"><a href="#创建配置文件" class="headerlink" title="创建配置文件"></a>创建配置文件</h2><p><code>sudo nano /etc/apache2/sites-enable/webdav.conf</code></p><p>请注意，和nginx不一样，如果要改端口要在/etc/apache2/ports.conf修改</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&lt;VirtualHost *:8888&gt;</span><br><span class="line">    ServerAdmin webmaster@localhost</span><br><span class="line">    DocumentRoot /mnt/sda1</span><br><span class="line">    #ErrorLog $&#123;APACHE_LOG_DIR&#125;/error.log</span><br><span class="line">    #CustomLog $&#123;APACHE_LOG_DIR&#125;/access.log combined</span><br><span class="line">    #DavLockDB &quot;/var/www/DavLock&quot; # 注释掉，默认路径，很多教程都会指定这个，权限设置不对很可能导致无法创建文件。</span><br><span class="line">    &lt;Directory /mnt/sda1&gt;</span><br><span class="line">        Options Indexes MultiViews</span><br><span class="line">        AllowOverride None</span><br><span class="line">        Order allow,deny</span><br><span class="line">        allow from all</span><br><span class="line">    &lt;/Directory&gt;</span><br><span class="line">    #Alias /webdav /mnt/sda1</span><br><span class="line"></span><br><span class="line">    &lt;Location /&gt;</span><br><span class="line">       DAV On</span><br><span class="line">       AuthType Basic</span><br><span class="line">       AuthName &quot;rman&quot; # 用户名，可以自定义</span><br><span class="line">       AuthUserFile /etc/apache2/webdav.password # 密码文件</span><br><span class="line">       Require valid-user</span><br><span class="line">    &lt;/Location&gt;</span><br><span class="line">&lt;VirtualHost&gt;</span><br></pre></td></tr></table></figure><h2 id="生成密码"><a href="#生成密码" class="headerlink" title="生成密码"></a>生成密码</h2><p><code>htpasswd -c /etc/apache2/webdav.password rman</code></p><p>最后为用户名，然后输入密码。</p><p>最后重启Apache2即可，并设为开机启动。</p><p><code>sudo systemctl enable apache2</code></p><p><code>sudo systemctl restart apache2</code></p><p>至此WebDAV就配置好了，可以直接通过浏览器或者其他客户端访问</p><p><code>http://ip:port/</code>。</p><h2 id="效果展示"><a href="#效果展示" class="headerlink" title="效果展示"></a>效果展示</h2><p><img src="https://image.rman.top/blog20220120182909.png" alt="image-20220120182907991"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;移动大法良心给了家庭宽带IPV6地址，从此能在里服务器快乐的挂着种子下视频，然后在世界任意角落通过IPV6地址访问看视频了（客户端IPV6地址可以用Cloudfare Warp或者VPS解决）。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;移动竟然没有对IPV6限速，我挂种子可
      
    
    </summary>
    
    
      <category term="技术分享" scheme="https://www.rman.top/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/"/>
    
    
      <category term="Linux" scheme="https://www.rman.top/tags/Linux/"/>
    
  </entry>
  
  <entry>
    <title>海外解锁网易云音乐版权限制歌曲</title>
    <link href="https://www.rman.top/2022/01/20/Unlock-Netease-Music/"/>
    <id>https://www.rman.top/2022/01/20/Unlock-Netease-Music/</id>
    <published>2022-01-20T09:33:30.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p>人在海外，还是喜欢熟悉的网易云音乐。毕竟是养了那么久的号，推荐的歌曲还是蛮符合我的胃口的，只可惜网易云许多歌曲在海外都无法播放，因此想着如何能解锁网易云。</p><p>一开始直接想通过国内服务器搭建一个代理，但是国内VPS带宽实在捉急，听个无损都要缓冲，体验太差了。在网上搜索，发现有这样一个项目可以帮助我们解决问题：<a href="https://github.com/nondanee/UnblockNeteaseMusic">https://github.com/nondanee/UnblockNeteaseMusic</a></p><h2 id="项目分析"><a href="#项目分析" class="headerlink" title="项目分析"></a>项目分析</h2><p>该项目的主要功能如下：</p><ol><li>为请求增加 X-Real-IP 参数解锁海外限制，支持指定网易云服务器 IP</li><li><p>使用 QQ / 虾米 / 百度 / 酷狗 / 酷我 / 咪咕 / JOOX 音源替换变灰歌曲链接</p></li><li><p>完整的流量代理功能 (HTTP / HTTPS)，可直接作为系统代理 (同时支持 PAC)</p></li></ol><p>功能1是我研究这个项目的初衷，我希望能在不用翻回国的情况下解锁网易云的海外限制。通过这个项目看来，网易云是通过X-Real-IP这个请求头来判断IP的。稍微熟悉网络安全的同学都知道，取IP应该用 REMOTE_ADDR，这个是不可伪造的，而X-Real-IP和X-Forward都是可以伪造的，因此此项目通过代理，修改了网易云音乐的包头，从而使得网易云无法正确判断我们的位置。</p><p>该项目如何修改我们的发包头呢？因为此项目是一个代理的形式提供服务，对HTTP流量可以直接修改，但是对于HTTPS流量就无能为力了。为此该项目采用了两种方法：1.流量降级。2.中间人攻击。第一种方法是，当检测到流量是https的时候就返回一个空，这时候网易云音乐客户端会重新以http的形式连接，从而可以修改包头。第二种方法，是用自定义证书替换网易云音乐的证书，因此可以通过中间人解密修改流量。</p><blockquote><p>这个bug的修正其实非常简单，不懂为啥网易云一直没有修复，其实只需要将IP的取值来源换成REMOTE_ADDR即可。</p></blockquote><p>对于功能2，其实就是对网易云音乐没有版权的歌曲，自动通过其他音乐源获取同名歌曲替换即可。此时网易云就只是一个没有感情的UI界面+收藏+推荐的软件了，正好也符合我的需求，本来我就只需要它的私人FM功能。</p><p>功能3是实现1,2的根源，通过一个代理的形式对流量进行修改，从而达到解锁的效果。同时既可以在本地搭建也可在云服务器搭建，给多个设备使用。后文我将介绍如何在云服务器搭建，从而给多个设备使用。</p><h2 id="项目部署"><a href="#项目部署" class="headerlink" title="项目部署"></a>项目部署</h2><p>由于源项目太久没有更新，我采用<a href="https://github.com/UnblockNeteaseMusic/server">此项目</a>所提供的的一个docker方式快捷部署。</p><p>服务端执行：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run  -d -p 8080:8080  -m 300M --memory-swap -1 -e ENABLE_LOCAL_VIP=true -e NO_CACHE=true -e ENABLE_FLAC=true -e NODE_ENV=production --restart=always --log-opt max-size=10m --name=win_music pan93412/unblock-netease-music-enhanced -e https://music.163.com</span><br></pre></td></tr></table></figure><p>此时会在VPS上开启8080端口的http服务。由于该项目有内存溢出情况，所以设置了内存限制。此指令已经亲自测试在所有客户端都可用。</p><h2 id="项目使用"><a href="#项目使用" class="headerlink" title="项目使用"></a>项目使用</h2><h3 id="Windows"><a href="#Windows" class="headerlink" title="Windows"></a>Windows</h3><p>windows客户端非常好使用，直接在<code>设置-工具-http代理</code>处填写你的服务器ip和端口号（默认是8080）即可。</p><h2 id="IOS"><a href="#IOS" class="headerlink" title="IOS"></a>IOS</h2><p>IOS由于无法直接通过流量降级发送http流量，因此采用安装证书，用中间人攻击方式修改流量。</p><p>在Safari上打开如此<a href="https://raw.githubusercontent.com/UnblockNeteaseMusic/server/enhanced/ca.crt">地址</a>安装并信任证书。在设置 &gt; 通用 &gt; 关于本机 &gt; 证书信任设置，手动信任证书。</p><p>IOS推荐采用Shadowrockt方式添加http代理。如果不想麻烦可以直接开全局代理，或者用如下规则：</p><p><a href="https://gist.githubusercontent.com/RManLuo/8b7b913298608d47778447012a6b8438/raw/69ba50bdc836e6140cdd8ae5f170b82767d950d7/music.conf">https://gist.githubusercontent.com/RManLuo/8b7b913298608d47778447012a6b8438/raw/69ba50bdc836e6140cdd8ae5f170b82767d950d7/music.conf</a></p><h2 id="MAC"><a href="#MAC" class="headerlink" title="MAC"></a>MAC</h2><p>MacOS和IOS类似，需要安装证书，同时可以用Clash等软件分流。</p><h2 id="安卓"><a href="#安卓" class="headerlink" title="安卓"></a>安卓</h2><p>安卓推荐用Clash设置代理并进行分流，可用规则如下</p><p><a href="https://github.com/DesperadoJ/Rules-for-UnblockNeteaseMusic/tree/master/Clash">https://github.com/DesperadoJ/Rules-for-UnblockNeteaseMusic/tree/master/Clash</a></p><h2 id="其他参考资料"><a href="#其他参考资料" class="headerlink" title="其他参考资料"></a>其他参考资料</h2><p><strong>Linux 客户端食用指南</strong>：<a href="https://github.com/nondanee/UnblockNeteaseMusic/issues/208">https://github.com/nondanee/UnblockNeteaseMusic/issues/208</a></p><p><strong>iOS配置经验分享</strong>： <a href="https://github.com/nondanee/UnblockNeteaseMusic/issues/368">https://github.com/nondanee/UnblockNeteaseMusic/issues/368</a></p><p><strong>iOS</strong> <strong>食用指南#65</strong>：<a href="https://github.com/nondanee/UnblockNeteaseMusic/issues/65">https://github.com/nondanee/UnblockNeteaseMusic/issues/65</a></p><p><strong>一个可以使用的教程#444</strong>： <a href="https://github.com/nondanee/UnblockNeteaseMusic/issues/444">https://github.com/nondanee/UnblockNeteaseMusic/issues/444</a></p><p><strong>教學：如何修正 UnblockNeteaseMusic 的「播放失敗」問題（酷我、QQ、周杰倫）#746</strong>： <a href="https://github.com/nondanee/UnblockNeteaseMusic/issues/746">https://github.com/nondanee/UnblockNeteaseMusic/issues/746</a></p><p> <strong>UnblockNeteaseMusic - 解锁网易云音乐客户端变灰歌曲</strong>：<a href="https://redn3ck.github.io/2020/06/23/UnblockNeteaseMusic-解锁网易云音乐客户端变灰歌曲">https://redn3ck.github.io/2020/06/23/UnblockNeteaseMusic-解锁网易云音乐客户端变灰歌曲</a> </p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;人在海外，还是喜欢熟悉的网易云音乐。毕竟是养了那么久的号，推荐的歌曲还是蛮符合我的胃口的，只可惜网易云许多歌曲在海外都无法播放，因此想着如何能解锁网易云。&lt;/p&gt;
&lt;p&gt;一开始直接想通过国内服务器搭建一个代理，但是国内VPS带宽实在捉急，听个无损都要缓冲，体验太差了。在网上
      
    
    </summary>
    
    
      <category term="技术分享" scheme="https://www.rman.top/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/"/>
    
    
      <category term="网易云音乐" scheme="https://www.rman.top/tags/%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90/"/>
    
      <category term="破解" scheme="https://www.rman.top/tags/%E7%A0%B4%E8%A7%A3/"/>
    
  </entry>
  
  <entry>
    <title>Graph Attention Multi-Layer Perceptron</title>
    <link href="https://www.rman.top/2021/10/13/Graph-Attention-Multi-Layer-Perceptron/"/>
    <id>https://www.rman.top/2021/10/13/Graph-Attention-Multi-Layer-Perceptron/</id>
    <published>2021-10-13T13:43:06.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h2><ul><li><p>The size of the K-hop neighbors grows exponentially to the number of GNN layers <strong>(High Memory Cost).</strong></p></li><li><p>GNN has to read great amount of data of neighboring nodes to compute the single target node representation, leading to high communication cost in a distributed environment <strong>(High Communication Cost)</strong>.</p></li></ul><p><img src="https://image.rman.top/blog20211013221159.png" alt="image-20211013214517854"></p><p>GNN的每一次特征传播都需要拉取邻居特征，对于k层的GNN来说，每个节点需要拉取的k跳以内邻居节点特征随着层数增加以指数增加，会占用<strong>大量内存</strong>。对于稠密的连通图，每个节点在每次训练的时候几乎需要拉取全图的节点信息，造成海量的<strong>通信开销</strong>。</p><ul><li><p><strong>A commonly used approach to tackle the issues is sampling.</strong></p><ul><li>The sampling quality highly influences the model performance, and it still needs communication in each step <strong>(reduce neighbors ).</strong></li></ul><p>Sampling的方法虽然可以减少邻居数量，减轻内存压力，但是仍要消息传递。</p></li><li><p><strong>Some method (e.g., SGC) decouples the feature propagation and the non-linear transformation process.</strong></p><ul><li><p>The feature propagation is executed during pre-processing.</p></li><li><p>Only the nodes of training set get involved in the model training.</p></li><li><p>The decoupling methods are more suitable for distributed training.</p><p>现有方法分离消息传递和非线性变化，提取收集好特征，后期直接用全连接变化即可。</p></li></ul></li></ul><h2 id="Challenges"><a href="#Challenges" class="headerlink" title="Challenges"></a>Challenges</h2><ul><li>The decoupling methods adopting fixed layers of feature propagation, leading to a fixed RF of nodes.</li><li>The local information and long-range dependencies cannot be fully leveraged at the same time.</li><li>This makes them lack the flexibility to model the interesting correlations on node features under different reception fields.</li></ul><p><img src="https://image.rman.top/blog20211013221202.png" alt="image-20211013215718830"></p><p>我们通过一个简单的示例来说明这个问题。图4中有1个被标蓝的节点并位于图中相对稠密的区域，而绿色节点位于图中相对稀疏的区域。同样进行2次特征传播操作，可以看到位于稠密区域的蓝色节点的感受野已经相对较大了，而位于稀疏区域的绿色节点的感受野却只包含了3个节点。这个实例形象地说明了不同节点的感受野的扩张速度存在较大的差异。在GNN中，一个节点感受野的大小表示它能捕获邻域信息的多少，感受野太大，则该节点可能会捕获许多不相关节点的信息，感受野太小，则该节点无法捕获足够的邻域信息得到高质量的节点表示。因此，对于不同特征传播步数的节点特征，GNN模型需要对不同的节点自适应地分配权重。否则，便会出现无法兼顾位于稠密区域和稀疏区域节点的情况，导致最后无法得到高质量的节点表示。</p><h2 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h2><ul><li>Propose a decoupling methods method that can be applied in huge graph and distributed environment. </li><li>Propose three node-adaptive graph learning mechanisms to meet the requires of different nodes with different propagation steps.</li><li>Achieve the STOA performance in the three largest graph benchmarks while maintains high scalability and efficiency.</li></ul><h2 id="Preliminaries"><a href="#Preliminaries" class="headerlink" title="Preliminaries"></a>Preliminaries</h2><h3 id="Graph-wise-Propagation"><a href="#Graph-wise-Propagation" class="headerlink" title="Graph-wise Propagation"></a>Graph-wise Propagation</h3><ul><li>Recently studies have observed that non-linear feature transformation contributes little to the performance of the GNNs as compared to feature propagation.</li><li>They reduces GNNs into a linear model operating on K-layers propagated features.</li></ul><p><img src="https://image.rman.top/blog20211013221205.png" alt="image-20211013215840376"></p><p>Graph-wise propagation和之前我们介绍的node-wise propagation 的先传播再非线性变化不一样，是直接得到一个K跳内的邻接的邻接矩阵和$\hat{A}^K$，然后一次性计算传播结果，提前收集好K-hop特征$X^K$，然后直接用全连接之类的变化即可。</p><p>显然在训练过程中不需要消息传递，结点K-hop特征直接被当成特征输入网络即可。</p><h3 id="Layer-wise-Propagation"><a href="#Layer-wise-Propagation" class="headerlink" title="Layer-wise Propagation"></a>Layer-wise Propagation</h3><p>Following SGC, some recent methods adopt layer-wise propagation combining the features with different propagation layers.</p><p><img src="https://image.rman.top/blog20211013221206.png" alt="image-20211013220038427"></p><h2 id="The-GAMLP-Model"><a href="#The-GAMLP-Model" class="headerlink" title="The GAMLP Model"></a>The GAMLP Model</h2><p>GAMLP decomposes the end-to-end GNN training into three parts: feature propagation, feature combination with RF attention, and the MLP training.</p><p><img src="https://image.rman.top/blog20211013221208.png" alt="image-20211013220058882"></p><p>As the feature propagation is pre-processed only once, and MLP training is efficient and salable, we can easily scale GAMLP to large graphs. Besides, with the RF attention, each node in GAMLP can adaptively get the suitable</p><h2 id="Feature-Propagation"><a href="#Feature-Propagation" class="headerlink" title="Feature Propagation"></a>Feature Propagation</h2><p>Parameter-free K-step feature propagation as:</p><p><img src="https://image.rman.top/blog20211013221209.png" alt="image-20211013220144723"></p><p>After K-step feature propagation, we correspondingly get a list of propagated features under different propagation steps:</p><p><img src="https://image.rman.top/blog20211013221212.png" alt="image-20211013220148894"></p><p>Average these propagated features in a weighted manner</p><p><img src="https://image.rman.top/blog20211013221214.png" alt="image-20211013220151907"></p><h2 id="Receptive-Field-Attention"><a href="#Receptive-Field-Attention" class="headerlink" title="Receptive Field Attention"></a>Receptive Field Attention</h2><p>Get the attention weight $W_l$ for different layers.</p><h3 id="Smoothing-Attention"><a href="#Smoothing-Attention" class="headerlink" title="Smoothing Attention"></a>Smoothing Attention</h3><p>Suppose we execute feature propagation for infinite times. In that case, the node embedding within the same connected component will reach a stationary state <strong>(Over smoothing).</strong></p><p><img src="https://image.rman.top/blog20211013221216.png" alt="image-20211013220255672"></p><p><img src="https://image.rman.top/blog20211013221218.png" alt="image-20211013220259953"></p><p>平滑注意力机制(Smoothing)：把经无穷次传播的节点特征作为参考向量。在实际计算的时候有公式可以直接带入数值求解，并不需要真的进行无穷次特征传播。该注意力机制希望能够学习到不同传播步数的节点特征相对于的距离，并用这个距离来指导权重的选择。</p><h3 id="Recursive-Attention"><a href="#Recursive-Attention" class="headerlink" title="Recursive Attention"></a>Recursive Attention</h3><p><img src="https://image.rman.top/blog20211013221220.png" alt="image-20211013220313204"></p><p>递归注意力机制(Recursive)：使用递归计算的方式，在计算赋予经L步传播的节点特征 的权重时，把前 L-1步的融合节点特征作为参考向量。该注意力机制希望能够学习到 $X^L$相比前L-1步的融合节点特征的信息增益，并用这个信息增益来指导权重的选择。</p><h3 id="JK-Attention"><a href="#JK-Attention" class="headerlink" title="JK Attention"></a>JK Attention</h3><p><img src="https://image.rman.top/blog20211013221221.png" alt="image-20211013220433422"></p><p><img src="https://image.rman.top/blog20211013221223.png" alt="image-20211013220437182"></p><p>知识跳跃注意力机制(JK)：如图7所示，把预处理阶段得到的所有经特征传播的节点特征全都按列拼接起来，并让这个向量过一个MLP，以MLP的输出结果作为参考向量。该注意力机制中的参考向量包含了所有K个经特征传播的节点特征矩阵中的信息，该注意力机制希望能够学习到不同传播步数的节点特征相对于大向量 的重要性，并用这个重要性来指导权重的选择。(可以理解为是一个局部的over smoothing attention).</p><h2 id="Model-Training"><a href="#Model-Training" class="headerlink" title="Model Training"></a>Model Training</h2><p><img src="https://image.rman.top/blog20211013221225.png" alt="image-20211013220503359"></p><h3 id="Incorporating-Label-Propagation"><a href="#Incorporating-Label-Propagation" class="headerlink" title="Incorporating Label Propagation"></a>Incorporating Label Propagation</h3><p><img src="https://image.rman.top/blog20211013221226.png" alt="image-20211013220516350"></p><h3 id="Reliable-Label-Utilization-RLU"><a href="#Reliable-Label-Utilization-RLU" class="headerlink" title="Reliable Label Utilization (RLU)"></a>Reliable Label Utilization (RLU)</h3><p>To better utilize the predicted soft label (i.e., softmax outputs), we split the whole training process into multiple stages, each containing a full training procedure of the GAMLP model.</p><p><strong>Here, we denote the prediction results of m-th stage as:</strong></p><p><img src="https://image.rman.top/blog20211013221228.png" alt="image-20211013220551932"></p><p>we adopt the predicted results for the nodes in the validation set and the test <strong>set at the last stage to enhance the label propagation.</strong></p><p><img src="https://image.rman.top/blog20211013221229.png" alt="image-20211013220609374"></p><p>增加label propagation的初始数量，把上次训练得到的高可信度的结点标签也作为真实标签加入，T controls the softness of the softmax distribution</p><h3 id="Reliable-Label-Distillation"><a href="#Reliable-Label-Distillation" class="headerlink" title="Reliable Label Distillation"></a>Reliable Label Distillation</h3><p>To fully take advantage of the helpful information of the last stage, we also included a knowledge distillation module in our model. we only include the nodes in the reliable node set $𝑉_r$ at (m-1)-th<br>stage (m &gt; 1) and then define the weighted KL divergence as:</p><p><img src="https://image.rman.top/blog20211013221231.png" alt="image-20211013220655169"></p><h2 id="Loss"><a href="#Loss" class="headerlink" title="Loss"></a>Loss</h2><p><img src="https://image.rman.top/blog20211013221233.png" alt="image-20211013220702996"></p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><h3 id="Datasets"><a href="#Datasets" class="headerlink" title="Datasets"></a>Datasets</h3><p><img src="https://image.rman.top/blog20211013221234.png" alt="image-20211013220718438"></p><h2 id="Implementation"><a href="#Implementation" class="headerlink" title="Implementation"></a>Implementation</h2><p><img src="https://image.rman.top/blog20211013221236.png" alt="image-20211013220733577"></p><h3 id="Results"><a href="#Results" class="headerlink" title="Results"></a>Results</h3><p>单机单卡跑10亿级别结点，在Ogb拿到了全球第一。</p><p><img src="https://image.rman.top/blog20211013221237.png" alt="image-20211013220744697"></p><p>The weights of propagated features with larger steps drop faster as the degree grows, which indicates that our attention mechanism could prevent high-degree nodes from including excessive irrelevant nodes which lead to over-smoothing.</p><p><img src="https://image.rman.top/blog20211013221239.png" alt="image-20211013220827279"></p><p>度数越高越dense，因此自然用的是局部的信息。</p><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><ul><li>This paper proposed many tricks (i.e., attention, GCNII, label propagation, knowledge distillation) that can be used in our method to boost the performance in the final stage.</li><li>The decoupling and weighted average methods can be extended to solve the huge HIN case (e.g., knowledge graph).</li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The size of the K-hop neighbo
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="分布式计算" scheme="https://www.rman.top/tags/%E5%88%86%E5%B8%83%E5%BC%8F%E8%AE%A1%E7%AE%97/"/>
    
  </entry>
  
  <entry>
    <title>HGK-GNN: Heterogeneous Graph Kernel based Graph Neural Networks</title>
    <link href="https://www.rman.top/2021/08/28/HGK-GNN/"/>
    <id>https://www.rman.top/2021/08/28/HGK-GNN/</id>
    <published>2021-08-28T13:58:36.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h1><ol><li>现有模型不好解决异构图</li><li>现有异构图方法缺少理论分析</li></ol><h1 id="Intro写作思路："><a href="#Intro写作思路：" class="headerlink" title="Intro写作思路："></a>Intro写作思路：</h1><ol><li><p>先介绍GNN以及GNN对应的理论研究，从而过渡到现有GNN模型不能解决异构图问题。（对应背景和现在的工作进度）</p></li><li><p>接下来介绍现有异构图的问题</p></li><li><ol><li>现有异构图需要人工指定metapath，或者其他需要经验得到的东西。</li><li>缺少针对HGNN理论分析。</li></ol></li><li><p>引出本文的核心：Graph     Kernel（为什么这里不放在开头呢？因为这个东西是用来解决问题的方法，而不是问题核心。问题还是GNN，所以第一段讲的是GNN）</p></li><li><ol><li>Graph Kernel（GK）：用于评价图上两个点或者两个子结构之间相似度的东西。(一种算子)</li><li>GK在同构图上的应用，但是在异构图上应用仍然存在挑战（存在什么挑战？这里讲一下是不是好一点。）</li></ol></li><li><p>本文的工作</p></li></ol><h1 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h1><ol><li>提出了一个基于异构图的Graph Kernel。第一个将马氏距离（Mahalanobis     distance，MD）和异构图kernel相结合，来捕获异构信息。</li><li>通过理论把graph     kernel和传统的HGNN联系起来，对传统的HGNN进行了理论分析。</li></ol><h1 id="Approach"><a href="#Approach" class="headerlink" title="Approach"></a>Approach</h1><p><img src="https://image.rman.top/blog20210828221310.png" alt="image-20210828221249458"></p><h2 id="Graph-Kernels"><a href="#Graph-Kernels" class="headerlink" title="Graph Kernels"></a>Graph Kernels</h2><p>Kernels 把数据映射到一个高纬度空间中，从而可以在高维空间对数据进行相似度计算。</p><p>Graph Kernels通过把图分解成不同的子结构，从而进行相似度计算。</p><p><img src="https://image.rman.top/blog20210828221314.png" alt="image-20210828220923087"></p><p>当不考虑子结构的时候，Graph Kernel可以只考虑节点的情况</p><p><img src="https://image.rman.top/blog20210828221316.png" alt="image-20210828220933147"></p><h2 id="Random-Walk-Graph-Kernel"><a href="#Random-Walk-Graph-Kernel" class="headerlink" title="Random Walk Graph Kernel"></a>Random Walk Graph Kernel</h2><p>比较两个图中，长度为l的randomwalk序列的相似度。</p><p><img src="https://image.rman.top/blog20210828221317.png" alt="image-20210828220946664"></p><h2 id="HGK-GNN"><a href="#HGK-GNN" class="headerlink" title="HGK-GNN"></a>HGK-GNN</h2><h3 id="Incorporating-Heterogeneous-Edges"><a href="#Incorporating-Heterogeneous-Edges" class="headerlink" title="Incorporating Heterogeneous Edges."></a>Incorporating Heterogeneous Edges.</h3><p><img src="https://image.rman.top/blog20210828221319.png" alt="image-20210828220956543"></p><p>计算两个节点u,v的相似度，定义Kernel如下：</p><ol><li>对节点u，v分别用其本身的特征做点乘。</li><li>同时对其所有的一跳邻居的边的进行组合并交叉相乘（计算量好大）</li></ol><h3 id="Incorporating-Heterogeneous-Nodes"><a href="#Incorporating-Heterogeneous-Nodes" class="headerlink" title="Incorporating Heterogeneous Nodes"></a>Incorporating Heterogeneous Nodes</h3><p>通过考虑不同节点类型和边类型，把不同节点类型节点通过映射函数映射到各自的空间。</p><p><img src="https://image.rman.top/blog20210828221321.png" alt="image-20210828221105099"></p><p>对于l层的邻居来说，其graph kernal可以定义成l-1层的邻居相似度乘以l层的邻居+边的相似度。</p><p><img src="https://image.rman.top/blog20210828221322.png" alt="image-20210828221116398"></p><h1 id="From-HGK-to-Neural-Architectures"><a href="#From-HGK-to-Neural-Architectures" class="headerlink" title="From HGK to Neural Architectures"></a>From HGK to Neural Architectures</h1><p>从Heterogeneous Graph Kernel到神经网络的表示形式</p><p><img src="https://image.rman.top/blog20210828221324.png" alt="image-20210828221124540"></p><p>作者证明得到，在第l层的图神经网络得到的向量表示正好都是对应l层的马氏空间中的向量。</p><p><img src="https://image.rman.top/blog20210828221326.png" alt="image-20210828221133393"></p><h1 id="THEORETICAL-ANALYSIS"><a href="#THEORETICAL-ANALYSIS" class="headerlink" title="THEORETICAL ANALYSIS"></a>THEORETICAL ANALYSIS</h1><p>作者接下来了理论分析了HGK-GNN和metapath-GNN的关系</p><p>传统的MP-GNN可以表示成用metapath进行聚合的图神经网络</p><p><img src="https://image.rman.top/blog20210828221409.png" alt="image-20210828221141920"></p><p>假设当前MPGNN的形式如下</p><p><img src="https://image.rman.top/blog20210828221410.png" alt="image-20210828221150626"></p><p>作者证明，在参数如下形式时，HGK-GNN和MPGNN等价</p><p><img src="https://image.rman.top/blog20210828221412.png" alt="image-20210828221202905"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h1&gt;&lt;ol&gt;
&lt;li&gt;现有模型不好解决异构图&lt;/li&gt;
&lt;li&gt;现有异构图方法缺少理论
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
      <category term="论文" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87/"/>
    
  </entry>
  
  <entry>
    <title>如何写好一个Introduction</title>
    <link href="https://www.rman.top/2021/08/25/how-to-write-an-intro/"/>
    <id>https://www.rman.top/2021/08/25/how-to-write-an-intro/</id>
    <published>2021-08-25T05:22:33.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>之前一直没有对写作intro的总结，现在根据AAAI写作时和老师的讨论，进行一下总结。</p><p>intro的核心目的：讲好一个故事，让reviewer知道，你要做的是什么？为什么要这么做？难点在哪？</p><p>A类文章的关键：</p><ul><li>问题要难！（问题不容易解决）</li><li>方法要新！（之前可以是没人考虑这个点）</li></ul><p>因此在进行Intro写作时，可以遵循如下思路</p><h2 id="问题描述："><a href="#问题描述：" class="headerlink" title="问题描述："></a>问题描述：</h2><p>第一段主要是问题描述（problem setting）。本段主要是针对要研究的问题进行简要介绍，方便读者直接了解你要做的问题是什么，给不熟悉这个领域的人一个大致的介绍</p><p>进行问题的描述，可以分为以下几个方向描述：</p><ol><li>关于problem setting，这个问题是啥？</li><li>他的背景如何，意义在哪？（实际生活的应用）</li><li>可能会有一点挑战？</li></ol><h2 id="现在的研究方案的总结"><a href="#现在的研究方案的总结" class="headerlink" title="现在的研究方案的总结"></a>现在的研究方案的总结</h2><p>你的这个问题是你自己提出来的吗？</p><p>如果不是，可以遵循以下的思路进行写作？</p><ol><li>现在的研究可以分为什么类别？</li><li>做到了什么地步？他们是如何解决这个问题的？</li><li>他们的发展过程是什么样的？比如PB-&gt;PF的演变</li><li>为什么他们要这么做？</li></ol><p>如果这个问题是你全新提出来的，可以遵循以下思路</p><ol><li>与之类似领域的任务别人是怎么做的？比如你提出了(k,p)-core community search，那之前关于k-core community search怎么做的？</li><li>他们和你的任务有什么样的联系，从而过渡到他们的不足。</li></ol><h2 id="现有方法的问题"><a href="#现有方法的问题" class="headerlink" title="现有方法的问题"></a>现有方法的问题</h2><p>这段是你的核心，如何能准确的抨击现有方法的不足，让读者认可的你的贡献点。</p><p>寻找问题的思路：</p><ol><li><p>现有方法哪里没考虑到？（体现你问题的新）</p></li><li><ol><li>比如PF方法只解决了Warp的问题，忽视了Generator，而Generator又十分重要。</li><li>比如k-core方法只解决了k的问题，而忽视了p这个值，以及没有考虑连接情况。</li></ol></li><li><p>现有问题的challenge（体现你问题的难，所以你的方法才有贡献）</p></li><li><ol><li>现有的简单方法为什么不能直接解决？比如：PF-Generator用简单的拼接会产生什么问题？</li><li>理想（optimal）的最好解决这个问题的方法应该什么样的？引出你的方法如何去接近这个最佳解决方案的。</li></ol></li></ol><h2 id="实际介绍你的方法"><a href="#实际介绍你的方法" class="headerlink" title="实际介绍你的方法"></a>实际介绍你的方法</h2><p>此处为介绍你提出方法的细节所在，这段其实是最简单的，就是结合上面的问题和挑战，一点点针对这些问题，你的方法是如何解决的。</p><p>最后通过实验证明即可。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;之前一直没有对写作intro的总结，现在根据AAAI写作时和老师的讨论，进行一下总结。&lt;/p&gt;
&lt;p&gt;intro的核心目的：讲好一个故事，让reviewer知道，你要做的是什么？为什么要这么做？难点在哪？&lt;/p&gt;
&lt;p&gt;A类文章的关键：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;问题要难！
      
    
    </summary>
    
    
      <category term="论文写作" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E5%86%99%E4%BD%9C/"/>
    
    
      <category term="写作" scheme="https://www.rman.top/tags/%E5%86%99%E4%BD%9C/"/>
    
  </entry>
  
  <entry>
    <title>Breaking the Limits of Message Passing Graph Neural Networks</title>
    <link href="https://www.rman.top/2021/06/17/Break-the-limit-of-1-WL-GNN/"/>
    <id>https://www.rman.top/2021/06/17/Break-the-limit-of-1-WL-GNN/</id>
    <published>2021-06-17T05:53:38.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h1><ol><li>Existing GNNs’ expressive power is limited to <strong>1-WL test</strong>, thus they cannot count some substructures likes: triangle, tailed triangle, and 4-cycle graphlets</li></ol><p><img src="https://image.rman.top/blog20210617141610.png" alt="image-20210617135654515"></p><ol><li><p>Existing beyond 1-WL test GNNs is computational heavily $O(n^3)$ and memory hungry $O(n^2)$. </p></li><li><p>Some methods introduce some <strong>handcrafted features</strong> that cannot be extracted by GNN into the node attributes to increase the GNN’s expressive power: Distance encoding, identity GNN, and some Jure’s works.</p></li><li><p>Existing GNN focuses on the low pass frequency component.</p></li></ol><h1 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h1><ol><li><p>Give the explanation of what make GNN has certain expressive power.</p></li><li><p>Propose a graph convolution method (<strong>GNNML</strong>) that is more powerful than 1-WL test and reaches the 3-WL test.</p></li><li><p>GNNML has linear memory and computational complexities.</p></li><li><p>Enough spectral ability and local update process.</p></li></ol><h2 id="Road-Map"><a href="#Road-Map" class="headerlink" title="Road Map"></a>Road Map</h2><p>GNN-&gt;WL test-&gt;Matrix Language-&gt; <strong>GNNML</strong></p><h1 id="Weisfeiler-Lehman-Test-WL-test"><a href="#Weisfeiler-Lehman-Test-WL-test" class="headerlink" title="Weisfeiler-Lehman Test (WL-test)"></a>Weisfeiler-Lehman Test (WL-test)</h1><h2 id="1-WL-test"><a href="#1-WL-test" class="headerlink" title="1-WL test"></a>1-WL test</h2><p>Consider the 1-vertex.</p><p><img src="https://image.rman.top/blog20210617141625.png" alt="image-20210617135807349"></p><h2 id="k-WL-test"><a href="#k-WL-test" class="headerlink" title="k-WL test"></a>k-WL test</h2><p>Consider k-vertex tuple.</p><p><img src="https://image.rman.top/blog20210617141628.png" alt="image-20210617135846698"></p><p>Examples of non-isomorphic graphs that cannot be distinguished by 1-WL but can be distinguished by 3-WL due to its capability of <strong>counting triangles</strong>.</p><h1 id="Matrix-Language-and-WL-test"><a href="#Matrix-Language-and-WL-test" class="headerlink" title="Matrix Language and WL test"></a>Matrix Language and WL test</h1><p>Matrix Language (MATLANG) includes different operations on matrices and makes some explicit connections between specific <strong>dictionaries of operations</strong> and the 1-WL and 3-WL tests</p><p><strong>Definition 1</strong>: $ML(\mathcal{L})$ is a matrix language with operations set $\mathcal{L}={op_1,⋯,op_n }, op_i\in{⋅,+,⊤,diag, tr,1,⊙,×,f}$</p><p><strong>Definition 2</strong>: $e(X)∈\mathbb{R}$ is a <strong>sentence</strong> in $ML(\mathcal{L})$ if it consists of any possible consecutive operations in $\mathcal{L}$, operating on a given matrix $X$ and resulting in a scalar value.</p><p><strong>Example</strong>: $e(X)=\mathbf{1}^\top X^2\mathbf{1}$  is a sentence of $ML(\mathcal{L})$ with $\mathcal{L}={⋅,⊤,\mathbf{1}}$</p><p> <strong>Matrix operation can extract different features from the graph that can be used to differentiate the graph.</strong></p><p><strong>Remark 1</strong>: Two adjacency matrices are indistinguishable by the 1-WL test if and only if $e(A_G )=e(A_H)$ for all $e∈L_1$ with $L_1={⋅,⊤,1, diag}$.</p><p><strong>Remark 2:</strong> $ML(L_2 )$ with $L_2={⋅,⊤,1,diag,tr}$ is more powerful than 1-WL test but less powerful than 3-WL test.</p><p><strong>Remark 3</strong>: $ML(L_3 )$ with $L_3={⋅,⊤,1,diag,tr,⊙}$  is as powerful as 3-WL test.</p><p><strong>Remark 4</strong>: Enriching operation set to $L^+=L∪{+,×,f}$, $L∈(L_1,L_2,L_3) $ cannot improve the expressive power.</p><h1 id="How-powerful-are-GNNs"><a href="#How-powerful-are-GNNs" class="headerlink" title="How powerful are GNNs?"></a>How powerful are GNNs?</h1><p><strong>Theorem 1</strong>: <strong>Spatial GNNs</strong> such as GCN, GAT cannot go further than 1-WL test ($ML(L_1^+)$)</p><p>Theorem 2: Chebnet (<strong>Spectral GNN</strong>) is more powerful than the 1-WL test if the <strong>Laplacian maximum eigenvalues</strong> of the non-regular graphs to be compared are <strong>not the same</strong>.</p><p><img src="https://image.rman.top/blog20210617141630.png" alt="image-20210617140616500"></p><p><strong>Theorem 3</strong>: 3-star graphlets can be counted by sentences $L_1^+$</p><p><strong>Theorem 4</strong>: Triangle and 4-cycle graphlets can be counted by sentences $L_2^+$</p><p><strong>Theorem 5</strong>: Tailed triangle graphlets can be counted by sentences $L_3^+$</p><p><img src="https://image.rman.top/blog20210617141633.png" alt="image-20210617140702482"></p><h1 id="Generalization-of-Spectral-and-Spatial-GNN"><a href="#Generalization-of-Spectral-and-Spatial-GNN" class="headerlink" title="Generalization of Spectral and Spatial GNN"></a>Generalization of Spectral and Spatial GNN</h1><h2 id="Spectral-GNN"><a href="#Spectral-GNN" class="headerlink" title="Spectral GNN"></a>Spectral GNN</h2><script type="math/tex; mode=display">X=Udiag(Ω(λ)) U^⊤</script><h2 id="Spatial-GNN"><a href="#Spatial-GNN" class="headerlink" title="Spatial GNN"></a>Spatial GNN</h2><script type="math/tex; mode=display">X=AHW</script><h2 id="Generalization-GNN"><a href="#Generalization-GNN" class="headerlink" title="Generalization GNN"></a>Generalization GNN</h2><script type="math/tex; mode=display">H^{(l+1)} = \sigma(\sum_sC^{(s)}H^{(l)W^{(l,s)}})</script><p>where $C^((s))∈\mathbb{R}^{(n×n)}$ is the $s$-th convolution support that defines how the node features are propagated to the neighboring nodes (<strong>different aggregation methods</strong>)</p><h1 id="GNN-beyond-1-WL"><a href="#GNN-beyond-1-WL" class="headerlink" title="GNN beyond 1-WL"></a>GNN beyond 1-WL</h1><p>As aforementioned, the K-WL test can be represented by some matrix operations. Thus, the GNN contains the <strong>certain operations</strong> can also have the express power of k-WL test.</p><p>The paper proposes two methods. The first one, called <strong>GNNML1</strong> is shown to be as powerful as the 1-WL test. The second one, called <strong>GNNML3</strong> exploits the theoretical results of to break the limits of 1-WL and reach 3-WL equivalence experimentally.</p><h2 id="GNNML1"><a href="#GNNML1" class="headerlink" title="GNNML1"></a>GNNML1</h2><p><img src="Break-the-limit-of-1-WL-GNN.assets/image-20210617141119900.png" alt="image-20210617141119900"></p><p>Proof: The GNNML1 can produce all possible vectors in $L_1={⋅,⊤,1,𝑑𝑖𝑎𝑔}$</p><p><img src="https://image.rman.top/blog20210617141636.png" alt="image-20210617141150293"></p><h2 id="GNNML3"><a href="#GNNML3" class="headerlink" title="GNNML3"></a>GNNML3</h2><p>To reach more powerful models than 1-WL, the graph convolution must support trace ($tr$) and multiplication ($⊙$) operation in $L_3$.</p><p>The trace (tr) and multiplication (⊙) operation often take effect in <strong>high power of adjacent matrix</strong>. </p><p>However, we cannot initially know which power of adjacency matrix is necessary for a given problem.</p><p><img src="https://image.rman.top/blog20210617141638.png" alt="image-20210617141219745"></p><p>Thus paper designs a <strong>spectral convolution support</strong> that can be expressed as a linear combination of all powers of adjacency matrix.</p><p><img src="https://image.rman.top/blog20210617141640.png" alt="image-20210617141228228"></p><p>With the any power of the adjacency matrix, the trace ($tr$) and multiplication ($⊙$) operation can be approximated by <strong>MLP</strong> (A trick ! MLP can approximate every function~)</p><p><img src="https://image.rman.top/blog20210617141643.png" alt="image-20210617141322253"></p><p>Where M can be seen as a mask (attention matrix) to select certain powers of the adjacency matrix.</p><p><strong>The forward calculation of GNNML3 is :</strong></p><p><img src="https://image.rman.top/blog20210617141645.png" alt="image-20210617141336810"></p><p>Where $C^s$ can be seen as a multi-heads attention of different graph structure components to provide different operations’ result vector that can be used to approximate 3-WL test. </p><h1 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h1><p>Q1: How many pairs of non-isomorphic simple graphs that are either 1-WL or 3-WL equivalent are not distinguished by the models?</p><p><img src="https://image.rman.top/blog20210617141648.png" alt="image-20210617141402307"></p><p>Q2: Can the models generalize the counting of some substructures in a given graph?</p><p><img src="https://image.rman.top/blog20210617141651.png" alt="image-20210617141412862"></p><p>Q3: Can the models learn low-pass, high-pass and bandpass filtering effects?</p><p><img src="https://image.rman.top/blog20210617141655.png" alt="image-20210617141424203"></p><p>Q4: Can the models generalize downstream graph classification and regression tasks?</p><p><img src="https://image.rman.top/blog20210617141657.png" alt="image-20210617141437879"></p><h1 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h1><ol><li><p>Theoretically give the explanation that to reach different express power (k-WL test) what operations GNN should have. It will help the successors find way to further improve the express power of GNN.</p></li><li><p>The multiple convolution supports used in GNNML3 is actually a multi-heads attention of different graph structure components to provide different operations’ result vector that can be used to approximate 3-WL test.</p></li><li><p>It cannot theoretically prove the GNNML3 is equal to 3-WL test, because its use the MLP to approximate the trace and multiplication operations.</p></li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h1&gt;&lt;ol&gt;
&lt;li&gt;Existing GNNs’ expressive power 
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="图理论" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%90%86%E8%AE%BA/"/>
    
  </entry>
  
  <entry>
    <title>You are the SUN of my life</title>
    <link href="https://www.rman.top/2021/06/03/You-are-the-SUN-of-my-life/"/>
    <id>https://www.rman.top/2021/06/03/You-are-the-SUN-of-my-life/</id>
    <published>2021-06-03T14:25:58.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="https://image.rman.top/blog20210603222824.png" alt="image-20210603222816897"><br><img src="https://image.rman.top/blog20210603222909.png" alt="image-20210603222905617"><br><img src="https://image.rman.top/blog20210603222930.png" alt="image-20210603222927376"><br><img src="https://image.rman.top/blog20210603223518.png" alt="image-20210603223510877"><br><img src="https://image.rman.top/blog20210603223717.png" alt="image-20210603223708940"><br><img src="https://image.rman.top/blog20210603223557.png" alt="image-20210603223553489"><br><img src="https://image.rman.top/blog20210603223804.png" alt="image-20210603223800523"><br><img src="https://image.rman.top/blog20210603223836.png" alt="image-20210603223829630"><br><img src="https://image.rman.top/blog20210603223859.png" alt="image-20210603223852832"><br><img src="https://image.rman.top/blog20210603224007.png" alt="image-20210603224001642"><br><img src="https://image.rman.top/blog20210603224031.png" alt="image-20210603224024044"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;https://image.rman.top/blog20210603222824.png&quot; alt=&quot;image-20210603222816897&quot;&gt;&lt;br&gt;&lt;img src=&quot;https://image.rman.top/blog202106032
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>Trip to Changsha</title>
    <link href="https://www.rman.top/2021/04/17/trip-to-changsha/"/>
    <id>https://www.rman.top/2021/04/17/trip-to-changsha/</id>
    <published>2021-04-17T12:20:47.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p><img src="https://image.rman.top/blog20210417202845.png" alt="image-20210417202301888"></p><p><img src="https://image.rman.top/blog20210417202906.png" alt="image-20210417202901245"></p><p><img src="https://image.rman.top/blog20210417202954.png" alt="image-20210417202952189"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;https://image.rman.top/blog20210417202845.png&quot; alt=&quot;image-20210417202301888&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://image.rman.top/blog20210
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="girl" scheme="https://www.rman.top/tags/girl/"/>
    
  </entry>
  
  <entry>
    <title>Happy New Year</title>
    <link href="https://www.rman.top/2021/02/20/Happy-New-Year/"/>
    <id>https://www.rman.top/2021/02/20/Happy-New-Year/</id>
    <published>2021-02-20T04:09:34.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="https://image.rman.top/blog20210220121420.png" alt="image-20210220121313714"></p><p><img src="https://image.rman.top/blog20210220121421.png" alt="image-20210220121323019"></p><p><img src="https://image.rman.top/blog20210220121422.png" alt="image-20210220121330408"></p><p><img src="https://image.rman.top/blog20210220121423.png" alt="image-20210220121340419"></p><p><img src="https://image.rman.top/blog20210220121424.png" alt="image-20210220121345967"></p><p><img src="https://image.rman.top/blog20210220121425.png" alt="image-20210220121350877"></p><p><img src="https://image.rman.top/blog20210220121426.png" alt="image-20210220121357021"><br><img src="https://image.rman.top/blog20210220121427.png" alt="image-20210220121401704"></p><p><img src="https://image.rman.top/blog20210220121428.png" alt="image-20210220121404960"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;https://image.rman.top/blog20210220121420.png&quot; alt=&quot;image-20210220121313714&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://image.rman.top/blog20210
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>Heterogeneous Graph Structure Learning for Graph Neural Networks</title>
    <link href="https://www.rman.top/2021/02/20/HGSL/"/>
    <id>https://www.rman.top/2021/02/20/HGSL/</id>
    <published>2021-02-20T03:29:41.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Motivation："><a href="#Motivation：" class="headerlink" title="Motivation："></a>Motivation：</h1><p>现有的异构图学习中一些图的结构是不好的，不利于下游任务，比如在user-item的异构图中，用户可能会点击一些无用的item，从而给异构图表示学习带来一些噪声。</p><p>现有有的一些图结构表示学习的方法，通过把邻接矩阵参数化，学习更好的邻接矩阵用于下游任务。但是他们都是用于同构图的方法。</p><p>本文提出了GSL框架，通过考虑三种不同的图结构：特征相似图，特征传播图，和语义图来学习更好的图结构用于下游任务。</p><h1 id="Approach："><a href="#Approach：" class="headerlink" title="Approach："></a>Approach：</h1><p><img src="https://image.rman.top/blog20210220114030.png" alt="image-20210220114030632"></p><h2 id="特征相似图："><a href="#特征相似图：" class="headerlink" title="特征相似图："></a>特征相似图：</h2><p>通过在节点之间的特征上用度量学习的方法，学习节点之间的相似度，构成相似度矩阵。</p><p><img src="https://image.rman.top/blog20210220114140.png" alt="image-20210220114140320"></p><p><img src="https://image.rman.top/blog20210220114148.png" alt="image-20210220114148339"></p><h2 id="特征传播图："><a href="#特征传播图：" class="headerlink" title="特征传播图："></a>特征传播图：</h2><p>特征转播图通过特征与拓扑之间的交互来生成图结构，特征之间的相似度是可以传播的。我们通过一个例子来更好的理解。例如，考虑生成用户和电影之间的潜在图结构，存在这样一种图结构生成方式：如果用户U1 看过电影M1，且M1和M2相似，那么用户U1可能对M2感兴趣即和节点存在潜在边。上述潜在的图结构可以分两步构建：得到特征相似的节点对（找到相似的电影M1和M2），随后用拓扑结构传播（通过U1的观影历史得到可能感兴趣的电影M2）。HGSL 也通过上述两步过程来得到特征传播图。</p><p>对于每个关系r，首先根据关系的头尾节点集合，根据特征相似矩阵的计算方法，生成相似度矩阵。</p><p><img src="https://image.rman.top/blog20210220114206.png" alt="image-20210220114206881"></p><p>然后再和原始的关系r邻接矩阵相乘，进行相似度传播，得到头相似度矩阵和尾相似度矩阵。</p><p><img src="https://image.rman.top/blog20210220114231.png" alt="image-20210220114223781"></p><h2 id="特征邻接矩阵"><a href="#特征邻接矩阵" class="headerlink" title="特征邻接矩阵"></a>特征邻接矩阵</h2><p>然后对矩阵进行attention聚合，得到特征邻接矩阵。</p><p><img src="https://image.rman.top/blog20210220114305.png" alt="image-20210220114305801"></p><h2 id="语义图："><a href="#语义图：" class="headerlink" title="语义图："></a>语义图：</h2><p>传统的metapath构成邻接矩阵忽视了中间节点，导致了信息丢失。于是本文先通过Metapath2vec学习不同metapath下节点的特征表示，然后根据不同的特征表示来生成不同metapath下的语义邻接矩阵。</p><p><img src="https://image.rman.top/blog20210220114326.png" alt="image-20210220114326039"></p><p>对于多个metapath，进行一个加权聚合得到语义邻接矩阵。</p><p><img src="https://image.rman.top/blog20210220114340.png" alt="image-20210220114340950"></p><h2 id="学习到的异构图邻接矩阵"><a href="#学习到的异构图邻接矩阵" class="headerlink" title="学习到的异构图邻接矩阵"></a>学习到的异构图邻接矩阵</h2><p>把特征邻接矩阵和语义邻接矩阵还有原始的不同关系的邻居矩阵进行attention聚合。</p><p><img src="https://image.rman.top/blog20210220114353.png" alt="image-20210220114353583"></p><h2 id="优化过程"><a href="#优化过程" class="headerlink" title="优化过程"></a>优化过程</h2><p>把学习到的不同关系的邻接矩阵，进行合并，忽视节点的类型，转换成一个大的邻接矩阵。然后进行两层的信息传播并进行预测。</p><p><img src="https://image.rman.top/blog20210220114403.png" alt="image-20210220114403268"></p><h1 id="实验"><a href="#实验" class="headerlink" title="实验"></a>实验</h1><p>在 DBLP、ACM 及 Yelp 数据集上行了丰富的实验来验证HGSL 的有效性。</p><h2 id="节点分类实验"><a href="#节点分类实验" class="headerlink" title="节点分类实验"></a>节点分类实验</h2><p><img src="https://image.rman.top/blog20210220114427.png" alt="image-20210220114427119"></p><h2 id="频道注意力可视化实验"><a href="#频道注意力可视化实验" class="headerlink" title="频道注意力可视化实验"></a>频道注意力可视化实验</h2><p><img src="https://image.rman.top/blog20210220114443.png" alt="image-20210220114443304"></p><h2 id="参数实验"><a href="#参数实验" class="headerlink" title="参数实验"></a>参数实验</h2><p><img src="https://image.rman.top/blog20210220114521.png" alt="image-20210220114521040"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Motivation：&quot;&gt;&lt;a href=&quot;#Motivation：&quot; class=&quot;headerlink&quot; title=&quot;Motivation：&quot;&gt;&lt;/a&gt;Motivation：&lt;/h1&gt;&lt;p&gt;现有的异构图学习中一些图的结构是不好的，不利于下游任务，比如在use
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
      <category term="图结构学习" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%BB%93%E6%9E%84%E5%AD%A6%E4%B9%A0/"/>
    
  </entry>
  
  <entry>
    <title>How to crack a soga backend</title>
    <link href="https://www.rman.top/2021/02/06/crack-soga/"/>
    <id>https://www.rman.top/2021/02/06/crack-soga/</id>
    <published>2021-02-06T17:29:24.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<h1 id="How-to-crack-a-soga-backend"><a href="#How-to-crack-a-soga-backend" class="headerlink" title="How to crack a soga backend"></a>How to crack a soga backend</h1><p>Soga 后端破解思路小分享。</p><p>仅以此文记录和分享一些关于go应用破解的过程。由于本人也是第一次进行go程序的逆向，本文的分析会比较简单和基础。</p><h1 id="Soga"><a href="#Soga" class="headerlink" title="Soga"></a>Soga</h1><p><a href="https://github.com/sprov065/soga">soga 后端是一个同时支持 v2ray、Trojan、Shadowsocks 的后端，社区版最高支持88用户，优化了长时间运行的内存占用。</a></p><p>本文以破解2.0.6为例，在release处可以下载指定版本的soga后端。</p><h1 id="符号还原"><a href="#符号还原" class="headerlink" title="符号还原"></a>符号还原</h1><p>Go二进制文件由于由于其自身恶心的机制导致对其直接在IDA中逆向十分困难。</p><blockquote><p>Go 语言的编译工具链会全静态链接构建二进制文件，把标准库函数和第三方 package 全部做了静态编译，再加上 Go 二进制文件中还打包进去了 runtime 和 GC(Garbage Collection，垃圾回收) 模块代码，所以即使做了 strip 处理( <code>go build -ldflags &quot;-s -w&quot;</code> )，生成的二进制文件体积仍然很大。在反汇编工具中打开 Go 语言二进制文件，可以看到里面包含动辄几千个函数。再加上 Go 语言的独特的函数调用约定、栈结构和多返回值机制，使得对 Go 二进制文件的分析，无论是静态逆向还是动态调式分析，都比分析普通的二进制程序要困难很多。</p><p>不过，好消息是安全社区还是找到了针对性的方法，让安全分析人员对 Go 语言二进制文件的逆向变得更加轻松。最开始有人尝试过针对函数库做符号 Signature 来导入反汇编工具中，还原一部分二进制文件中的函数符号。后来有人研究出 Go 语言二进制文件内包含大量的运行时所需的符号和类型信息，以及字符串在 Go 二进制文件中独特的用法，然后开发出了针对性的符号甚至类型信息恢复工具。至此，对 Go 语言二进制文件的逆向分析工作，就变得轻松异常了。</p><p>-<a href="https://www.anquanke.com/post/id/214940">https://www.anquanke.com/post/id/214940</a></p></blockquote><p>因此为了方便我们进行分析，我在此处采用<a href="https://github.com/0xjiayu/go_parser/blob/master/README_cn.md">go_parser</a>来对二进制文件进行信息还原。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">file--&gt;script file--&gt;go_parser.py</span><br></pre></td></tr></table></figure><p>此脚本能还原出go可执行文件的函数信息以及一些字符串，由于电脑崩溃此处没有保存还原之后的截图。</p><h1 id="软件分析"><a href="#软件分析" class="headerlink" title="软件分析"></a>软件分析</h1><p>在还原字符串以及函数信息之后，破解将十分容易。</p><p>我们首先搜索字符串，寻找验证有关的关键词。一把梭，直接查字符串，找到check。</p><p><img src="https://i.loli.net/2021/02/07/Xh8LtPsnioGwK21.png" alt="img"></p><p>右键x-refer-to定位到check-soga函数。</p><p><img src="https://i.loli.net/2021/02/07/UWeh4GDrQFI3Y1A.png" alt="img"></p><p>查看上层的startsogatask函数，分析函数，我们可得如下结果。</p><p><img src="https://i.loli.net/2021/02/07/2ChfeHI51JZdvDP.png" alt="QQ图片20210207014513"></p><h1 id="软件破解"><a href="#软件破解" class="headerlink" title="软件破解"></a>软件破解</h1><p>简单的将check soga nop掉，直接jmp到 loc_A770F7，这个函数就patch完成了。</p><p><img src="https://i.loli.net/2021/02/07/KM24owZbDPcrIga.png" alt="image-20210207014630516"></p><p>然后外部main_main还要处理一下update问题。同样的nop掉即可。</p><p><img src="https://i.loli.net/2021/02/07/TxCMpztmQwORrEh.png" alt="image-20210207014716589"></p><p><img src="https://i.loli.net/2021/02/07/Gg2JjmZb6eQUvBH.png" alt="image-20210207014726318"></p><h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>至此，一个简单的破解就完成了。很显然对软件的继续分析之后可以看出，此破解方法只是绕过了一开始的key验证，在之后的运行中，仍然会有隔一段时进行验证的行为。本文只是抛砖引玉，分享一些自己逆向分析go的二进制文件的心得，读者可以自行进行尝试，进行更加完善的破解。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;How-to-crack-a-soga-backend&quot;&gt;&lt;a href=&quot;#How-to-crack-a-soga-backend&quot; class=&quot;headerlink&quot; title=&quot;How to crack a soga backend&quot;&gt;&lt;/a&gt;How t
      
    
    </summary>
    
    
      <category term="技术分享" scheme="https://www.rman.top/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/"/>
    
    
      <category term="破解" scheme="https://www.rman.top/tags/%E7%A0%B4%E8%A7%A3/"/>
    
      <category term="go" scheme="https://www.rman.top/tags/go/"/>
    
      <category term="逆向" scheme="https://www.rman.top/tags/%E9%80%86%E5%90%91/"/>
    
  </entry>
  
  <entry>
    <title>Beyond Clicks Modeling Multi-Relational Item Graph for Session-Based Target Behavior Prediction</title>
    <link href="https://www.rman.top/2020/12/13/MGNN/"/>
    <id>https://www.rman.top/2020/12/13/MGNN/</id>
    <published>2020-12-13T07:07:18.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Background"><a href="#Background" class="headerlink" title="Background"></a>Background</h2><p><strong>Session recommendation:</strong> </p><p>Aiming to predict the next item to be interacted with a user under a specific type of behavior, and modeling user dynamic interest.</p><p><strong>Target behavior session recommendation:</strong> </p><p>Considers target behavior and auxiliary behavior sequences and explores for accurate prediction.</p><p><img src="http://image.rman.top/blog20201213153011.png" alt="Next  Session recommendation  Target behavior is sparse but important.  Next  Target behavior session recommendation "></p><h2 id="Challenges"><a href="#Challenges" class="headerlink" title="Challenges"></a>Challenges</h2><ul><li>Firstly, most existing  methods focus on only using the same type of user behavior as input for the next item prediction, but ignore the potential of leveraging other  type of behavior as auxiliary information.</li><li>Secondly,  item-to-item relations are modeled separately and locally, since both RNN based and GNN based recommendation models only utilize one behavior sequence each time.</li></ul><h2 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h2><ul><li>We break the restriction of only using one type of  behavior sequence in session-based recommendation and <strong>exploring  another type of behavior</strong> as auxiliary information and construct the multirelational item graph for learning global item-to-item relations.</li><li>we develop the novel graph model MGNN-SPred which learns <strong>global item-to-item relations</strong> through graph neural network and integrates representations of target and auxiliary of current sequences by the gating mechanism.</li><li>We carry <strong>out extensive experiments</strong> and demonstrate MGNNSPred achieves the best performance among strong competitors.</li></ul><h2 id="Method"><a href="#Method" class="headerlink" title="Method"></a>Method</h2><p><img src="http://image.rman.top/blog20201213153038.png" alt="img"></p><h3 id="Problem-Definition"><a href="#Problem-Definition" class="headerlink" title="Problem Definition"></a>Problem Definition</h3><p>• Session set: $S$<br>• Target behavior sequence: $P^s=[p<em>1^s,⋯,p</em>|P^s |^s]$<br>• Auxiliary behavior sequence: $Q^s=[q<em>1^s,⋯,q</em>(|Q^s |)^s]$<br>• Multi-Relational Item Graph: $G=(V,E)$, $V$ is the set of nodes in the<br>• graph containing all available items and $E$ is the edge sets involving<br>• Multiple types of directed edges. Each edge is a triple consisting of the head item, the tail item, and the type of this edge. Edge $(a, b, click) ∈ E$ means that a user clicked item $b$ after clicking item $a$.</p><h3 id="Graph-Construction"><a href="#Graph-Construction" class="headerlink" title="Graph Construction"></a>Graph Construction</h3><p>The algorithm browses all behavior sequences, collects all items in the sequences as the nodes of the graph, and constructs edges between two consequent items in the same sequence with their behavior types as the edge types.</p><p><img src="http://image.rman.top/blog20201213154029.png" alt="image-20201213154019948"></p><h3 id="Item-Representation-Learning"><a href="#Item-Representation-Learning" class="headerlink" title="Item Representation Learning"></a>Item Representation Learning</h3><p>For each node $v∈V$, first convert them to a space $E∈\mathbb{R}^{|V|×d}$, and feed them with MRIG into GNN.</p><p>Each node in the graph has four types of neighboring node sets. According to the type and direction, we name the four sets as “target-forward”, “target-backward”, “auxiliary-forward”, and “auxiliary-backward”.</p><p><img src="http://image.rman.top/blog20201213154129.png" alt="image-20201213154129052"></p><p>Same for the auxiliary set.</p><h3 id="Item-Representation-Learning-1"><a href="#Item-Representation-Learning-1" class="headerlink" title="Item Representation Learning"></a>Item Representation Learning</h3><p>First aggregate each group of neighbors by mean-pooling to obtain the representation of this group, defined as below:</p><p><img src="http://image.rman.top/blog20201213154152.png" alt="image-20201213154152657"></p><p>Then, we combine these four representations of different neighbor groups by sum-pooling:</p><p><img src="http://image.rman.top/blog20201213154216.png" alt="image-20201213154216522"></p><p>Finally, we update the representation of the center node 𝑣 by:</p><p><img src="http://image.rman.top/blog20201213154157.png" alt="image-20201213154157722"></p><h3 id="Sequence-Representation-Learning"><a href="#Sequence-Representation-Learning" class="headerlink" title="Sequence Representation Learning"></a>Sequence Representation Learning</h3><p>Mean pooling the target behavior sequence $𝑃$ and auxiliary behavior sequence $𝑄$ as $p$ and $q$, respectively, which are given as:</p><p><img src="http://image.rman.top/blog20201213154243.png" alt="image-20201213154243403"></p><p>where $g_v=h_v^K$, and $K$ is the total iterations of the GNN.</p><p>A gate mechanism to calculate the relative importance weight $𝛼$</p><script type="math/tex; mode=display">α=σ(W_g [p;q])</script><p>$o$ for the current session by the weighted summation of $p$ and $q$:</p><script type="math/tex; mode=display">o=α ⋅p+(1-α)⋅q</script><h3 id="Model-Prediction-and-Training"><a href="#Model-Prediction-and-Training" class="headerlink" title="Model Prediction and Training"></a>Model Prediction and Training</h3><p>We further calculate the recommendation score $𝑠_𝑣$ of each item $v ∈V$ using the item embedding $e_v$ . A bi-linear matching scheme is employed by:</p><script type="math/tex; mode=display">s_v=o^⊤ We_v</script><p>Over all items to get the probability distribution $\hat{y}$:</p><script type="math/tex; mode=display">\hat{y}=softmax(s)</script><p>Loss function:</p><p><img src="http://image.rman.top/blog20201213154515.png" alt="image-20201213154515710"></p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><h3 id="Datasets"><a href="#Datasets" class="headerlink" title="Datasets:"></a>Datasets:</h3><p><img src="http://image.rman.top/blog20201213154534.png" alt="image-20201213154533984"></p><h3 id="Baselines"><a href="#Baselines" class="headerlink" title="Baselines:"></a>Baselines:</h3><p><img src="http://image.rman.top/blog20201213154543.png" alt="image-20201213154542945"></p><h4 id="Results"><a href="#Results" class="headerlink" title="Results"></a>Results</h4><p><img src="http://image.rman.top/blog20201213154559.png" alt="image-20201213154559738"></p><p><img src="http://image.rman.top/blog20201213154603.png" alt="image-20201213154603602"></p><p><img src="http://image.rman.top/blog20201213154606.png" alt="image-20201213154606397"></p><p><img src="http://image.rman.top/blog20201213154610.png" alt="image-20201213154610835"></p><p><img src="http://image.rman.top/blog20201213154614.png" alt="image-20201213154614279"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Background&quot;&gt;&lt;a href=&quot;#Background&quot; class=&quot;headerlink&quot; title=&quot;Background&quot;&gt;&lt;/a&gt;Background&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Session recommendation:&lt;/stron
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="会话推荐" scheme="https://www.rman.top/tags/%E4%BC%9A%E8%AF%9D%E6%8E%A8%E8%8D%90/"/>
    
      <category term="序列推荐" scheme="https://www.rman.top/tags/%E5%BA%8F%E5%88%97%E6%8E%A8%E8%8D%90/"/>
    
      <category term="推荐系统" scheme="https://www.rman.top/tags/%E6%8E%A8%E8%8D%90%E7%B3%BB%E7%BB%9F/"/>
    
  </entry>
  
  <entry>
    <title>GHashing Semantic Graph Hashing for Approximate Similarity Search in Graph Databases</title>
    <link href="https://www.rman.top/2020/11/13/GHashing/"/>
    <id>https://www.rman.top/2020/11/13/GHashing/</id>
    <published>2020-11-13T14:09:49.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Objection："><a href="#Objection：" class="headerlink" title="Objection："></a>Objection：</h2><ul><li><p>Retrieve graphs from the database similar enough to a query.</p></li><li><ul><li>Optimize the pruning stage.</li></ul></li></ul><h2 id="Background"><a href="#Background" class="headerlink" title="Background:"></a>Background:</h2><ul><li>Graph Edit Distance (GED) is a method to measure the distance between two graphs.</li><li>The current similarity search, first compute the lower bound between the query and the every candidate graph and they prune the graph larger tan than the threshold. Then, they compute the exact GED in the remaining graphs.</li></ul><h2 id="Challenges"><a href="#Challenges" class="headerlink" title="Challenges:"></a>Challenges:</h2><ul><li><p>The computation of Graph Edit Distance (GED) is NP-hard.</p></li><li><p>Existing methods cannot handle the large databases due to their exact pruning strategy.</p></li><li><ul><li>Subgraph isomorphism check to generate the graph index</li><li>GED lower bounds are too  loose, which leads to many candidates.</li></ul></li></ul><h2 id="Deep-hash-retrieval"><a href="#Deep-hash-retrieval" class="headerlink" title="Deep hash retrieval:"></a>Deep hash retrieval:</h2><p><img src="http://image.rman.top/blog20201114133540.png" alt="image-20201114133540575"></p><p><img src="http://image.rman.top/blog20201114133543.png" alt="Target  K: categ  00 Ι Ι0Ι0Ι0ΙOΙ  ΙΙ0ΙΙ0Ι0Ι0  οιοιιοιοιοοι  001101101010 "></p><h2 id="Graph-Deep-Hash"><a href="#Graph-Deep-Hash" class="headerlink" title="Graph Deep Hash:"></a>Graph Deep Hash:</h2><ul><li>Train a GNN as hash function to generate the index of the graph, where the similarity computation can     be done on the hash index instead of the whole graph.</li><li>Prune the graphs using the hash code and embeddings.</li><li>Compute the exact GED using GED solver.</li></ul><p><img src="http://image.rman.top/blog20201114133609.png" alt="Graph  Conv  Graph  Conv  Graph  Graph  Conv  P ooling  Offline  Stage  Online  Stage  Graph Feature Extraction  Embe dding  Loss.*  Embedding  Embedding  Binarizatlon  Graph  Graph  Graph  Graph  A ttenti on  Ha sh Index  F(go  F(gJ  Pluning Phase  Verification "></p><h2 id="Challenges-for-Graph-Deep-Hash"><a href="#Challenges-for-Graph-Deep-Hash" class="headerlink" title="Challenges for Graph Deep Hash:"></a>Challenges for Graph Deep Hash:</h2><ul><li>The threshold for graph similarity search may vary from query to query, it is appropriate to treat it as a regression problem, which requires estimating GED by hamming distance.</li><li>How to establish a relationship between hamming distance and GED is a problem.</li><li>Lack of positive samples.</li></ul><h2 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h2><ul><li>We provide a <strong>first</strong> attempt to use a neural-network-based approach to address the similarity search problem for graph databases via graph hashing.</li><li>We propose a novel method GHashing, a <strong>GNN-based</strong> graph hashing approach, which can <strong>automatically</strong> learn a hash function that maps graphs into <strong>binary vectors</strong>, to enhance the <strong>pruning-verification framework</strong> by providing a fast and accurate pruner.</li><li>We conduct extensive experiments to show that our method not only has an average F1-score of 0.80 on databases with <strong>5</strong> <strong>million graphs</strong> but also on average <strong>20× faster</strong> than the only state-of-the-art baseline on million-scale datasets.</li></ul><h2 id="Preliminaries"><a href="#Preliminaries" class="headerlink" title="Preliminaries"></a>Preliminaries</h2><p>•Graph Edit Distance (GED): $ged(g_1,g_2)$ is defined as the minimum number of edit operations to make $g_1$ isomorphic to $g_2$. The operation can be one of the following:</p><ol><li>Insert a node</li><li>Delete a node</li><li>Change the label of the node</li><li>Insert an edge</li><li>Delete an edge</li></ol><p>Graph Similarity Search under GED: Given a graph database $D$ with $N$ graphs, and a query graph $q$ and a threshold $τ$, the graph similarity search under GED measure aims to find ${g│g∈D∧ged(g,q)≤τ}$</p><h2 id="Approach"><a href="#Approach" class="headerlink" title="Approach:"></a>Approach:</h2><h3 id="Hash-function"><a href="#Hash-function" class="headerlink" title="Hash function :"></a>Hash function :</h3><p><img src="http://image.rman.top/blog20201114135325.png" alt="Graph  Conv  Offline  Stage  Graph  Conv  Graph  Attention  Conv  Pooling  Graph Feature Extraction  Graph  Continuous  Embedding  Continuous  Binarization  Graph  Conv  Graph  Conv  Graph  Attenti on  Conv  Pooling "></p><h4 id="Graph-neural-network"><a href="#Graph-neural-network" class="headerlink" title="Graph neural network:"></a>Graph neural network:</h4><p><img src="http://image.rman.top/blog20201114135327.png" alt="wEN (v)  h (1+1)  = (h(vl), m  (7)  (8) "></p><h4 id="Graph-pooling"><a href="#Graph-pooling" class="headerlink" title="Graph pooling:"></a>Graph pooling:</h4><p><img src="http://image.rman.top/blog20201114135330.png" alt="IVI  (10)  IVI  n=l  where 0(•) is any activation function, V•V/a is trainable parameters  and ReLU(X) = max(X, 0). "></p><h3 id="Loss-function"><a href="#Loss-function" class="headerlink" title="Loss function:"></a>Loss function:</h3><script type="math/tex; mode=display">L=λL_{code} (g_1,g_2 )+(1-λ) L_{emb} (g_1,g_2 )</script><script type="math/tex; mode=display">L_{code} (g_1,g_2 )=L(\hat y,y)</script><script type="math/tex; mode=display">\hat {𝑦} =|𝐻(𝑔_1 )−𝐻(𝑔_2 )|,  𝑦=𝑔𝑒𝑑(𝑔_1,𝑔_2 ),  𝐿 can be any loss function for regression.</script><h4 id="Design-of-L-code"><a href="#Design-of-L-code" class="headerlink" title="Design of $L_{code}$"></a>Design of $L_{code}$</h4><ul><li>GED can be arbitrarily large, the hamming distance between two B-bit hash codes can not be larger than B.</li><li>Therefore, L should satisfy following properties:<ul><li>Small punishment when both values are large $L(\hat y,y)=L′(min⁡{γ,\hat y},min{γ,y})$</li><li>Asymmetric: $L(\hat y,y)≠L(y,\hat y)$, estimated hamming distance should smaller than GED.</li><li>Minimized when $\hat y= y$</li><li>Convex</li></ul></li></ul><p><img src="http://image.rman.top/blog20201114135804.png" alt="image-20201114135804231"></p><h4 id="Handling-discrete-constraints"><a href="#Handling-discrete-constraints" class="headerlink" title="Handling discrete constraints"></a>Handling discrete constraints</h4><p>Hamming distance to Euclidean space</p><p><img src="http://image.rman.top/blog20201114135859.png" alt="image-20201114135859172"></p><p>Binary regularization</p><p><img src="http://image.rman.top/blog20201114135907.png" alt="image-20201114135907457"></p><h4 id="Design-of-L-emb"><a href="#Design-of-L-emb" class="headerlink" title="Design of $L_{emb}$"></a><strong>Design of</strong> $L_{emb}$</h4><p><img src="http://image.rman.top/blog20201114135934.png" alt="image-20201114135934082"></p><h3 id="Online-Stage"><a href="#Online-Stage" class="headerlink" title="Online Stage"></a>Online Stage</h3><ol><li>Encode the query graph to $H(q)$</li><li><p>Search the keys whose hamming distance to $H(q)$ is less than $τ+t$, $t$ is set to 1.</p></li><li><p>Second-stage pruning by computing$||F(g)-F(q)||_2^2&gt;τ+0.5$</p></li><li><p>Verify every graph remained with exact verification algorithm</p></li></ol><p><img src="http://image.rman.top/blog20201114135956.png" alt="Online  Stage  010  Hash Key  010  011  101  110  111  Hash Index  Pruning Phase  Fir-st-Level "></p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment:"></a>Experiment:</h2><h3 id="Datasets"><a href="#Datasets" class="headerlink" title="Datasets"></a>Datasets</h3><p><img src="http://image.rman.top/blog20201114140100.png" alt="Dataset  AIDS  LINUX  ALCHEMY  IDI  42, 687  38, 661  119, 487  5, 000, 000  5, 000, 000  ave IVI  25  16  21  10  10  ave IEI  55  34  44  66  40  ILOI  62  Lel "></p><p><img src="http://image.rman.top/blog20201114140108.png" alt="Table 2: Recall/lcl ratio (x 10¯5) for GHashing and Naive  2  3  4  6  690  270  150  98  69  52  AIDS  GH  30  19  15  11  7.3  6.2  ALCHEMY  Naive  7.0  5.5  4.8  4.3  3.8  3.6  23  20  16  14  13  11  GH  15  12  10  8.8  7.9  6.7  N aive  16  12  10  8.6  7.7  6.6  11  4.9  2.8  1.9  1.2  GH-  3.5  2.4  1.7  1.4  1.0  1.0  Naive  4.2  2.7  1.9  1.4  1.2  1.0 "></p><p><img src="http://image.rman.top/blog20201114140111.png" alt="Table 3: Recall/lcl ratio for different code lengths on  AIDS dataset  24 bit  28  18  13  9.6  7.5  6.1  32 bit  19  15  11  7.1  48 bit  70  43  30  21  15  12 "></p><p><img src="http://image.rman.top/blog20201114140114.png" alt="(i)lCl vs.r(ALCHEMY)  冖 3 ) ICI vs.T(AIDS)  (j)Pvs.T(ALCHEMY)  冖 f)Pvs.TdlNUX)  (b) p vs. T(AIDS)  (k) R vs.T(ALCHEMY) (1) Fl vs.r(ALCHEMY)  (g) R vs. T(LINUX)  (c)Rvs 44m 匕  (h)F1vs r(LINUX)  (d)F1vs.r(AIDS) "></p><p>为什么$\tau$越大recall反而下降了呢？</p><p>在问了老师之后，可能的解释是随着$\tau$上升，正例的样本也变多了，所以recall下降了。</p><p><img src="http://image.rman.top/blog20201114140118.png" alt="Real GED  Figure 3: Violin plots of predicted GED given real GED on  AIDS dataset. A violin plot is an extension of the box plot,  where each &quot;violin&quot; is a plot of the density function of a his-  togram produced from the data. "></p><p>The results in Figure 3 show that the hamming distance is usually smaller than the real GED</p><p><img src="http://image.rman.top/blog20201114140300.png" alt="• BSS-GED  1E+2  • ML-ındex.._GH  E 1E+O  İZ 1E-I  1E-2  g 1E-3  ı. ı. ı. II ı II  • Inves  ı.E+3  11.E+2  •-I.E+I  21.E+0  ı.E+1  zı.E+O  ı.E-ı  ı.E-3  ı.E+2  12345  (a) T vs. T (AIDS)  ı.E+2  zı.E+1  El.E+O  ı.E-2  1 23  (d) R/T vs. T (AIDS)  6  6  12345  (b) T vs. T (LİNUX)  6  123456  (c) T vs. T (ALCHEMY)  ı.E+1  ZI.E+O  Z ı.E-ı  ı.E-2  11  123456  (e) R/T vs. T (LİNUX)  ı  2  3456  (f) R/T vs. T (ALCHEMY)  Figure 4: Average query time (T), recall/time ratio for GH  and three baselines on three real datasets. The truncated bar  means the total running time exceeds 1000 minutes. "></p><p><img src="http://image.rman.top/blog20201114140305.png" alt="Table 4: Costs of offline stage for GHashing and ML-Index  Dataset  AIDS ALCHEMY LNUX  NIL-I  n dex  Time  Space  Time  Space  759s  56M  696s  678M  443s  136M  248s  960M  1143s  52M  N/A  N/A  3172s  5.1G  N/A  N/A  3544s  5.1G  N/A  N/A "></p><p>在线查询快，recall高，offline训练时间少，存储空间少。好就完事了！yizhou Sun 牛！</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Objection：&quot;&gt;&lt;a href=&quot;#Objection：&quot; class=&quot;headerlink&quot; title=&quot;Objection：&quot;&gt;&lt;/a&gt;Objection：&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Retrieve graphs from the data
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="图数据库" scheme="https://www.rman.top/tags/%E5%9B%BE%E6%95%B0%E6%8D%AE%E5%BA%93/"/>
    
  </entry>
  
  <entry>
    <title>Distance Encoding – Design Provably More Powerful Graph Neural Networks for Structural Representation Learning</title>
    <link href="https://www.rman.top/2020/11/13/DistanceEncoding/"/>
    <id>https://www.rman.top/2020/11/13/DistanceEncoding/</id>
    <published>2020-11-13T14:09:26.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="The-problem-of-GNNs"><a href="#The-problem-of-GNNs" class="headerlink" title="The problem of GNNs:"></a>The problem of GNNs:</h1><ul><li>传统GNN会被1-WL     test 所限制。因为节点都是以度进行区分的。</li><li>核心问题：节点分类或者连接预测并不是同构问题，但是GNN是基于WL-test的所以必须要给节点引入特征。<br><img src="https://image.rman.top/blog20210220115605.png" alt="image-20210220115605821"></li><li>传统的WLtest会根据节点的度来区分节点，就会导致无法区分结构信息<br><img src="https://image.rman.top/blog20210220115734.png" alt="image-20210220115734405"></li><li>在这里做两层卷积会导致节点信息都是相同，无法直接区分两个节点之间是否有连边。<br><img src="https://image.rman.top/blog20210220115706.png" alt="image-20210220115706653"></li><li>全图分类会有无法区分<br><img src="http://image.rman.top/blogclip_image004.png" alt="Suppose we query two entire graphs. Can WLGNNs distinguish them? "></li></ul><h1 id="Distance-Encoding"><a href="#Distance-Encoding" class="headerlink" title="Distance Encoding:"></a>Distance Encoding:</h1><ul><li>采用最短路径作为特征，可以区分节点同构</li></ul><p><img src="http://image.rman.top/blogclip_image005.png" alt="Suppose we query these two red node. Can WL-GNNs  distinguish them within 2 layer? "></p><p><img src="https://image.rman.top/blog20210220115813.png" alt="image-20210220115813584"></p><ul><li>同时也可以解决链接预测的问题。对每个pair都对图中的所有节点算最短距离。</li></ul><p><img src="http://image.rman.top/blogimage-20201113224654272.png" alt="image-20201113224654272"></p><ul><li><p>对于全图的预测来说</p></li><li><p>对每个节点都进行标记，然后就能区分</p></li></ul><p><img src="http://image.rman.top/blogclip_image008.png" alt="Suppose we query two entire graphs. Can WLGNNs distinguish them?  blue nth distanæ while all paiß  Of green with distance "></p><p> <img src="http://image.rman.top/blogclip_image009.png" alt="Distance encoding  • A target node subset S, and a node u in V  • Distance Encoding:  where  - (Wuv, WK, ... , wk)  ((ulv) = ), I  uv uv  W is the random walk matrix: W = AD -l  Shortest-Path-Distance (SPD), personalized pageRank scores, Katz  similarity are all special cases.  In practice, k: 2—4. "></p><p><img src="http://image.rman.top/blogclip_image010.png" alt="Take-away I:  1.  2.  3.  4.  5.  6.  A target node subset S, and a node u in V  Extract the ego-net around S.  Use BFS to compute shortest path distance (SPD) or random walk  matrix power WK between each node v in S and u in the ego-net.  You obtain ((ulv). If SPD&gt; threshold, set a default value.  Use one-hot encoding of  Concate &lt; (ulS) with the original node attributes and then use WL-  GNNs over this ego-net. "></p><ul><li>采用one-hop标记，dimension最大是要卷积的距离，比如最大距离是4，则有4为0000，比如有两个节点到他的距离分布是2和3，则最后距离嵌入表示是0110，如何有两个节点是距离为4则是0002，以此类推。</li><li>得到feature就把它拼接到原始节点上进行卷积</li></ul><h3 id="证明："><a href="#证明：" class="headerlink" title="证明："></a>证明：</h3><p><img src="http://image.rman.top/blogclip_image011.png" alt="The Power of DE-GNN for p-sized node-set  Theorem 3.3  • Two structures (SI,AI) and (S2,A2) with ISII= IS21 = p, p fixed:  1.  2.  3.  Al and AZ are only different in structures (features are all the same)  that are uniformly independently sampled from r-regular graphs (r &lt;  (210g n)AO.5)  DE-GNN (with some injective requirement) within layers L &lt;  (0.5+e) log  can distinguish (SI,AI) and (S2,A2) with probability 1-  O(l/n)  Distance encoding can be simply chosen as shortest-path-distance "></p><ul><li>对于层数不断增加，则区分度更好。<br><img src="http://image.rman.top/blogclip_image012.png" alt="Empirical evaluation  Simulation:  Uniformly sample 104/n many  n-sized 3-regular graphs.  Compare all pairs of nodes (u,v)  Use an untrained DE-GNN after  L layers with randkm  initialization.  The color of the points implies  the portion of pairs of u,v such  that — le — 12.  O  0.5 logn  simulation  1.0  0.8  0.6  0.4  0.2  0.0 "></li></ul><h3 id="实验："><a href="#实验：" class="headerlink" title="实验："></a>实验：</h3><ul><li>实验是在以节点周围结构为准的图来进行判断。</li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;The-problem-of-GNNs&quot;&gt;&lt;a href=&quot;#The-problem-of-GNNs&quot; class=&quot;headerlink&quot; title=&quot;The problem of GNNs:&quot;&gt;&lt;/a&gt;The problem of GNNs:&lt;/h1&gt;&lt;ul
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
  </entry>
  
  <entry>
    <title>Heterogeneous Deep Graph Infomax</title>
    <link href="https://www.rman.top/2020/09/03/HDGI/"/>
    <id>https://www.rman.top/2020/09/03/HDGI/</id>
    <published>2020-09-03T07:58:08.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Heterogeneous-Deep-Graph-Infomax"><a href="#Heterogeneous-Deep-Graph-Infomax" class="headerlink" title="Heterogeneous Deep Graph Infomax"></a>Heterogeneous Deep Graph Infomax</h1><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>Inspired by the emerging mutual information-based learning algorithm, This paper propose an <strong>unsupervised</strong> graph neural network Heterogeneous Deep Graph Infomax (HDGI) for heterogeneous graph representation learning.</p><p>Author utilized the <strong>meta-path</strong> to model the structure information involving semantics in Heterogeneous graph and apply the <strong>graph convolution</strong> module and <strong>semantic-attention</strong> module to capture the individual node local representation.</p><p>By maximizing the local-global mutual information, HDGI effectively learns highlevel node representations based on the diverse information in heterogeneous graphs</p><h2 id="Unsupervised-graph-representation-learning"><a href="#Unsupervised-graph-representation-learning" class="headerlink" title="Unsupervised graph representation learning"></a>Unsupervised graph representation learning</h2><ul><li>Matrix factorization: capture the global graph information by factorizing the affinity matrix, which ignore the node attributes and local neighborhood relationships.</li><li>Edge-based method: capture the local and high-order neighborhood information by edges connections or random-walk paths, which only preserve limited order node proximity and lack a mechanism<br>to preserve the global graph structure.</li><li>DGI(Deep graph infomax): maximizes the mutual information between graph patch representations and the corresponding high-level summaries of graphs. It has shown competitive performance even compared with supervised graph neural networks in benchmark homogeneous graphs.</li></ul><h2 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h2><ul><li>This paper presents the first model to apply mutual information maximization to representation learning in heterogeneous graphs.</li><li>HDGI, is a novel unsupervised graph neural network. It handles graph heterogeneity by utilizing an attention mechanism on meta-paths and deals with the unsupervised settings by applying mutual information maximization.</li><li>HDGI are effective for both node classification and clustering tasks. Moreover, its performance can also beat state-of-the-art GNN models, where they have the additional supervised label information.</li></ul><h2 id="Mutual-information"><a href="#Mutual-information" class="headerlink" title="Mutual information"></a>Mutual information</h2><p>Mutual information is a quantity that measures a relationship between two random variables that are sampled simultaneously.</p><p><img src="http://image.rman.top/blogimage-20200903141813565.png" alt="image-20200903141813565"></p><p>In order to maximize the <strong>MI</strong>, we need maximize the $\frac{p(y|x)}{p(y)}$, which means $p(y|x)$ is bigger than $p(y)$. For each input $x$, the encoder can find a feature $y$ that can well represent $x$.</p><h2 id="Notation"><a href="#Notation" class="headerlink" title="Notation"></a>Notation</h2><p>Heterogenous graph: $\mathcal{G}=(\mathcal{V},\mathcal{E})$</p><p>Node type mapping function: $\phi:\mathcal{V}\to\mathcal{T},\phi(v)\in \mathcal{T}$</p><p>Edge type mapping function:$\psi:\mathcal{E}\to\mathcal{R},\psi(e)\in \mathcal{R}$</p><p>$\mathcal{T}+\mathcal{R}&gt;2$</p><p>Metapath: $\Phi=v<em>1 \mathop{\to}\limits^{R_1}\cdots \mathop{\to}\limits^{R</em>{n-1}}v_n$</p><p>Given a metapath $\Phi<em>i$, if there exists a metapath instance between $v_i,j_j$, then $A</em>{ij}^{\Phi_i}=1$ where $A^{\phi_i}$ is the adjacent matrix of metapath $\Phi_i$.</p><p><strong>Problem definition</strong>: Given a $\mathcal{G}$ and the initial feature matrix $X$, the representation $H\in\mathbb{R}^{|V|\times d}$ which contains both structure and node attributes information.</p><h2 id="Approach"><a href="#Approach" class="headerlink" title="Approach"></a>Approach</h2><p><img src="http://image.rman.top/blogimage-20200903143747045.png" alt="image-20200903143747045"></p><h3 id="Meta-path-based-local-representation-encoder"><a href="#Meta-path-based-local-representation-encoder" class="headerlink" title="Meta-path based local representation encoder"></a>Meta-path based local representation encoder</h3><p>The first step is meta-path specific node representation learning which encodes nodes in terms of each meta-path based adjacency matrix respectively.</p><script type="math/tex; mode=display">H^{\Phi_i}=a_{\Phi_i}(X,A^{\Phi_i})</script><p>Two kinds of encoder are considered in this work.</p><p><strong>GCN:</strong></p><p><img src="http://image.rman.top/blogimage-20200903144133410.png" alt="image-20200903144133410"></p><p>Where $A^{\widetilde{\Phi_i}}=A^{\Phi_i}+I$</p><p><strong>GAT:</strong></p><p><img src="http://image.rman.top/blogimage-20200903144328223.png" alt="image-20200903144328223"></p><h3 id="Heterogeneous-graph-node-representation-learning"><a href="#Heterogeneous-graph-node-representation-learning" class="headerlink" title="Heterogeneous graph node representation learning"></a>Heterogeneous graph node representation learning</h3><p>After the meta-path representation, We need to aggregate the more general representations of the nodes.</p><p><img src="http://image.rman.top/blogimage-20200903144505589.png" alt="image-20200903144505589"></p><p>The importance of each meta-path is calculated as:</p><p><img src="http://image.rman.top/blogimage-20200903144558452.png" alt="image-20200903144558452"></p><p><img src="http://image.rman.top/blogimage-20200903144606672.png" alt="image-20200903144606672"></p><p>The final representation $H$ is obtained by:</p><p><img src="http://image.rman.top/blogimage-20200903144645308.png" alt="image-20200903144645308"></p><h3 id="Global-Representation-Encoder"><a href="#Global-Representation-Encoder" class="headerlink" title="Global Representation Encoder"></a>Global Representation Encoder</h3><p><strong>Averaging encoder function.</strong></p><p><img src="http://image.rman.top/blogimage-20200903145114044.png" alt="image-20200903145114044"></p><p><strong>Pooling encoder function</strong></p><p><img src="http://image.rman.top/blogimage-20200903145143071.png" alt="image-20200903145143071"></p><p>Each node’s vector is independently fed through a fully connected layer. An elementwise max-pooling operator is applied to summary the information from the nodes set</p><p><strong>Set2vec encoder function</strong></p><p>Author randomly permutate of the node’s neighbors on an unordered set and feed to the LSTM</p><h3 id="HDGI-Learning"><a href="#HDGI-Learning" class="headerlink" title="HDGI Learning"></a>HDGI Learning</h3><p><strong>Mutual information based discriminator</strong></p><p>Belghazi et al. proved that the KL-divergence admits the Donsker-Varadhan representation and the f-divergence representation as dual representations:</p><p><img src="http://image.rman.top/blogimage-20200903150208248.png" alt="image-20200903150208248"></p><p>$\mathbb{P}_{xy}$ is the joint distribution and $\mathbb{P}_x\otimes \mathbb{P}_Y$ is the product of margins, $T_w$ is a deep neural network based discriminator.</p><p>Author estimate and maximize the mutual information by training an discriminator $D$ to distinguish positive sample set $Pos={[\vec{h<em>n},\vec{s}]}^N</em>{n=1}$ with negative sample set $Neg={[\vec{ \widetilde{h<em>m}},\vec{s}]}^M</em>{m=1}$.</p><p>The sample $(\vec{h_i},\vec{s})$ is the positive node belongs to graph, and $(\vec{ \widetilde{h_m}},\vec{s})$ is the generated fake node.</p><p>The discriminator $D$ is a bilinear layer:</p><script type="math/tex; mode=display">D(\vec{h_i})=\sigma(\vec{h_i}^{\top}W_D\vec{s})</script><p><strong>Loss function:</strong></p><p><img src="http://image.rman.top/blogimage-20200903151118784.png" alt="image-20200903151118784"></p><p><strong>Negative samples generator:</strong></p><p><img src="http://image.rman.top/blogimage-20200903151241338.png" alt="image-20200903151241338"></p><p>Keep the graph structure unchanged and shuffle the feature of each node in the graph.</p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><h3 id="Dataset"><a href="#Dataset" class="headerlink" title="Dataset:"></a>Dataset:</h3><p><img src="http://image.rman.top/blogimage-20200903151508638.png" alt="image-20200903151508638"></p><h3 id="Node-classification"><a href="#Node-classification" class="headerlink" title="Node classification"></a>Node classification</h3><p><img src="http://image.rman.top/blogimage-20200903151542175.png" alt="image-20200903151542175"></p><h3 id="Node-clustering-task"><a href="#Node-clustering-task" class="headerlink" title="Node clustering task"></a>Node clustering task</h3><p><img src="http://image.rman.top/blogimage-20200903152412935.png" alt="image-20200903152412935"></p><h3 id="Ablation-experiment"><a href="#Ablation-experiment" class="headerlink" title="Ablation experiment"></a>Ablation experiment</h3><p><img src="http://image.rman.top/blogimage-20200903152517415.png" alt="image-20200903152517415"></p><h3 id="Some-discovery"><a href="#Some-discovery" class="headerlink" title="Some discovery :"></a>Some discovery :</h3><p>The HDGI is highly depend on the initial feature $X$, when the $X$ is random initiated the performance of HDGI decreased dramatically.</p><div class="table-container"><table><thead><tr><th>Method</th><th>Classification (feat)</th><th></th><th>Classification (no feat)</th><th></th><th>Cluster (feat)</th><th></th><th>Cluster (no feat)</th><th></th></tr></thead><tbody><tr><td></td><td>Micro F1</td><td>Macro F1</td><td>Micro F1</td><td>Macro F1</td><td>NMI</td><td>ARI</td><td>NMI</td><td>ARI</td></tr><tr><td>HAN</td><td>0.9329</td><td>0.9336</td><td>0.8547</td><td>0.8506</td><td>0.2691</td><td>0.2193</td><td>0.6305</td><td>0.6956</td></tr><tr><td>HGT</td><td>0.8224</td><td>0.8175</td><td>0.8298</td><td>0.8265</td><td>0.4944</td><td>0.4782</td><td>0.4548</td><td>0.4104</td></tr><tr><td>HDGI-C</td><td>0.8273</td><td>0.8156</td><td>0.4969</td><td>0.2246</td><td>0.0056</td><td>0.0038</td><td>0.0202</td><td>0.0530</td></tr></tbody></table></div>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Heterogeneous-Deep-Graph-Infomax&quot;&gt;&lt;a href=&quot;#Heterogeneous-Deep-Graph-Infomax&quot; class=&quot;headerlink&quot; title=&quot;Heterogeneous Deep Graph Inf
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
      <category term="图表示学习" scheme="https://www.rman.top/tags/%E5%9B%BE%E8%A1%A8%E7%A4%BA%E5%AD%A6%E4%B9%A0/"/>
    
  </entry>
  
  <entry>
    <title>Redundancy-Free Computation for Graph Neural Networks</title>
    <link href="https://www.rman.top/2020/08/22/Redundancy-Free-Computation-for-Graph-Neural-Networks/"/>
    <id>https://www.rman.top/2020/08/22/Redundancy-Free-Computation-for-Graph-Neural-Networks/</id>
    <published>2020-08-22T12:20:26.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Redundancy-Free-Computation-for-Graph-Neural-Networks"><a href="#Redundancy-Free-Computation-for-Graph-Neural-Networks" class="headerlink" title="Redundancy-Free Computation for Graph Neural Networks"></a>Redundancy-Free Computation for Graph Neural Networks</h1><h2 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h2><ul><li><p>To avoid redundant computations：减少冗余计算</p></li><li><p>HAGs are functionally equivalent to standard GNN-graphs：性能不变</p></li><li><p>An agnostic method：对所有模型都适用</p><p><img src="http://image.rman.top/blogimage-20200821163547510.png" alt="image-20200821163547510"></p></li></ul><p>对邻居上重合的的vector进行聚合，然后再传递。</p><h2 id="HAGs"><a href="#HAGs" class="headerlink" title="HAGs"></a>HAGs</h2><p>把聚合的点和原来的点聚合，生成一张新图</p><p><img src="http://image.rman.top/blogimage-20200821163906650.png" alt="image-20200821163906650"></p><h2 id="Existing-GNNs"><a href="#Existing-GNNs" class="headerlink" title="Existing GNNs"></a>Existing GNNs</h2><ul><li>没有顺序：GCN</li><li>有顺序：LSTM聚合</li></ul><h2 id="Aggregation-Nodes"><a href="#Aggregation-Nodes" class="headerlink" title="Aggregation Nodes"></a>Aggregation Nodes</h2><p><img src="http://image.rman.top/blogimage-20200821164422651.png" alt="image-20200821164422651"></p><ul><li><p>如果是原图的属性，就用节点的隐藏向量</p></li><li><p>如果是聚合节点，就用聚合向量。</p></li></ul><p><img src="http://image.rman.top/blogimage-20200821164632482.png" alt="image-20200821164632482"></p><h2 id="Cost-Function"><a href="#Cost-Function" class="headerlink" title="Cost Function"></a>Cost Function</h2><p><img src="http://image.rman.top/blogimage-20200821165644760.png" alt="image-20200821165644760"></p><h2 id="Algorithm"><a href="#Algorithm" class="headerlink" title="Algorithm"></a>Algorithm</h2><p><img src="http://image.rman.top/blogimage-20200821165855440.png" alt="image-20200821165855440"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Redundancy-Free-Computation-for-Graph-Neural-Networks&quot;&gt;&lt;a href=&quot;#Redundancy-Free-Computation-for-Graph-Neural-Networks&quot; class=&quot;heade
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="图数据库" scheme="https://www.rman.top/tags/%E5%9B%BE%E6%95%B0%E6%8D%AE%E5%BA%93/"/>
    
  </entry>
  
  <entry>
    <title>MultiSage: Empowering GCN with Contextualized Multi-Embeddings onWeb-Scale Multipartite Networks</title>
    <link href="https://www.rman.top/2020/08/14/MultiSage/"/>
    <id>https://www.rman.top/2020/08/14/MultiSage/</id>
    <published>2020-08-14T07:20:10.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="MultiSage-Empowering-GCN-with-Contextualized-Multi-Embeddings-onWeb-Scale-Multipartite-Networks"><a href="#MultiSage-Empowering-GCN-with-Contextualized-Multi-Embeddings-onWeb-Scale-Multipartite-Networks" class="headerlink" title="MultiSage: Empowering GCN with Contextualized Multi-Embeddings onWeb-Scale Multipartite Networks"></a>MultiSage: Empowering GCN with Contextualized Multi-Embeddings onWeb-Scale Multipartite Networks</h1><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>Existing GCNs mostly work on homogeneous graphs and consider a single embedding for each node, which do not sufficiently model the multi-facet nature and complex interaction of nodes in real world<br>networks.  Here, author present a contextualized GCN engine by modeling the multipartite networks of target nodes and their intermediate context nodes that specify the contexts of their interactions.</p><h2 id="Current-Issues-and-problems"><a href="#Current-Issues-and-problems" class="headerlink" title="Current Issues and  problems"></a>Current Issues and  problems</h2><ul><li>Nodes are connected in different ways thus close to each other in different ways, which cannot be simultaneously captured by a single embedding.</li><li><strong>How to find proper context?</strong>：The  real-world networks are often multipartite, it beneficial to model target nodes and context nodes in multipartite networks, where the interactions between the target nodes can be subtly modeled via the help of context nodes.</li><li><strong>How to leverage context?</strong>：How to leverage context in massive real-world networks to facilitate<br>effective and flexible downstream applications.</li></ul><p><img src="http://image.rman.top/blogimage-20200813111808135.png" alt="image-20200813111808135"></p><h2 id="Preliminaries"><a href="#Preliminaries" class="headerlink" title="Preliminaries"></a>Preliminaries</h2><p>Traditional GCN: The output of the $l+1$ th convolutional layer $\textbf{H}^{l+1}$ of GCN is computed as follows</p><p><img src="http://image.rman.top/blogimage-20200813112017937.png" alt="image-20200813112017937"></p><p>GraphSage: Sample a fixed number of neighbors in each convolution layer and aggregate the neighborhood embedding.</p><p><img src="http://image.rman.top/blogimage-20200813113024588.png" alt="image-20200813113024588"></p><p>Triplet-wise optimization objective based on max-margin ranking as follows</p><p><img src="http://image.rman.top/blogimage-20200813113054830.png" alt="image-20200813113054830"></p><p>where $\delta$ is a margin parameter, $v_q$ and $v_p$ are the query and positive nodes, $v_n$ is the negative node sampled from $P_n(v_q)$</p><p>$\mathcal{T}$：The number of the nodes type in graph</p><p>$\mathcal{C}$：Context nodes set</p><p>Each $u\in\mathcal{N}_v\subset\mathcal{T}$ of the ego $v\in \mathcal{T}$ is associated with a dominant context node $o \sim(v,u)\in \mathcal{C}$</p><h2 id="MultiSage"><a href="#MultiSage" class="headerlink" title="MultiSage"></a>MultiSage</h2><p>In this work, Author leverage the heterogeneity of real-world networks by separating nodes into two main types: target nodes and context nodes. Our main focus is to learn embeddings of the target nodes, while using the context nodes to describe the relationship between the target nodes.</p><p><img src="http://image.rman.top/blogimage-20200813113704204.png" alt="image-20200813113704204"></p><p><strong>Assumptions:</strong></p><ol><li>minimum domain knowledge is available to separate target nodes from context nodes</li><li>most important interactions among target nodes involve context nodes</li></ol><p><img src="http://image.rman.top/blogimage-20200813114154211.png" alt="image-20200813114154211"></p><p><img src="http://image.rman.top/blogimage-20200813114357968.png" alt="image-20200813114357968"></p><p>In (a), when three neighbor pins are aggregated through mean pooling, the resulting neighborhood embedding simply lies in the center of the three pins, reflecting the same influence of all neighbors on the ego. In contrast in (b), two neighbor pins are connected via the fashion board while the other one via the crafts board, thus drawing the neighborhood embedding more into the fashion direction. Such contextualization over the target interaction is desirable, since each neighbor is similar to the ego from a particular perspective, and thus should influence the ego embedding more in the corresponding subspace.</p><p><img src="http://image.rman.top/blogimage-20200813124137599.png" alt="image-20200813124137599"></p><h3 id="Raw-feature-transformation"><a href="#Raw-feature-transformation" class="headerlink" title="Raw feature transformation"></a>Raw feature transformation</h3><p>learns to project and transform raw node features via stacked dense neural networks as follows</p><p><img src="http://image.rman.top/blogimage-20200813115937275.png" alt="image-20200813115937275"></p><p>$z_t$ and $z_c$ represent the embeddings of the target and the context nodes, respectively.</p><h3 id="Contextual-masking"><a href="#Contextual-masking" class="headerlink" title="Contextual masking"></a>Contextual masking</h3><p>Contextual masking allows us to project different ego-neighbor pairs into various embedding subspaces,<br>so as to emphasize contextualized interaction among target node pairs regarding particular embedding dimensions at the <strong>feature level</strong>.</p><p>Element-wise multiplying the embedding of the context node $z_c (o)$ onto the embeddings of both ego and neighbor target nodes $z_t (v)$ and $z_t (u)$ as follows</p><script type="math/tex; mode=display">z_{t|c}=z_t\otimes z_c</script><p>Note that, since the last embedding layer of $z_c$ is ReLU, certain dimensions can be learned to be zero, which effectively “masks out” irrelevant dimensions, so as to project the target embeddings into particular subspaces directly controlled by the context embeddings</p><p>Autho also introduce:</p><script type="math/tex; mode=display">z_{t|c}=z_t\oplus z_c</script><script type="math/tex; mode=display">z_{t|c}=ReLU(W_p(z_t \odot z_c)+b)</script><p>where $\odot$ means the concatenation.</p><h3 id="Contextual-attention"><a href="#Contextual-attention" class="headerlink" title="Contextual attention"></a>Contextual attention</h3><p>Author design a novel contextual attention mechanism to consider the overall impact of different neighbors of ego at the <strong>node level</strong>, by jointly computing an attention weight for each ego-context-neighbor triplet $\alpha (v,o,u)=$</p><p><img src="http://image.rman.top/blogimage-20200813122053635.png" alt="image-20200813122053635"></p><p>where ${a,W<em>{at},W</em>{ac}}$ are the learnable attention parameters. $\tau$ is the LeakyReLU activation function.</p><p>To further improve the capacity and stability, we exploit multi-head attention to compute the aggregated contextualized embedding as follows:</p><p><img src="http://image.rman.top/blogimage-20200813123426905.png" alt="image-20200813123426905"></p><h3 id="Training-objective"><a href="#Training-objective" class="headerlink" title="Training objective"></a>Training objective</h3><p>Author directly add the contextualized ego embedding $z<em>{N_v} (v)$ and neighbor embedding $z</em>{N_v} (u) $as<br>the final MultiSage embedding $h(v)$. </p><p><strong>Training loss:</strong> </p><p>sampling positive neighbor and negative neighbor $v_p,v_n$</p><p><img src="http://image.rman.top/blogimage-20200813113054830.png" alt="image-20200813113054830"></p><p><img src="http://image.rman.top/blogimage-20200813130113062.png" alt="image-20200813130113062"></p><p>这个加法是合理的，如果u，v是邻居，则$h_u$=$h_v$,那么乘积就会很大，如果不是邻居，则$h_u$ 不等于$h_v$乘积会小，则loss是会变大的。</p><h3 id="Contextualized-random-walk"><a href="#Contextualized-random-walk" class="headerlink" title="Contextualized random walk"></a>Contextualized random walk</h3><p>由于每个游走序列会有多个中间节点，但是其实只是有一些中间节点是不重要的，于是对每个ego-target node pair只保留最重要的中间节点。</p><p><img src="http://image.rman.top/blogimage-20200813151229871.png" alt="image-20200813151229871" style="zoom:67%;" /></p><p>vis[v]：记录节点访问次数</p><p>ctx[v]：记录中间节点和target节点</p><p>dom[v]：记录不同中间节点的重要性</p><p>line 7: 对所有的访问过的context node 记录增加</p><p>line8-15：运行多次random walk，记录出现target node情况下，出现最多的contex node。</p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><p><img src="http://image.rman.top/blogimage-20200813154448878.png" alt="image-20200813154448878"></p><p><img src="http://image.rman.top/blogimage-20200813154608159.png" alt="image-20200813154608159"></p><p><img src="http://image.rman.top/blogimage-20200813155337550.png" alt="image-20200813155337550"></p><p>可以使用mask去获取不同的候选商品，因为mask会剔除一些不同的特征，可以让目标映射到不同的子</p><p><img src="http://image.rman.top/blogimage-20200813160743067.png" alt="image-20200813160743067"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;MultiSage-Empowering-GCN-with-Contextualized-Multi-Embeddings-onWeb-Scale-Multipartite-Networks&quot;&gt;&lt;a href=&quot;#MultiSage-Empowering-GCN-
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
  </entry>
  
  <entry>
    <title>Meet u at the afternoon</title>
    <link href="https://www.rman.top/2020/08/10/Meet-u-at-the-afternoon/"/>
    <id>https://www.rman.top/2020/08/10/Meet-u-at-the-afternoon/</id>
    <published>2020-08-10T05:38:35.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="http://image.rman.top/blog微信图片_20200810133306.jpg" alt="微信图片_20200810133306"><br><img src="http://image.rman.top/blog微信图片_20200810133149.jpg" alt="微信图片_20200810133149"></p><p><img src="http://image.rman.top/blog微信图片_202008101333075.jpg" alt="微信图片_202008101333075"></p><p><img src="http://image.rman.top/blog微信图片_202008101333061.jpg" alt="微信图片_202008101333061"></p><p><img src="http://image.rman.top/blog微信图片_202008101333071.jpg" alt="微信图片_202008101333071"></p><p><img src="http://image.rman.top/blog微信图片_20200810133307.jpg" alt="微信图片_20200810133307"></p><p><img src="http://image.rman.top/blog微信图片_202008101333072.jpg" alt="微信图片_202008101333072"></p><p><img src="http://image.rman.top/blog微信图片_202008101333073.jpg" alt="微信图片_202008101333073"></p><p><img src="http://image.rman.top/blog微信图片_202008101333074.jpg" alt="微信图片_202008101333074"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_20200810133306.jpg&quot; alt=&quot;微信图片_20200810133306&quot;&gt;&lt;br&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_20200
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>Meet u at the sunset~</title>
    <link href="https://www.rman.top/2020/08/09/Meet-u-at-the-sunset/"/>
    <id>https://www.rman.top/2020/08/09/Meet-u-at-the-sunset/</id>
    <published>2020-08-09T15:46:04.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="http://image.rman.top/blog微信图片_202008092339291.jpg" alt="微信图片_202008092339291"><br><img src="http://image.rman.top/blog微信图片_202008092339292.jpg" alt="微信图片_202008092339292"><br><img src="http://image.rman.top/blog微信图片_202008092339294.jpg" alt="微信图片_202008092339294"><br><img src="http://image.rman.top/blog微信图片_202008092339293.jpg" alt="微信图片_202008092339293"><br><img src="http://image.rman.top/blog微信图片_202008092339296.jpg" alt="微信图片_202008092339296"><br><img src="http://image.rman.top/blog微信图片_202008092339297.jpg" alt="微信图片_202008092339297"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_202008092339291.jpg&quot; alt=&quot;微信图片_202008092339291&quot;&gt;&lt;br&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_202
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>First time watch a film</title>
    <link href="https://www.rman.top/2020/07/30/First-time-watch-a-film/"/>
    <id>https://www.rman.top/2020/07/30/First-time-watch-a-film/</id>
    <published>2020-07-30T09:38:21.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="http://image.rman.top/blog微信图片_20200730173326.jpg" alt="微信图片_20200730173326"><br><img src="http://image.rman.top/blog微信图片_20200730173350.jpg" alt="微信图片_20200730173350"><br><img src="http://image.rman.top/blog微信图片_20200730173346.jpg" alt="微信图片_20200730173346"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_20200730173326.jpg&quot; alt=&quot;微信图片_20200730173326&quot;&gt;&lt;br&gt;&lt;img src=&quot;http://image.rman.top/blog微信图片_20200
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>An Efficient Neighborhood-based Interaction Model for Recommendation on Heterogeneous Graph</title>
    <link href="https://www.rman.top/2020/07/23/HINRec/"/>
    <id>https://www.rman.top/2020/07/23/HINRec/</id>
    <published>2020-07-23T06:33:16.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><h3 id="Problem"><a href="#Problem" class="headerlink" title="Problem"></a>Problem</h3><ol><li><p>Most existing HIN-based methods rely on explicit path reachability to leverage path-based semantic relatedness between users and items, e.g., metapath-based similarities. These methods are hard to use and integrate since path connections are sparse or noisy, and are often of different lengths.</p><p>现有的方法，依赖于物品和用户之间的语义构成的路径，比如metapath的相似度。这些方法在遇到路径很稀少、充满噪音或长度不一致时会导致表示能力的下降。</p></li><li><p>Other graph-based methods aim to learn effective heterogeneous network representations by compressing node together with its neighborhood information into single embedding before prediction. This weakly coupled manner in modeling overlooks the rich interactions<br>among nodes, which introduces an early summarization issue.</p><p>对于图卷积的方法来说，他们只学习了临近邻居的信息，并把他们聚合到一个向量中进行表示，这样很可能导致忽视了一些节点之间复杂的联系。</p></li></ol><p>In this paper, author propose an end-to-end Neighborhood-based Interaction Model for Recommendation to address above problems. </p><ul><li><p>Author first analyze the significance of learning interactions in HINs and then propose a novel formulation to capture the interactive patterns between each pair of nodes through their metapath-guided neighborhoods.</p></li><li><p>Then, to explore complex interactions between metapaths and deal with the learning complexity on large-scale networks, we formulate interaction in a convolutional way and learn efficiently with fast Fourier transform.</p></li></ul><h3 id="Challenge"><a href="#Challenge" class="headerlink" title="Challenge"></a>Challenge</h3><ol><li>How to tackle the early summarization issue? Due to the  complex structure of the HIN, the interactive local structures are hidden and not fully utilized in previous methods.</li><li>How to design an end-to-end framework to capture and aggregate the interactive patterns between neighborhoods? There are usually various nodes in different types involved in one path. Different paths/nodes may contribute differently to the final performance.</li><li>How to learn the whole system efficiently? Learning interactive information on HINs is always time-consuming; especially when faced with paths in different types and lengths for metapath-based approaches and large-scale high-order information for graph-based approaches.</li></ol><h2 id="Preliminary"><a href="#Preliminary" class="headerlink" title="Preliminary"></a>Preliminary</h2><p><strong>Recommendation:</strong></p><p><img src="http://image.rman.top/blogimage-20200722162838160.png" alt="image-20200722162838160" style="zoom:50%;" /></p><p><strong>HIN Graph</strong>：$\mathcal{G}=(\mathcal{V},\mathcal{E})$, which consists of more than one node type or link type.</p><p><img src="http://image.rman.top/blogimage-20200722163247534.png" alt="image-20200722163247534" style="zoom: 67%;" /></p><p><strong>Metapath-guided Neighborhood</strong>：Given an object $o$ and a metapath $ρ$ (start from $o$) in an HIN, the metapath guided neighborhood is defined as the set of all visited objects when the object $o$ walks along the given metapath $ρ$. </p><p>$\mathcal{N}_p^i(o)$ is the neighbors of object $o$ after $i$-th steps sampling.</p><p>$\mathcal{N}_p^0(o)=o$</p><p>$\mathcal{N}_p^{I-1}(o)=\mathcal{N}_p(o)$, $I$ is the length of metapath.</p><p>$H[\mathcal{N}<em>p(o)]_l=[e^p_0\oplus e^p_1\oplus\cdots\oplus e^p</em>{I-1}]$: The embedding matrix of metapath $\rho$</p><p><img src="http://image.rman.top/blogimage-20200722164053597.png" alt="image-20200722164053597"></p><h2 id="Method"><a href="#Method" class="headerlink" title="Method"></a>Method</h2><p><img src="http://image.rman.top/blogimage-20200722164149329.png" alt="image-20200722164149329"></p><p>INPUT: <user, item, attribute, relation></p><ol><li>Select the metapath-guided neighbors for source and target via neighbor samplings.</li><li>Use interactive convolutional operation to generate potential interaction information among the neighbors</li><li>Aggregate information via attentnion mechanism in both node and path level.</li></ol><p>OUTPUT: Final prediction</p><h3 id="Neighborhood-Sampling"><a href="#Neighborhood-Sampling" class="headerlink" title="Neighborhood Sampling"></a>Neighborhood Sampling</h3><p><img src="http://image.rman.top/blogimage-20200722165605610.png" alt="image-20200722165605610" style="zoom:50%;" /></p><h3 id="Interaction-Module"><a href="#Interaction-Module" class="headerlink" title="Interaction Module"></a>Interaction Module</h3><p>Due to the heterogeneity of nodes, different types of nodes have different feature spaces. Hence, for each type of nodes with type $\phi<em>i$. Author design the type-specific transformation matrix $M</em>{\phi_i}$ to project the features of different types of nodes into a unified feature space.</p><script type="math/tex; mode=display">e'_i=M_{\phi_i}\cdot e_i</script><p>where $e_i$ and $e’_i$ are the original and projected features of node $i$.</p><p>Considering that neighbors in different distances to the source/target node usually contribute differently to the final prediction, author divide the sampled metapath-guided neighborhood into several innerdistance and outer-distance neighbor groups.</p><p><img src="http://image.rman.top/blogimage-20200722171234443.png" alt="image-20200722171234443"></p><p>In order to compute the interactions in each neighbor group, author adopt the convolution method:</p><p>e.g. calculate the interaction between $u_A,m_B,d_B,m_D$ and $m_B,d_C,m_C,u_C$</p><ol><li>Inverse the order of target movie neighborhood: $u_C,m_C,d_C,m_B$</li><li>Shift the sequence and obtain the co-ratings between different types of nodes like $r(u_A,m_B)$  or $r(u_A,u_C)+r(m_B,m_C),+r(d_B,d_C)+r(m_D,m_B)$by product operation.</li></ol><p><img src="http://image.rman.top/blogimage-20200722171502037.png" alt="image-20200722171502037"></p><p>Therefore, the above procedure can be written in convolution form:</p><script type="math/tex; mode=display">H[\mathcal{N}_{\rho}(s),\mathcal{N}_{\rho}(t)]_l=H[\mathcal{N}_{\rho}(s)]_l\odot H[\mathcal{N}_{\rho}(t)]_l</script><p><img src="../../../../../../Desktop/An Efficient Neighborhood-based Interaction Model for Recommendation on Heterogeneous Graph.assets/image-20200722173900365.png" alt="image-20200722173900365" style="zoom:50%;" /></p><p>By using the fast Fourier transformation (FFT) and $\mathcal{F}^{-1}$</p><p><img src="http://image.rman.top/blogimage-20200722173955344.png" alt="image-20200722173955344"></p><h3 id="Aggregation-Module"><a href="#Aggregation-Module" class="headerlink" title="Aggregation Module"></a>Aggregation Module</h3><h4 id="Node-Element-level-Attention"><a href="#Node-Element-level-Attention" class="headerlink" title="Node/Element-level Attention"></a>Node/Element-level Attention</h4><p><img src="http://image.rman.top/blogimage-20200723105412155.png" alt="image-20200723105412155"></p><p>After the interaction module, the author adopt the self-attention to learn the weight among various  kinds of nodes in metapath $\rho$</p><p><img src="http://image.rman.top/blogimage-20200723105430848.png" alt="image-20200723105430848"></p><p>where $h^{\rho}<em>i,h^{\rho}_j$ are elements of interaction matrix $ H[\mathcal{N}</em>{\rho}] $ and $W_T,W_S$ are trainable weights. </p><p>The attention value is calculated as bellow</p><p><img src="http://image.rman.top/blogimage-20200723110447673.png" alt="image-20200723110447673"></p><p>The final result is calculated as：</p><p><img src="http://image.rman.top/blogimage-20200723110519985.png" alt="image-20200723110519985"></p><p>Given a set of metapath $\rho<em>0,\rho_1,\cdots,\rho</em>{P-1}$, we get $Z[\mathcal{N<em>{\rho_0)}}],Z[\mathcal{N</em>{\rho<em>1)}},\cdots,Z[\mathcal{N</em>{\rho_{p-1})}}]$</p><h4 id="Path-Matrix-level-Attention"><a href="#Path-Matrix-level-Attention" class="headerlink" title="Path/Matrix-level Attention."></a>Path/Matrix-level Attention.</h4><p>For each metapath aggregate the information with soft attention.</p><p><img src="http://image.rman.top/blogimage-20200723111402328.png" alt="image-20200723111402328"></p><h3 id="Objective-function"><a href="#Objective-function" class="headerlink" title="Objective function"></a>Objective function</h3><p><img src="http://image.rman.top/blogimage-20200723112003117.png" alt="image-20200723112003117"></p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><h3 id="Five-questions"><a href="#Five-questions" class="headerlink" title="Five questions"></a>Five questions</h3><p><img src="http://image.rman.top/blogimage-20200723112136779.png" alt="image-20200723112136779"></p><h3 id="Datasets"><a href="#Datasets" class="headerlink" title="Datasets"></a>Datasets</h3><p>Movielens: <a href="https://grouplens.org/datasets/movielens/">https://grouplens.org/datasets/movielens/</a></p><p>LastFM: <a href="https://grouplens.org/datasets/hetrec-2011/">https://grouplens.org/datasets/hetrec-2011/</a></p><h3 id="Result"><a href="#Result" class="headerlink" title="Result"></a>Result</h3><p><img src="http://image.rman.top/blogimage-20200723112306556.png" alt="image-20200723112306556"></p><p>HIRecCNN：Use CNN instead of the interaction module to fuse information around the neighbors.</p><p>HIRecGCN：Use GCN instead of the aggregation module to aggregate information from the graph.</p><h3 id="Interpretable"><a href="#Interpretable" class="headerlink" title="Interpretable"></a>Interpretable</h3><ol><li>显示metapath的重要性</li><li>显示metapath内部的节点之间的关联关系</li></ol><p><img src="http://image.rman.top/blogimage-20200723140221153.png" alt="image-20200723140221153"></p><p>说明增加metapath的对性能的影响</p><p><img src="http://image.rman.top/blogimage-20200723142050535.png" alt="image-20200723142050535"></p><p>说明邻居长度对性能的影响。</p><p><img src="http://image.rman.top/blogimage-20200723142115438.png" alt="image-20200723142115438"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Abstract&quot;&gt;&lt;a href=&quot;#Abstract&quot; class=&quot;headerlink&quot; title=&quot;Abstract&quot;&gt;&lt;/a&gt;Abstract&lt;/h2&gt;&lt;h3 id=&quot;Problem&quot;&gt;&lt;a href=&quot;#Problem&quot; class=&quot;header
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="Metapath" scheme="https://www.rman.top/tags/Metapath/"/>
    
      <category term="推荐算法" scheme="https://www.rman.top/tags/%E6%8E%A8%E8%8D%90%E7%AE%97%E6%B3%95/"/>
    
  </entry>
  
  <entry>
    <title>AM-GCN: Adaptive Multi-channel Graph Convolutional Networks</title>
    <link href="https://www.rman.top/2020/07/21/AM-GCN/"/>
    <id>https://www.rman.top/2020/07/21/AM-GCN/</id>
    <published>2020-07-21T07:56:00.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Motivation"><a href="#Motivation" class="headerlink" title="Motivation"></a>Motivation</h2><p>现有的STOA的GCN算法不能很好的将节点特征融合进拓扑结构当中。GCN在一些节点分类的任务中不能很好的融合深层的拓扑结构和节点特征。作者希望提出一种新的GCN结构，在能保持现有的GCN优点的情况下，同样能很好的融合拓扑结构和节点的特征。</p><h2 id="Model"><a href="#Model" class="headerlink" title="Model"></a>Model</h2><p><img src="http://image.rman.top/blogimage-20200717163846413.png" alt="image-20200717163846413" style="zoom:67%;" /></p><p>把图拆成两部分，生成Topology Graph和Feature Graph。</p><p>Feature Graph是根据节点的特征采用KNN构成的新的图。</p><p>然后分为三个部分，上下两个部分用独立的参数训练，中间用共享参数训练</p><p><img src="http://image.rman.top/blogimage-20200721153641366.png" alt="image-20200721153641366"></p><p><img src="http://image.rman.top/blogblogimage-20200721153650181.png" alt="image-20200721153650181"></p><p>然后$Z<em>{CT},Z</em>{CF}$做个两个平均值生成$Z_C$</p><p><img src="http://image.rman.top/blogblogimage-20200721153722946.png" alt="image-20200721153722946"></p><p>然后对$Z_T,Z_C,Z_F$做个一个attention生成最后的表示$Z$</p><p><img src="http://image.rman.top/blogblogimage-20200721153751424.png" alt="image-20200721153751424"></p><h2 id="Objective-function"><a href="#Objective-function" class="headerlink" title="Objective function"></a>Objective function</h2><p>$\mathcal{L}_c$相似约束</p><p>同时对Common Convolution 的两个输出，分别生成节点内部的相似度矩阵，然后希望两个Graph的相似度矩阵足够接近。</p><p><img src="http://image.rman.top/blogimage-20200717165002572.png" alt="image-20200717165002572" style="zoom:67%;" /></p><p>$\mathcal{L}_d$差异约束</p><p>虽然对于两个模型的$S$是相似的，但是对于两个模型的输出向量$Z$是不相似的，不然就没有学习的必要了。</p><p><img src="http://image.rman.top/blogblogimage-20200717165838333.png" alt="image-20200717165838333"></p><p>$\mathcal{L}_t$分类loss</p><p><img src="http://image.rman.top/blogblogimage-20200717170107002.png" alt="image-20200717170107002"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Motivation&quot;&gt;&lt;a href=&quot;#Motivation&quot; class=&quot;headerlink&quot; title=&quot;Motivation&quot;&gt;&lt;/a&gt;Motivation&lt;/h2&gt;&lt;p&gt;现有的STOA的GCN算法不能很好的将节点特征融合进拓扑结构当中。GCN在一
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
  </entry>
  
  <entry>
    <title>Hey~Girl!</title>
    <link href="https://www.rman.top/2020/07/15/Hey-Girl/"/>
    <id>https://www.rman.top/2020/07/15/Hey-Girl/</id>
    <published>2020-07-15T17:14:53.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p><img src="http://image.rman.top/blogimage-20200716010439659.png" alt="image-20200716010439659"><br><img src="http://image.rman.top/blogimage-20200716010451408.png" alt="image-20200716010451408"><br><img src="http://image.rman.top/blogimage-20200716010458558.png" alt="image-20200716010458558"><br><img src="http://image.rman.top/blogimage-20200716010552521.png" alt="image-20200716010552521"><br><img src="http://image.rman.top/blogimage-20200716010607035.png" alt="image-20200716010607035"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;http://image.rman.top/blogimage-20200716010439659.png&quot; alt=&quot;image-20200716010439659&quot;&gt;&lt;br&gt;&lt;img src=&quot;http://image.rman.top/blogim
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>MultiImport: Inferring Node Importance in a Knowledge Graph from Multiple Input Signals</title>
    <link href="https://www.rman.top/2020/07/13/multiimport/"/>
    <id>https://www.rman.top/2020/07/13/multiimport/</id>
    <published>2020-07-13T02:23:02.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<h2 id="简介："><a href="#简介：" class="headerlink" title="简介："></a>简介：</h2><p>对一个拥有多种节点重要性的图谱来说，如何去正确的估计他们每个节点重要性是一个很巨大的挑战。其中一个重要的问题就是如何从多种的不同的输入中有效的提取信息。针对这个问题，作者提出了一种隐向量模型，他可以从不同的信号中捕获节点的重要性。</p><p><img src="https://i.loli.net/2020/07/13/NsITkGRnEt86lLu.png" alt="image-20200713103300082"></p><p>以上图为例，针对一个电影的知识图谱来说，存在不同的种类的的节点，同时每个节点的信息可能拥有不同的属性。以不同的属性作为评价指标，其每个节点的重要性也是不一样的，并且不是每个节点都有全部的属性。这就导致了两个问题：</p><ol><li>节点的重要性以不同的属性作为评价，所得到的结果是不一样的。</li><li>可能会存在空属性的情况，导致节点在那个属性下无法评价重要性。</li></ol><p>作者希望对所有节点学习到一个通用的属性重要性$z$，这样作者就可以对图中所有的节点进行一个统一的重要性表达。</p><h2 id="符号定义"><a href="#符号定义" class="headerlink" title="符号定义"></a>符号定义</h2><h3 id="Node-Feature"><a href="#Node-Feature" class="headerlink" title="Node Feature"></a>Node Feature</h3><p>$X\in \mathbb{R}^{|V|\times F}$</p><h3 id="Node-Importance"><a href="#Node-Importance" class="headerlink" title="Node Importance"></a>Node Importance</h3><p>$z\in \mathbb{R}_{\geq 0}$，是一个非负的实数，代表图中每个节点的重要性。</p><h3 id="Input-Signal"><a href="#Input-Signal" class="headerlink" title="Input Signal"></a>Input Signal</h3><p>$V’ \to \mathbb{R}_{\geq 0}(V’ \subseteq V)$，同样也是一个重要性，但是一个部分的映射，把一些具有相同属性节点映射到一个重要性空间。对一个数据源，可能有多种不同的signals，比如一本书可以有销售的数量，销售的金额，投票的数量等，所以对一本书的受欢迎的评价可能来自多个不同的方面。同样一些signal只对一些种类的节点有效，所以是一个部分映射。</p><p>在本文中，作者设定了$M$个不同的输入signals，${S<em>i: V’_i\to \mathbb{R}</em>{\geq 0}|V’_i \subseteq V,i=1,\dots, M}$</p><p>输入的signals有如下的性质：</p><ul><li>输入的信号有不同的尺度，可能一个值域是在0-1之间，另一个是在0-100之间。</li><li>输入的信号都是值越大节点越重要。</li></ul><h2 id="Object-Function"><a href="#Object-Function" class="headerlink" title="Object Function"></a>Object Function</h2><p><strong>我认为本文的目标方程的构建过程是本文最大的贡献点，理论推导严密，合理合规。</strong></p><p>给定一个图和一个初始化的参数，目标是学习到一个表达：</p><script type="math/tex; mode=display">z=f(\mathcal{G},\theta)</script><p>为了优化方程$f$，其实就是最大化后验概率</p><script type="math/tex; mode=display">max\ p(\theta|\mathcal{G},S)</script><p>根据贝叶斯理论就是，后验概率等于</p><script type="math/tex; mode=display">p(\theta|\mathcal{G},S)=\frac{p(\mathcal{G},S|\theta)p(\theta)}{p(\mathcal{G},S)}\varpropto p(\theta)p(\mathcal{G}|\theta)p(S|\mathcal{G},\theta)</script><p>证明如下：</p><script type="math/tex; mode=display">1.\ p(\mathcal{G},S)是常数，可以直接省略\\2.\ p(s|G,\theta)=\frac{p(G,S,\theta)}{p(G,\theta)}=\frac{p(G,S|\theta)p(\theta)}{p(G,\theta)}\\3. 又 p(G,\theta)=p(G|\theta)p(\theta)\\4. 所以 p(G,S|\theta)=p(S|G,\theta)p(G|\theta)\\ 5. p(\theta|\mathcal{G},S)\varpropto p(\theta)p(\mathcal{G}|\theta)p(S|\mathcal{G},\theta)</script><p>$p(\theta)$,是先验参数分布，作者用了中值为0的高斯分布，</p><script type="math/tex; mode=display">p(\theta)=\mathcal{N}(\theta|0,\lambda^{-1}I)</script><p>$p(\mathcal{G}|\theta)$是用来给定参数$\theta$来表达图的概率。给定一个节点，将其用函数$g(\cdot)$嵌入到低纬空间，然后用KG的triplet来表达图。公式如下：</p><p><img src="https://i.loli.net/2020/07/13/dAPyreUT3OKWo6u.png" alt="image-20200713141909010"></p><p>这个公式得到的是每个triplet出现的概率。</p><p>$p(S|\mathcal{G},\theta)$是给定一个图和参数，每一个信号出现的概率，其假设学习出的参数，能拟合节点在所有signal里的重要性概率，用极大似然概率，得到如下公式：</p><p><img src="https://i.loli.net/2020/07/13/UyvqLZzskQ3iAaC.png" alt="image-20200713142410531"></p><p>其中$p(s^{(i)}_j)$是，节点在第$i$种signal里的重要性概率，其公式如下:</p><p><img src="https://i.loli.net/2020/07/13/cMsdqyV9X1ZWwoY.png" alt="image-20200713142550289"></p><p>$p(z_j^{(i)})$则是我们学习到的重要性，其表示如下：</p><p><img src="https://i.loli.net/2020/07/13/RVm1gliLyTDjIvx.png" alt="image-20200713142636612"></p><p>则我们最后得到的目标方程如下：</p><p><img src="https://i.loli.net/2020/07/13/AoG9msKcb5nqzy7.png" alt="image-20200713142707096"></p><h2 id="模型和训练过程"><a href="#模型和训练过程" class="headerlink" title="模型和训练过程"></a>模型和训练过程</h2><p>节点一开始用函数$g(x)$进行节点嵌入，然后通过$g’(g(x))$（全连接）转换到一维，然后另$h^0=g’(g(x))$</p><p>模型在message passing采用的是注意力的加权求和，类似GAT</p><p><img src="https://i.loli.net/2020/07/13/lo3WuTt1erQqR8A.png" alt="image-20200713142946738"></p><p><img src="https://i.loli.net/2020/07/13/n3BQaKfVRMjToxd.png" alt="image-20200713143021813"></p><p>最后对每个节点的表达作者是使用GENI的的中心平均化</p><p>最后得到每个重要性的表达向量$z$，注意$z_i$也只是一个值，因为一开始进行了转换。：</p><p><img src="https://i.loli.net/2020/07/13/KaIHTUoRMhCXqS9.png" alt="image-20200713143538123"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;简介：&quot;&gt;&lt;a href=&quot;#简介：&quot; class=&quot;headerlink&quot; title=&quot;简介：&quot;&gt;&lt;/a&gt;简介：&lt;/h2&gt;&lt;p&gt;对一个拥有多种节点重要性的图谱来说，如何去正确的估计他们每个节点重要性是一个很巨大的挑战。其中一个重要的问题就是如何从多种的不同的输
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="Graph Embedding" scheme="https://www.rman.top/tags/Graph-Embedding/"/>
    
  </entry>
  
  <entry>
    <title>MixHop:Higher-Order Graph Convolutional Architectures via Sparsified Neighborhood Mixing</title>
    <link href="https://www.rman.top/2020/07/12/MixHop/"/>
    <id>https://www.rman.top/2020/07/12/MixHop/</id>
    <published>2020-07-12T14:46:42.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="简述"><a href="#简述" class="headerlink" title="简述"></a>简述</h2><p>现有的基于半监督的图神经网络算法，不能很好的学习到不同跳的邻居特征。本文提出了一种可以重复的表达不同距离的邻居用户特征的算法。</p><p>原始GCN不同层卷积都用相同的权重，不能捕获不同层的信息差异性，本文证明了对不同层采用不同的信息传递权重能捕获不同层之间的信息差异性。</p><p><img src="https://i.loli.net/2020/07/12/AjLE6a7vSWctzKo.png" alt="image-20200712155849920"></p><h2 id="贡献"><a href="#贡献" class="headerlink" title="贡献"></a>贡献</h2><ol><li>提出了Delta Operators，并证明了传统的GCN模型没有能学到这样的表达</li><li>提出了MixHop，通过利用多次邻接矩阵，作者证明MixHop能够学习到更广泛的邻居特征，同时也不会增加模型的内存。</li></ol><h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><ol><li>传统GNN一次只能卷积一次邻居</li><li>在降低邻接矩阵求特征值的复杂度之后丢失了一些信息</li></ol><h2 id="假设"><a href="#假设" class="headerlink" title="假设"></a>假设</h2><p><img src="https://i.loli.net/2020/07/12/JimeNKEWn1fryz6.png" alt="image-20200701164504476"></p><h2 id="模型"><a href="#模型" class="headerlink" title="模型"></a>模型</h2><p><img src="https://i.loli.net/2020/07/12/5Lxob2O7ZPyQqlc.png" alt="image-20200701164046322"></p><h3 id="Delta-Operation"><a href="#Delta-Operation" class="headerlink" title="Delta Operation"></a>Delta Operation</h3><p><img src="https://i.loli.net/2020/07/12/B2LTf38YxpEzw6O.png" alt="image-20200712163255272"></p><p>这是一个在不同距离的节点特征之间收集特征的操作。一个模型能够学习到两跳的信息的前提是其存在一组参数和一个injective mapping $f$，可以使得网络的输出可以给定任何邻接矩阵$A$和特征$X$。</p><h3 id="MixHop-Graph-Convolution-Layer"><a href="#MixHop-Graph-Convolution-Layer" class="headerlink" title="MixHop Graph Convolution Layer"></a>MixHop Graph Convolution Layer</h3><p><img src="https://i.loli.net/2020/07/12/qpWdNDobikMjAxE.png" alt="image-20200712174307445"></p><p>和传统GCN重复乘以A不同，本文在一次操作里乘多次A，一次性获得多跳的信息。并且和传统GCN的每层权重矩阵W相同不一样，这里每一跳都有各自的权重矩阵W。最后将其拼接起来。</p><h3 id="模型的表示能力"><a href="#模型的表示能力" class="headerlink" title="模型的表示能力"></a>模型的表示能力</h3><h4 id="证明1：传统GCN不能表达two-hop-Delta-Operators"><a href="#证明1：传统GCN不能表达two-hop-Delta-Operators" class="headerlink" title="证明1：传统GCN不能表达two-hop Delta Operators"></a>证明1：传统GCN不能表达two-hop Delta Operators</h4><p>通过构造$C<em>{1,2}$来证明$W^<em>$是任意两行都是相等的，从而证明$AW^</em>$的rank为1，又证明$AW^*=f$，从而$f$不可能是injective（单射）的，因为任意两行相等，所以对多个不同的两行的$C</em>{xy}$都产生相同的输出。</p><p><img src="https://i.loli.net/2020/07/12/QVyI78tN6wCzJnH.png" alt="image-20200712215522230" style="zoom:50%;" /></p><p><img src="../../../../../../Desktop/MixHop.assets/image-20200712215535565.png" alt="image-20200712215535565" style="zoom:50%;" /></p><h4 id="证明2：证明MixHop具有two-hop性质"><a href="#证明2：证明MixHop具有two-hop性质" class="headerlink" title="证明2：证明MixHop具有two-hop性质"></a>证明2：证明MixHop具有two-hop性质</h4><p>通过拼接操作，再加上合理构造的$W$，可以产生two-hop形式的函数。因此可以证明构造的方式是合理的，能捕获two-hop性质。</p><p><img src="https://i.loli.net/2020/07/12/Wvdc1zZUN3SyIm2.png" alt="image-20200712221022566" style="zoom:50%;" /></p><h3 id="模型参数"><a href="#模型参数" class="headerlink" title="模型参数"></a>模型参数</h3><p>作者针对不同层的$W$，认为不同层的信息重要程度是不一样的，于是作者先用统一的特征维度n进行预训练。然后再训练完之后通过L2正则化，和阈值筛选出新的维度大小，然后再重新训练。通过这个操作，作者认为能表现出不同hop特征的重要程度（这难道不是一个attention就能解决的吗？？）</p><p><img src="https://i.loli.net/2020/07/12/HjBlSMD1ARYKxiW.png" alt="image-20200712224115002" style="zoom:50%;" /></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;简述&quot;&gt;&lt;a href=&quot;#简述&quot; class=&quot;headerlink&quot; title=&quot;简述&quot;&gt;&lt;/a&gt;简述&lt;/h2&gt;&lt;p&gt;现有的基于半监督的图神经网络算法，不能很好的学习到不同跳的邻居特征。本文提出了一种可以重复的表达不同距离的邻居用户特征的算法。&lt;/p&gt;
&lt;p
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
  </entry>
  
  <entry>
    <title>生物信息学复习提纲</title>
    <link href="https://www.rman.top/2020/07/08/bioinfo/"/>
    <id>https://www.rman.top/2020/07/08/bioinfo/</id>
    <published>2020-07-08T11:59:27.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>本文是本人基于哈尔滨工业大学生物信息学整个课程的复习提纲</p><hr><h1 id="绪论"><a href="#绪论" class="headerlink" title="绪论"></a>绪论</h1><h2 id="组学："><a href="#组学：" class="headerlink" title="组学："></a>组学：</h2><p>生物学中对某些生物分子的整个集合进行的系统性研究</p><h3 id="组学基本法则："><a href="#组学基本法则：" class="headerlink" title="组学基本法则："></a>组学基本法则：</h3><p>获取大样本-高通量侧学-数据分析-结果注释：生物验证</p><h2 id="基因数据库："><a href="#基因数据库：" class="headerlink" title="基因数据库："></a>基因数据库：</h2><h3 id="SRA数据库："><a href="#SRA数据库：" class="headerlink" title="SRA数据库："></a>SRA数据库：</h3><p>手机全世界的基因组原始测序数据</p><h3 id="GenBank数据库："><a href="#GenBank数据库：" class="headerlink" title="GenBank数据库："></a>GenBank数据库：</h3><p>1983年起，收集全世界公开发表的DNA序列</p><h3 id="GEO数据库："><a href="#GEO数据库：" class="headerlink" title="GEO数据库："></a>GEO数据库：</h3><p>收集基因表达谱数据，收集超过9.1w数据集</p><h2 id="生物信息学："><a href="#生物信息学：" class="headerlink" title="生物信息学："></a>生物信息学：</h2><p>是研究生物数据管理、存储、检索、分析、挖掘、可视化的算法与系统，实现对生物数据的理解和利用的一个多学科交叉领域。</p><h1 id="生物数据和数据库"><a href="#生物数据和数据库" class="headerlink" title="生物数据和数据库"></a>生物数据和数据库</h1><h2 id="DNA："><a href="#DNA：" class="headerlink" title="DNA："></a>DNA：</h2><ul><li>一串由ACGT组成的字符串</li><li>双链结构</li></ul><h2 id="RNA："><a href="#RNA：" class="headerlink" title="RNA："></a>RNA：</h2><ul><li>一串由ACGU组成的字符串</li></ul><h2 id="蛋白质："><a href="#蛋白质：" class="headerlink" title="蛋白质："></a>蛋白质：</h2><p>…</p><h2 id="生命："><a href="#生命：" class="headerlink" title="生命："></a>生命：</h2><ul><li><p>有生命和无生命</p></li><li><ul><li>有生命：可以移动、繁殖、生长、进食，和外界进行物质交换</li><li>无生命：无法和外界进行物质交换（除了种子，病毒）</li><li>有生命和无生命都符合相同的物理和化学规则</li></ul></li></ul><h2 id="蛋白质和核酸："><a href="#蛋白质和核酸：" class="headerlink" title="蛋白质和核酸："></a>蛋白质和核酸：</h2><ul><li><p>蛋白质：</p></li><li><ul><li>决定生物的性状</li></ul></li><li><p>核酸：</p></li><li><ul><li>编码蛋白质</li><li>传递遗传信息</li></ul></li></ul><h2 id="蛋白质：-1"><a href="#蛋白质：-1" class="headerlink" title="蛋白质："></a>蛋白质：</h2><ul><li>一级结构：组成蛋白质的多肽链的线性氨基酸序列。</li><li>二级结构：依靠不同氨基酸C=O和N-H基团之间氢键形成的稳定结构</li><li>三级结构：通过多个二级结构元素的排列形成的一个蛋白质分子的三维结构。</li><li>四级结构：用于描述由多个不同肽键间相互作用形成具有功能的蛋白质符合物分子</li></ul><h2 id="DNA：-1"><a href="#DNA：-1" class="headerlink" title="DNA："></a>DNA：</h2><ul><li><p>碱基：</p></li><li><ul><li>A-T, C-G</li><li>A，G：嘌呤</li><li>C，T：嘧啶</li></ul></li></ul><h2 id="非编码RNA："><a href="#非编码RNA：" class="headerlink" title="非编码RNA："></a>非编码RNA：</h2><ul><li>是指不能翻译为蛋白的功能性 RNA 分子</li></ul><h2 id="基因转录："><a href="#基因转录：" class="headerlink" title="基因转录："></a>基因转录：</h2><ul><li>Promoter     （启动子 ）: a region before each gene in DNA; to</li></ul><p>serve as an indication to cellular mechanism that a gene is ahead</p><ul><li>mRNA: a     copy of gene; with exactly the same sequence as one of</li></ul><p>the strands of the gene but substituting U for T</p><ul><li>Introns (     内含子 ): parts of a gene / not used in protein synthesis;</li></ul><p>spliced out from mRNA —&gt;shortened mRNA leaves nucleus with</p><p>exons ( 外显子</p><h2 id="mRNA翻译："><a href="#mRNA翻译：" class="headerlink" title="mRNA翻译："></a>mRNA翻译：</h2><ul><li>把mRNA翻译成蛋白质的过程。</li></ul><h2 id="生物数据库："><a href="#生物数据库：" class="headerlink" title="生物数据库："></a>生物数据库：</h2><h3 id="分类："><a href="#分类：" class="headerlink" title="分类："></a>分类：</h3><ul><li>基因组数据库</li><li>核酸序列数据库</li><li>蛋白质序列数据库</li><li>生物大分子（主要是蛋白质）三维空间结构数据库</li><li>对基因组图谱、核酸和蛋白质序列、蛋白质结构以及文献等数据进行分析、整理、归纳、注释，     具有特殊生物学意义和专门用途的二次数据库</li></ul><h3 id="NCBI："><a href="#NCBI：" class="headerlink" title="NCBI："></a>NCBI：</h3><ul><li>1988 年 11 月美国国家健康研究所（ NIH ）、国家医学图书馆</li></ul><p>NLM ）发起成立。</p><ul><li>1992 年， NCBI 建立 GenBank 核酸序列数据库，将美国专利商标</li></ul><p>局存储的专利序列并入 GenBank 管理，并与 EMBL 、 DDBJ（与 GenBank 并称世界三大生物序列信息数据库）实现数据资源的交换和共享。</p><h3 id="GenBank"><a href="#GenBank" class="headerlink" title="GenBank:"></a>GenBank:</h3><ul><li>GenBank 是 NIH 遗传序列数据库，集成所有公开可获得的已注释</li></ul><p>DNA 序列；</p><ul><li>核酸序列数据根据不同的研究属性，     分属于 Nucleotide 、 GSS 和 EST</li></ul><p>三个子库</p><ul><li>Nculeotide 收录绝大多数常规的核酸序列</li><li>GSS 收录测序起始阶段用来进行序列或基因示踪     、重复序列或基因</li></ul><p>数量预判等的各种短读长序列；</p><ul><li>EST 收录 cDNA 及 cDNA 特征序列信息。</li></ul><h3 id="RefSeq"><a href="#RefSeq" class="headerlink" title="RefSeq:"></a>RefSeq:</h3><ul><li>收集全世界公开发表的各类物种（人、动植物、微生物等）的参考序列（包括基因组、转录体等）</li></ul><h3 id="Gene："><a href="#Gene：" class="headerlink" title="Gene："></a>Gene：</h3><ul><li>基因数据库收录全部已测序物种的基因注释信息。</li><li>包括基因的命称、染色体定位、基因序列和编码产物（     mRNA 、蛋白质）情况、基因功能和相关文献信息等。</li><li>与 GenBank 、 OMIM     、遗传多态数据库（如 dbSNP 、dbVar ）等 NCBI 子库，及 KEGG 、 Gene Ontology等外源性数据库进行交叉引用。</li></ul><h3 id="dbSNP"><a href="#dbSNP" class="headerlink" title="dbSNP:"></a>dbSNP:</h3><ul><li>收集基因组66个物种的基因组变异数据，目前收集超过3.2亿经过验证的人类基因组变异信息。</li></ul><h3 id="dbGap"><a href="#dbGap" class="headerlink" title="dbGap:"></a>dbGap:</h3><ul><li>收集人类基因类型与表型相互作用关系数据。</li></ul><h3 id="GEO："><a href="#GEO：" class="headerlink" title="GEO："></a>GEO：</h3><ul><li>接收和管理基因芯片或测序技术获得的表达数据。</li></ul><h3 id="Epigenomics"><a href="#Epigenomics" class="headerlink" title="Epigenomics:"></a>Epigenomics:</h3><ul><li>表观基因组数据查询和浏览相结合的数据库</li></ul><h3 id="Unigene："><a href="#Unigene：" class="headerlink" title="Unigene："></a>Unigene：</h3><ul><li>分别将不同来源的基因序列、蛋白质相似性（与模式生物比较）、基因表达（不同组织或发育状态）、染色体定位、cDNA 序列、 mRNA 序列（选择性剪接）、 EST 序列等进行罗列和比较。</li></ul><h2 id="UCSC基因组浏览器和数据资源："><a href="#UCSC基因组浏览器和数据资源：" class="headerlink" title="UCSC基因组浏览器和数据资源："></a>UCSC基因组浏览器和数据资源：</h2><ul><li>UCSC 收录了包括人类基因组在内的     48 种哺乳动物（ mam mal ）、 19 种其他</li></ul><p>脊椎动物（ vert e brate ）、 3 种后口动物（ deuterostome ）、 20 种昆虫（insect ）、线虫 nematode ）等众多动物，及病毒 virus ）、酵母等微生物全基因组数据。</p><ul><li>包括基因和基因结构、开放读码框、 mRNA 、 EST 、转录本、非编码基因、基因表达、基因调控、基因变异（ SNPs 、微缺失、微插入等），及重复序列等信息。</li></ul><h3 id="BLAT序列比对工具："><a href="#BLAT序列比对工具：" class="headerlink" title="BLAT序列比对工具："></a>BLAT序列比对工具：</h3><ul><li>支持目标序列与参考基因组进行 DNA 或蛋白序列比对。DNA比对</li><li>快速寻找 95% 或更高的匹配度的 40 碱基以上相似序列，可能会丢失低匹配度的短片段序列。蛋白序列比对</li><li>快速搜索比对长度在 20 氨基酸以上、相似性超过 80% 的序列。</li></ul><h1 id="序列匹配"><a href="#序列匹配" class="headerlink" title="序列匹配"></a>序列匹配</h1><h2 id="一致度："><a href="#一致度：" class="headerlink" title="一致度："></a>一致度：</h2><ul><li>如果两个序列（蛋白质或 DNA ）长度相同，那么它们的一致度定义为他们对应位置上相同的残基（一个字母，氨基酸或碱基）的数目占总长度的百分数。</li></ul><h2 id="相似度："><a href="#相似度：" class="headerlink" title="相似度："></a>相似度：</h2><ul><li>如果两个序列（蛋白质或 DNA ）长度相同，那么它们的相似度定义为他们对应位置上相似的残基与相同的残基的数目和占总长度的百分数。</li></ul><h2 id="打点法："><a href="#打点法：" class="headerlink" title="打点法："></a>打点法：</h2><ul><li>比较序列重叠部分</li><li>寻找序列的重复部分</li></ul><h2 id="双序列全局比对算法："><a href="#双序列全局比对算法：" class="headerlink" title="双序列全局比对算法："></a>双序列全局比对算法：</h2><p><img src="clip_image001.png" alt="NeedlemanWunsch 算 法 》 1970 年 》 SaulNeedleman 和 ChristianWunsch 两  人 首 先 将 动 态 規 划 算 法 应 用 于 两 条 序 列 的 全 局 比 对 》 这 个 算 法 后 称 为  Needleman Wunsch 算 法 。  ． 000000  00000  序 列 p ： ACGTC  序 列 q ： AATC  m=length (p)  n=length (q)  瞥 换 记 分 矩 阵  gap  000000  0 0  s 性 ， j ） 是 按 照 替 换 记 分 矩 阵 得 到 的 前  幻 与 p [ 1 最 大 相 似 性 的 得 分 。  w 性 ， ） 是 字 符 q 巨 ] 和 p [ ] 按 照 替 换 记 分  矩 阵 计 算 的 得 分  得 分 矩 阵 "></p><h2 id="双序列局部比对算法："><a href="#双序列局部比对算法：" class="headerlink" title="双序列局部比对算法："></a>双序列局部比对算法：</h2><p><img src="clip_image002.png" alt="声 处 理 子 序 列 与 完 整 序 列 （ 或 短 序 列 与 长 序 列 ） 比 对  的 一 般 过 程 是 ： 设 短 序 列 “ 和 长 序 列 心 ， 它 们 的 长 度  分 别 为 和 ， 比 对 是 在 心 序 列 中 寻 找 长 度 的 “ 序  列 的 过 程 。  0  一 螃 一 1 ） 乛 。 动 ）  S(i,J)=max  s(i,j 一 1) + 还  匹 配 或 错 还  缺 失 "></p><p><img src="file:///C:/Users/luoli/AppData/Local/Temp/msohtmlclip1/02/clip_image003.png" alt="双 序 列 局 部 比 对 及 算 法  全 局 比 对 。 m 亡 m) ： 用 于 比 较 两 个 长 度 近 似 的 序 列  局 部 比 对 (localaligment) ： 用 于 比 较 一 长 一 短 两 条 序 列  1981 年 Temp smi 宙 和 MichaelWa 忙 m ] an 对 局 部 比 对 进 行 了 研 究 》 产 生  了 Smith-Waterman 算 法 。  序 列 p ： ACGTC  序 列 q ： CG  得 分 矩 阵  字 符 对 字 符  序 列 p  字 符 对 空 位  序 列 q  箭 头 指 看 的 序 列 为 空 位  局 部 序 列 比 对 结 果 ： 16  字 符 对 空 位  序 列 p  箭 头 指 看 的 序 列 为 空 位  序 列 q  全 局 序 列 比 对 结 果 ： 1 "></p><p><img src="file:///C:/Users/luoli/AppData/Local/Temp/msohtmlclip1/02/clip_image004.png" alt="一 致 度 和 相 似 度 的 正 确 算 法  如 果 两 个 序 列 长 相 同 ：  一 致 度 (identity)  相 似 度 （  similarity)  （ 一 致 字 符 的 个 数 / 全 局 比 对 长 度 ） × 10 “  （ 一 致 及 相 似 的 字 符 的 个 数 / 全 局 比 对 长 度 ） × 100  序 列 1 ： CVHK-LA  identity ： （ 4 / 7 ） * 100  57  月 ． 歹 ] 2 ： C—HKTIA similarity ： （ （ 4 + 1 ） / 7 ） 100  71  如 果 两 个 序 列 长 度 不 相 同 ：  一 致 度 (identity) ： （ 一 致 字 符 的 个 数 / 全 局 比 对 长 度 ） × 10 “  相 似 度 （  similarity)  一 （ 一 致 及 相 似 的 字 符 的 个 数 / 全 局 比 对 长 度 ） × 10 “  月 ． 屮 ] 1 ： CVHKAT identity ： （ 4 / 6 ） * 100  67  月 ． 歹 ] 2 ： CIHK T similarity ： （ （ 4 + 1 ） ／ 巧 ） 噙 100  83  无 论 两 个 序 列 长 度 是 否 相 同 》 都 要 先 做 双 序 列 全 局 比 对 》  然 后 根 据 比 对 结 果 及 比 对 长 度 计 算 它 们 的 一 致 度 和 相 似 度 "></p><h2 id="Seeding"><a href="#Seeding" class="headerlink" title="Seeding"></a>Seeding</h2><p><img src="clip_image005.png" alt="For a given word length w (usually 3 for proteins and 11 for  nucleotides), slicing the query sequence into multiple  continuous &quot;seed words&quot;  Query Sequence  MVLSPADKTNVKAAW "></p><p><img src="clip_image006.png" alt="Speedup: mask low-complexity  Low complexity  sequences yield false  positives.  - CACACACACACACACA  K  1  log  Alphabet size (4 or  11  Window len  Frequency of the fth letter "></p><h1 id="分子进化分析"><a href="#分子进化分析" class="headerlink" title="分子进化分析"></a>分子进化分析</h1><p>从物种的一些分子特性出发，从而了解物种之间的生物系统发生的关系。</p><h2 id="分子进化的模式："><a href="#分子进化的模式：" class="headerlink" title="分子进化的模式："></a>分子进化的模式：</h2><ul><li><p>DNA突变的模式：替代，插入，缺失，倒位；</p></li><li><p>核苷酸替代：转换(Transition) &amp; 颠换(Transversion)</p></li><li><p>基因复制：多基因家族的产生以及伪基因的产生</p></li><li><ul><li>A. 单个基因复制– 重组或者逆转录</li><li>B. 染色体片断复制</li><li>C. 基因组复制</li></ul></li></ul><h2 id="分子进化的目的："><a href="#分子进化的目的：" class="headerlink" title="分子进化的目的："></a>分子进化的目的：</h2><ul><li>物种分类及关系：从物种的一些分子特性出发，构建系统发育树，进而了解物种之间的生物系统发生的关系—— tree of life</li><li>大分子功能与结构的分析：同一家族的大分子，具有相似的三级结构及生化功能，通过序列同源性分析，构建系统发育树，进行相关分析；功能预测</li><li>进化速率分析：例如，HIV的高突变性；哪些位点易发生突变？</li></ul><h1 id="系统发生与重建："><a href="#系统发生与重建：" class="headerlink" title="系统发生与重建："></a>系统发生与重建：</h1><h2 id="基因的编码区和非编码区："><a href="#基因的编码区和非编码区：" class="headerlink" title="基因的编码区和非编码区："></a>基因的编码区和非编码区：</h2><ul><li>基因的DNA由编码区（Coding region）和非编码区（Noncoding region）构成；</li><li>编码区可以转录信使RNA，进而调控蛋白质的合成；</li><li>非编码区不能转录成信使RNA，但是它可以调控遗传信息</li></ul><p>的表达；</p><ul><li>原核基因：编码区全部编码蛋白质；</li></ul><p>真核基因：编码区分为外显子和内含子,只有外显子能编码蛋白质；</p><h2 id="两个序列间的核苷酸差异："><a href="#两个序列间的核苷酸差异：" class="headerlink" title="两个序列间的核苷酸差异："></a>两个序列间的核苷酸差异：</h2><p><img src="clip_image007.png" alt="声 对 于 一 种 同 的 核 酸 分 子 来 说 ， 它 在 亲 缘 关 系 越 近  的 生 物 之 间 差 异 就 越 小 ， 相 反 差 异 就 越 大 ， 即 两 同  源 分 子 分 歧 的 时 间 与 它 们 之 间 的 序 列 差 异 成 正 比 。  声 同 一 条 祖 先 序 列 传 衍 的 两 条 后 裔 序 列 ， 它 们 的 核 苷  酸 差 异 随 时 间 而 增 加 。 一 个 简 便 的 描 述 序 列 分 歧 大  小 的 测 度 是 两 条 后 裔 序 列 中 不 同 核 苷 酸 位 点 的 比 例 。  声 以 下 ， 我 们 称 此 估 计 为 p 距 离 。 "></p><p><img src="clip_image008.png" alt="声 当 ， 遵 循 分 布 时 ， 就 有 可 能 估 计 出 平 均 每 个 位 点 的  氨 基 酸 替 代 数 。 为 此 ， 让 我 们 考 虑 在 时 间 耐 两 个  序 列 间 某 一 位 点 上 的 氨 基 酸 相 同 的 概 率 ， 按 公 式  （ 4 ． 4 ） 计 算 。 然 后 ， 对 所 有 位 点 的 q 求 均 值 ， 为  a + 2 "></p><h2 id="基于距离法构建系统发生树"><a href="#基于距离法构建系统发生树" class="headerlink" title="基于距离法构建系统发生树"></a>基于距离法构建系统发生树</h2><h3 id="距离矩阵"><a href="#距离矩阵" class="headerlink" title="距离矩阵"></a>距离矩阵</h3><p><img src="clip_image009.png" alt="A Sequences  sequence A ACGCGTTGG GCG A TG G CAAC  TTGG G c G ACG G T A AT  sequence a ACGCA TTGA A T GA TG A TAA T  sequence D AC TTGA G T GAT A A TAA T  B. Distances between sequences, the number of steps  required to change one sequence into the other.  nac  nso  C. Distance table "></p><h3 id="通过距离构建树"><a href="#通过距离构建树" class="headerlink" title="通过距离构建树"></a>通过距离构建树</h3><p>同组合并，距离相加/2</p><p><img src="clip_image010.png" alt="22  39  41  39  41  18  41  43  20  10 "></p><p>19=（18+20）/2</p><p><img src="clip_image011.png" alt="22  (DE)  39  41  40  42  19  c-19/2=9.5 "></p><h2 id="基于最小二乘法构建系统发生树"><a href="#基于最小二乘法构建系统发生树" class="headerlink" title="基于最小二乘法构建系统发生树"></a>基于最小二乘法构建系统发生树</h2><p><img src="clip_image012.png" alt="表 4 一 7 线 粒 体 DNA 序 列 的 成 对 距 离  4 ． 猩 猩  2 ． 黑 猩 猩  3 ． 大 猩 猩  4 ． 猩 猩  0 ． 0965  0 ． 1849  2 ． 黑 猩 猩  0 ． 1180  0 ． 2009  3 ． 大 猩 猩  0 」 947 "></p><p><img src="clip_image013.png" alt="s  _d13)2 + (dl 4  -d9)2  — d12)2  = (d12  +(d24  —d34)2  0008840 0043266  0000000 0046212  o.osns  -d23)2  S,  o.0fS908 0.13f79S  0061854 0.138742 0_0001 "></p><h2 id="分子钟假说："><a href="#分子钟假说：" class="headerlink" title="分子钟假说："></a>分子钟假说：</h2><ul><li>分子钟（molecular clock）假说认为DNA或蛋白质序列的进化速率随时间或进化谱系保持恒定。</li><li>最简单的分子钟假设检验是采用第三个物种C（外</li></ul><p>类群）来检验两个物种A和B是否以相同的速率进</p><p>化。这一检验称为相对速率检验（relative-rate</p><p>test），其实几乎所有的分子钟检验比较的都是相</p><p>对速率而不是绝对速率。</p><h1 id="蛋白质和核苷酸的适应性进化"><a href="#蛋白质和核苷酸的适应性进化" class="headerlink" title="蛋白质和核苷酸的适应性进化"></a>蛋白质和核苷酸的适应性进化</h1><h2 id="中性与近中性理论："><a href="#中性与近中性理论：" class="headerlink" title="中性与近中性理论："></a>中性与近中性理论：</h2><p>按照中性理论，我们今天观察到的遗传变异——无论是种内多态性还是中间分歧，均不取决于自然选择所驱动的有利突变的固定，而是取决于那些事实上没有适合效应（即中性的）突变的随机固定。</p><p>这个理论认为在<a href="https://zh.wikipedia.org/wiki/分子遺傳學">分子遗传学</a>的层次上，基因的变化大多数是<a href="https://zh.wikipedia.org/w/index.php?title=中性突變&amp;action=edit&amp;redlink=1">中性突变</a>，也就是对生物个体的生殖与生存既没有好处也没有坏处的突变。由于中性突变并不受<a href="https://zh.wikipedia.org/wiki/自然選擇">自然选择</a>影响，而是由中性的<a href="https://zh.wikipedia.org/wiki/突变">突变</a>基因的<a href="https://zh.wikipedia.org/wiki/遗传漂变">遗传漂变</a>产生的，因此中性理论也曾被认为是与<a href="https://zh.wikipedia.org/wiki/查尔斯·达尔文">查尔斯·达尔文</a>的<a href="https://zh.wikipedia.org/wiki/自然選擇">自然选择</a>论处于竞争状态。另外木村资生提出突然变异产生的蛋白质和原本的蛋白质之间没有适应性的差异时的突然变异则称为<a href="https://zh.wikipedia.org/w/index.php?title=中立突然變異&amp;action=edit&amp;redlink=1">中立突然变异</a>的理论</p><p>来自 <a href="[https://zh.wikipedia.org/zh-cn/%E4%B8%AD%E6%80%A7%E6%BC%94%E5%8C%96%E7%90%86%E8%AB%96](https://zh.wikipedia.org/zh-cn/中性演化理論)">[https://zh.wikipedia.org/zh-cn/%E4%B8%AD%E6%80%A7%E6%BC%94%E5%8C%96%E7%90%86%E8%AB%96](https://zh.wikipedia.org/zh-cn/中性演化理論)</a> </p><h3 id="主要内容："><a href="#主要内容：" class="headerlink" title="主要内容："></a>主要内容：</h3><ul><li>承认负选择。</li><li>认为正选择力量很小。</li><li>强调功能约束。</li><li>功能的约束造成不同的基因突变速率不同。</li><li>功能重要的部分变化会影响其功能，大多数的变化均饱受负选择作用。</li><li>功能不很重要的部分变化多，不影响功能，被随机保留。</li></ul><p><img src="clip_image014.png" alt="s fi{JZX  0, select against  0, selected for;  (Nearly neutral) :  Isl &lt; 1/ (2Ne) , IslS1/Ne  Ne: (effective population size) "></p><p><img src="clip_image015.png" alt="4 ． 严 格 中 性 选 择 下 的 演 化 速 率 ： 左  v ： 每 代 、 每 个 配 子 的 突 变 速 率  士 population 中 的 个 体 数  每 代 Population 中 新 的 突 变 ： 2M&#39;  “ ： 单 个 突 变 在 Population 中 被 固 定 的 概 率  每 代 被 固 定 在 Population 中 的 中 性 突 变 的 概 率 ： 1/2N  因 此 ， 当 、 等 于 零 ， 即 中 性 选 择 时 ，  与 Population 大 小 无 关 ！  k= (2Nv)(1/2N) =v ， "></p><h2 id="经典演化和分子演化的区别"><a href="#经典演化和分子演化的区别" class="headerlink" title="经典演化和分子演化的区别"></a>经典演化和分子演化的区别</h2><ol><li><p>经典演化以形态特征为主：如被子植物的花：花瓣离生-花瓣合生</p></li><li><ol><li>自然选择成为主要驱动力</li></ol></li><li><p>分子演化的特征：</p></li><li><ol><li>种群内以随机选择（遗传漂变）为主要驱动力</li></ol></li></ol><h2 id="蛋白质水平演化速率："><a href="#蛋白质水平演化速率：" class="headerlink" title="蛋白质水平演化速率："></a>蛋白质水平演化速率：</h2><p>不同位点上的氨基酸替代率相同，或即使不相同，平均替代速率也很小</p><p><img src="clip_image016.png" alt="0 ． ． 0 ． 000  2 ． 蛋 白 质 演 化 速 率 的 计 算  祖 先 序 列 、 、 、 一 0000H0 一 0  “ 翮 ： 所 比 较 序 列 的 氨 基 酸 数 目  ： 所 比 较 两 个 序 列 中 差 异 的 氨 基 酸 数 目  尹 d ： 两 个 序 列 氨 基 酸 相 差 的 程 度  P  7 &#39; ： 两 个 同 源 序 列 分 歧 的 时 间 "></p><p><img src="clip_image017.png" alt="序 列 中 的 氨 基 酸 数 ： “  = 8  序 列 1 ： 8 个 氨 基 酸  原 始 物 种 （ PA ）  序 列 2 ： 8 个 氨 基 酸  差 异 的 氨 基 酸 数 目  T( 年 ）  P2  PI  Pd ： 引 8 ： 0 ， 375 物 种 PI  物 种  7 &#39; ： 两 个 同 序 列 分 歧 的 时 间 "></p><p><img src="clip_image018.png" alt="Kaa ： 两 个 同 源 序 列 中 每 个 位 点 氨 基 酸 的 平 均 替 代 数  (substitute number) ：  假 设 ： 每 个 位 点 发 生 替 代 数 0 ， 1 ， 2 ． “ 的 概 率 符 合 泊 松 分 布  e•Kaa + 人 e ． 人 翮 +  矿 a ： 1 ． 尹 d Kaa=-ln(l-Pd)  每 个 位 点 的 氨 基 酸 平 均 替 代 速 率 (substitute rate) ：  一 每 年 每 个 位 点 氨 基 酸 的 替 代 速 率 "></p><h2 id="分子钟："><a href="#分子钟：" class="headerlink" title="分子钟："></a>分子钟：</h2><ol><li><p>一个特定的大分子（蛋白质或DNA）在所有演化谱系中具有恒定的演化速率</p></li><li><p>得到速率的关键：大分子(物种）的分歧时间</p></li><li><ul><li>时间很难预测</li><li>最真的使用化石或者地质事件</li><li>相对速率：用一分歧时间早于所研究的物种作为参考</li><li>先决条件：演化速率恒定</li></ul></li></ol><h1 id="基因表达数据分析"><a href="#基因表达数据分析" class="headerlink" title="基因表达数据分析"></a>基因表达数据分析</h1><h2 id="基因表达的时间性和空间性"><a href="#基因表达的时间性和空间性" class="headerlink" title="基因表达的时间性和空间性"></a>基因表达的时间性和空间性</h2><h3 id="时间特异性："><a href="#时间特异性：" class="headerlink" title="时间特异性："></a>时间特异性：</h3><ul><li>是指特定基因的表达严格按照特定的时间顺序发生以适应细胞或个体特定分化、发育阶段的需要，故又称为阶段特异性。</li></ul><h3 id="空间特异性："><a href="#空间特异性：" class="headerlink" title="空间特异性："></a>空间特异性：</h3><ul><li>是指多细胞生物个体在特定生长发育阶段，同一基因表达在不同的细胞或组织器官不同，从而导致特异性蛋白质分布于不同的细胞或组织器官。故又称为细胞 特异性或组织特异性。</li></ul><h2 id="基因表达方式："><a href="#基因表达方式：" class="headerlink" title="基因表达方式："></a>基因表达方式：</h2><h3 id="组成表达："><a href="#组成表达：" class="headerlink" title="组成表达："></a>组成表达：</h3><ul><li>指在个体发育的任一阶段都能在大多数细胞中持续进行的基因表达。</li><li>其基因表达产物通常是对生命过程必需的或必不可少的，且较少受环境因素的影响。</li><li>这类基因通常被称为管家基因（housekeeping gene）。</li></ul><h3 id="诱导和阻碍表达："><a href="#诱导和阻碍表达：" class="headerlink" title="诱导和阻碍表达："></a>诱导和阻碍表达：</h3><ul><li>诱导表达（Induction）是指在特定环境因素刺激下，基因被激活，从</li></ul><p>而使基因的表达产物增加。这类基因称为可诱导基因。</p><ul><li>DNA损伤→修复酶基因激活</li><li><p>乳糖→利用乳糖的三种酶表达</p></li><li><p>阻遏表达（repression）是指在特定环境因素刺激下，基因被抑制，从而使基因的</p></li></ul><p>表达产物减少。这类基因称为可阻遏基因。</p><h3 id="协调表达和协调调节："><a href="#协调表达和协调调节：" class="headerlink" title="协调表达和协调调节："></a>协调表达和协调调节：</h3><p>在一定机制控制下，功能上相关的一组基因，无论其为何种表达方式，均需要协调一致，共同表达。</p><h2 id="基因表达数据的分析："><a href="#基因表达数据的分析：" class="headerlink" title="基因表达数据的分析："></a>基因表达数据的分析：</h2><ol><li>分析单个基因的表达水平，根据在不同实验条件下，基因表达</li></ol><p>水平的变化，来判断它的功能，采用的分析方法有统计学中的假</p><p>设检验等。</p><ol><li>考虑基因组合，将基因分组，研究基因的共同功能、相互作用</li></ol><p>以及协同调控等。多采用聚类分析等方法。</p><ol><li>尝试推断潜在的基因调控网络，从机理上解释观察到的基因表</li></ol><p>达数据。多采用反向工程的方法。</p><h2 id="基因表达测定方法RT-qPCR"><a href="#基因表达测定方法RT-qPCR" class="headerlink" title="基因表达测定方法RT-qPCR"></a>基因表达测定方法RT-qPCR</h2><p><img src="clip_image019.png" alt="absolute quantification  relative quantification  tm detettrm  Rox  via  normalisation  via  gene index  HKG  external  Curve  syeR  . RT_PCR product  • pbsrmd OVA  without PCR  correction  • RNA  • syrttetic  • SyrthetiC RNA Oligos  P CR  emciency  REST, "></p><h1 id="基因表达测定平台与数据库："><a href="#基因表达测定平台与数据库：" class="headerlink" title="基因表达测定平台与数据库："></a>基因表达测定平台与数据库：</h1><h2 id="cDNA芯片："><a href="#cDNA芯片：" class="headerlink" title="cDNA芯片："></a>cDNA芯片：</h2><ul><li>– cDNA是与mRNA互补的DNA分子，长约0.2~5kb</li><li>– 通过碱基互补配对原则进行探针与待测mRNA之间的分子杂交产生信号，反映待检mRNA水平，在一定程度上体现基因的表达水平</li></ul><h2 id="Typical-RNA-Seq-experiment"><a href="#Typical-RNA-Seq-experiment" class="headerlink" title="Typical-RNA-Seq experiment:"></a>Typical-RNA-Seq experiment:</h2><p>①内容： RNA-seq技术就是把mRNA切成许多长度介于</p><p>100bp~200bp的短片段，然后反转录合成cDNA，进行PCR扩增，利用高通量测序技术获得相关的基因表达信息。</p><p>②优势：有助于探索真核转录的复杂性，此外还提供了比其他方法更精确的转录水平及其亚型的测量方法。</p><h2 id="Microarray技术与RNA-Seq技术的比较："><a href="#Microarray技术与RNA-Seq技术的比较：" class="headerlink" title="Microarray技术与RNA-Seq技术的比较："></a>Microarray技术与RNA-Seq技术的比较：</h2><p>1.RNA-Seq技术对没有已知参考基因组信息的非模式生物，也可测定转录信息；</p><p>2.RNA-Seq技术可以测定转录边界的精度达到一个碱基，RNA-Seq可以用来研究复杂的转录关系；</p><p>3.RNA-Seq可以同时测定序列的变异；</p><p>4.RNA-Seq背景信号很小，测定的动态范围很大。</p><p>Ø RNA-Seq在基因表达的定量上准确性很高；</p><p>Ø RNA-Seq在测定技术上和生物上重复性很高；</p><p>Ø RNA-Seq的测定需要很少的RNA样本。</p><p>Ø 在应用上RNA-Seq技术对ISOFORM的测定和等位基因的区分比芯片技术有很好的优势。</p><h2 id=""><a href="#" class="headerlink" title=" "></a> </h2><h2 id="基因表达数据库："><a href="#基因表达数据库：" class="headerlink" title="基因表达数据库："></a>基因表达数据库：</h2><p><img src="clip_image020.png" alt="常 用 基 因 表 达 数 据 库 名 称  Gene Expression  Omnibus （ GEO ）  Expression Atlas  SMD  RNA-Seq Atlas  GEPdb  GND  EMAGE  AGEMAP  数 据 库 内 容  目 前 最 常 用 的 基 因 表 达 数 据 (NCBI)  欧 洲 生 物 信 息 学 中 心 的 基 因 表 达 数 据 库  Stanford 基 因 表 达 数 据 库  正 常 组 织 的 基 因 表 达 谱 数 据  基 因 型 、 表 型 和 基 因 表 达 关 系  老 鼠 发 育 基 因 表 达 信 息  老 鼠 胚 胎 的 时 空 表 达 信 息  老 鼠 老 化 的 基 因 表 达 数 据 "></p><h2 id="疾病相关基因表达数据库"><a href="#疾病相关基因表达数据库" class="headerlink" title="疾病相关基因表达数据库"></a>疾病相关基因表达数据库</h2><p><img src="clip_image021.png" alt="数 据 库 名 称  GENT  Parld)B  cMAP  Anticancer drug gene  expression database  CGED  数 据 库 内 容  肿 瘤 组 织 与 正 常 组 织 的 表 达 数 据  帕 金 森 病 的 基 因 表 达 数 据 库  小 分 子 化 合 物 对 人 细 胞 基 因 表 达 的 影 响  抗 癌 化 合 物 的 基 因 表 达 数 据  癌 症 基 因 表 达 数 据 库 （ 包 括 临 床 信 息 ） "></p><h1 id="数据预处理与差异表达分析："><a href="#数据预处理与差异表达分析：" class="headerlink" title="数据预处理与差异表达分析："></a>数据预处理与差异表达分析：</h1><p><img src="clip_image022.png" alt="（ 一 ） 倍 数 法  实 验 条 件 下 的 表 达 值  对 照 条 件 下 的 表 达 值  龙 通 常 以 2 倍 差 异 为 阈 值 ， 判 断 基 因 是 否 差 异 表 达 "></p><h2 id="表达量的计算"><a href="#表达量的计算" class="headerlink" title="表达量的计算"></a>表达量的计算</h2><p><img src="clip_image023.png" alt="Fragments/Reads Per Kilobase of exon per Million fragments  mapped  x 1 09  FPKM, =  LtM  Xt - No of fragments mapped to transcript t  Lt — length of transcript t  M - No of total fragments mapped  Fragment sampling variance. X, —Possion(ir)  Biological variance: Gamma(a, ß/(l-ß))  Overall: X, Negative Binomial(a, /3) "></p><h2 id="t检验法："><a href="#t检验法：" class="headerlink" title="t检验法："></a>t检验法：</h2><p><img src="clip_image024.png" alt="（ 二 ） t 检 验 法  Xl 一 2  2  龙 运 用 ／ 检 验 法 可 以 判 断 基 因 在 两 不 同 条 件 下 的 表  达 差 异 是 否 具 有 显 著 性 "></p><h2 id="方差分析："><a href="#方差分析：" class="headerlink" title="方差分析："></a>方差分析：</h2><p><img src="clip_image025.png" alt="MS  SS "></p><h2 id="SAM方法："><a href="#SAM方法：" class="headerlink" title="SAM方法："></a>SAM方法：</h2><p><img src="clip_image026.png" alt="（ 四 ） SAM ： 去 （ significance analysis of microarrays)  1. 多 重 假 设 检 验 问 题  I 型 错 误 （ 假 阳 性 ）  声 在 假 设 检 验 作 推 断 结 论 时 ， 拒 绝 了 实 际 上 正 确 的 检  验 假 设 ， 即 将 无 差 异 表 达 的 基 因 判 断 为 差 异 表 达 。  Il 型 错 误 （ 假 阴 性 ）  声 不 拒 绝 实 际 上 不 正 确 的 ， 即 将 有 差 异 表 达 的 基 因 判  断 为 无 差 异 表 达 。 "></p><h1 id="基因注释与功能分类："><a href="#基因注释与功能分类：" class="headerlink" title="基因注释与功能分类："></a>基因注释与功能分类：</h1><p>功能基因组学的主要任务之一是进行基因组功能注释（genome annotation），了解基因的功能，认识基因与疾病的关系，掌握基因的产物及其在生命活动中的作用等。</p><p>快速有效的基因注释对进一步识别基因，研究基因的表达调控机制，研究基因在生物体代谢途径中的地位，分析基因、基因产物之间的相互作用关系，预测和发现蛋白质功能，揭示生命的起源和进化等具有重要的意义。</p><h2 id="Go数据库："><a href="#Go数据库：" class="headerlink" title="Go数据库："></a>Go数据库：</h2><p>基因本体数据库是GO组织（Gene Ontology Consortium）在2000年构建的一个结构化的标准生物学模型，旨在建立基因及其产物知识的标准词汇体系，涵盖了基因的细胞组分（cellular component）、分子功能（molecular function）、生物学过程（biological process）。</p><h2 id="Go注释"><a href="#Go注释" class="headerlink" title="Go注释"></a>Go注释</h2><p><img src="clip_image027.png" alt="GO 注 释 体 系 特 点  多 GO 通 过 控 制 注 释 词 汇 的 层 次 结 构 使 得 研 宄 人 员 能 够  从 不 同 层 面 查 询 和 使 用 基 因 注 释 信 息 。  声 从 整 体 上 来 看 GO 注 释 系 统 是 一 个 有 向 无 环 图  （ directed acyclic graphs) ， 包 含 三 个 分 支 ， 即 ： 生 物  学 过 程 （ biological process ） ， 分 子 功 能 （ molecular  function) 和 纟 日 胞 组 弓 （ cellular component ） 。  多 注 释 系 统 中 每 一 个 结 点 (node) 都 是 基 因 或 蛋 白 的  一 种 描 述 ， 结 点 之 间 保 持 严 格 的 关 系 ， 即 &quot;is a ” 或  part 0 「 ， 。 "></p><h2 id="KEGG数据库："><a href="#KEGG数据库：" class="headerlink" title="KEGG数据库："></a>KEGG数据库：</h2><p>京都基因与基因组百科全书（Kyoto encyclopedia of genes and genomes, KEGG） 是系统分析基因功能、基因组信息的数据库，它整合了基因组学、生物化学以及系统功能组学的信息，有助于研究者把基因及表达信息作为一个整体网络进行研究。</p><h2 id="基因集功能富集分析"><a href="#基因集功能富集分析" class="headerlink" title="基因集功能富集分析"></a>基因集功能富集分析</h2><ul><li>富集分析方法通常是分析一组基因在某个功能结点上是否过出现（over-presentation）。这个原理可以由单个基因的注释分析发展到大基因集合的成组分析。</li><li>由于分析的结论是基于一组相关的基因，而不是根据单个基因，所以富集分析方法增加了研究的可靠性，同时也能够识别出与生物现象最相关的生物过程。</li></ul><h1 id="基因功能预测"><a href="#基因功能预测" class="headerlink" title="基因功能预测"></a>基因功能预测</h1><ul><li>首先，从总体上宏观地概括抽取信息，如不同样本间、不同时间点间全部差异基因；</li><li>其次，通过GO或KEGG分析，即从GO分类结果找到实验涉及的显著功能类别或将差异基因映射到通路中，</li></ul><p>根据基因在通路中的位置及表达水平的变化算出受影响显著的通路，从而预测未知的基因功能等。</p><h2 id="基于Go的基因功能预测："><a href="#基于Go的基因功能预测：" class="headerlink" title="基于Go的基因功能预测："></a>基于Go的基因功能预测：</h2><ol><li>对差异表达基因进行功能预测</li><li>蛋白质互作用网络用于基因功能预测</li><li>利用GO体系结构比较基因功能</li></ol><h2 id="基于KEGG通路分析的基因功能预测："><a href="#基于KEGG通路分析的基因功能预测：" class="headerlink" title="基于KEGG通路分析的基因功能预测："></a>基于KEGG通路分析的基因功能预测：</h2><p>通路分析是现在经常被使用的芯片数据基因功能分析法。与GO分类法（应用单个基因的GO分类信息）不同，通路分析法利用的资源是许多已经研究清楚的基因之间的相互作用，即生物学通路。研究者可以把表达发生变化的基因集导入通路分析软件中，进而得到变化的基因都存在于哪些已知通路中，并通过统计学方法计算哪些通路与基因表达的变化最为相关。</p><h1 id="生物分子网络与通路："><a href="#生物分子网络与通路：" class="headerlink" title="生物分子网络与通路："></a>生物分子网络与通路：</h1><h2 id="生物学通路："><a href="#生物学通路：" class="headerlink" title="生物学通路："></a>生物学通路：</h2><ul><li>生物学通路是指由生物体内一系列生物化学分子，包括基因、基因产物极其化合物，通过各种生化级联反应来完成的某一个生物学过程。</li><li>生物体内最主要的生物学通路就包括代谢通路和信号传导通路。</li></ul><h2 id="转录调控网络："><a href="#转录调控网络：" class="headerlink" title="转录调控网络："></a>转录调控网络：</h2><ul><li>描述转录因子，极其调控的基因之间的关系</li><li>有向图</li><li>其中点表示转录因子或者被调控的基因，边表示转录因子对基因的调控关系，箭头指向被调控的基因</li></ul><h2 id="mRNA："><a href="#mRNA：" class="headerlink" title="mRNA："></a>mRNA：</h2><ul><li>miRNA是基因调控网络中的主要组分，在人类细胞中有~1200miRNA，miRNA可以在转录后和翻译水平</li></ul><p>上调控多于30%的编码基因的表达。</p><ul><li>miRNA和靶基因间不是简单的一对一的关系，而是复杂的多对多的关系，形成了复杂的转录后调控网络。</li><li>其中网络中包含两种类型的节点，miRNA和靶基因，网络的边代表miRNA对于靶基因具有调控作用。</li><li>miRNA-靶基因的转录后调控网络是一种典型的二分网络，网络的边只存在于miRNA集合和靶基因集合之间，而miRNA集合和靶基因集合内部并不存在调控关系。</li></ul><h2 id="蛋白质互作用数据库："><a href="#蛋白质互作用数据库：" class="headerlink" title="蛋白质互作用数据库："></a>蛋白质互作用数据库：</h2><ul><li>HPRD数据库</li><li>BIND数据库</li><li>DIP数据库</li><li>IntAct数据库</li><li>BioGRID数据库：基因和蛋白质相互作用的数据库</li></ul><h2 id="代谢网络："><a href="#代谢网络：" class="headerlink" title="代谢网络："></a>代谢网络：</h2><ul><li>代谢通路是指细胞中代谢物在酶的作用下转化为新的代谢物过程中发生的一系列生物化学反应</li><li>代谢网络则是指由代谢反应以及调节这些反应的调控机制所组成的描述细胞内代谢和生理过程的网络</li></ul><h2 id="完全网络"><a href="#完全网络" class="headerlink" title="完全网络"></a>完全网络</h2><ul><li>最完整的保存代谢通路中各个反应，以及每个反应中的底物、产物和酶。</li></ul><h2 id="多反应物网络"><a href="#多反应物网络" class="headerlink" title="多反应物网络"></a>多反应物网络</h2><ul><li>代谢物只由一个节点表示，边由底物指向产物，酶与底物、产物之间的边则可以由双向边来表示。</li></ul><h2 id="主要反应物网络"><a href="#主要反应物网络" class="headerlink" title="主要反应物网络"></a>主要反应物网络</h2><ul><li>只包含主要代谢底物指向主要产物的网络。</li></ul><h2 id="-1"><a href="#-1" class="headerlink" title=" "></a> </h2><h2 id="信号传导网络："><a href="#信号传导网络：" class="headerlink" title="信号传导网络："></a>信号传导网络：</h2><ul><li>生物中的信号传导(Signal transduction)则是指细胞将一种类型的生物信号或刺激转换为其他生物信号</li></ul><p>最终激活细胞反应的过程。</p><ul><li>同代谢通路一样，信号传导的过程中多个生物分子在酶作用下按照一定顺序发生一系列生理化学反应，</li></ul><p>由此得到了信号传导通路。</p><ul><li>信号传导网络即是指参与信号传导通路的分子和酶以及其间所发生的生化反应所构成的网络。</li></ul><h1 id="生物分子网络分析："><a href="#生物分子网络分析：" class="headerlink" title="生物分子网络分析："></a>生物分子网络分析：</h1><h2 id="连通度和图的连通度"><a href="#连通度和图的连通度" class="headerlink" title="连通度和图的连通度"></a>连通度和图的连通度</h2><p><img src="clip_image028.png" alt="声 连 通 度 描 述 了 网 络 中 某 个 节 点 的 连 接 数 量 ， 整 个 网  络 的 连 通 性 可 以 使 用 其 平 均 值 来 表 示 。  声 对 于 由 N 个 节 点 和 L 条 边 组 成 的 无 向 网 络 其 平 均 连 通  度 为 Knet=2L/N 。  声 连 通 度 较 大 的 节 点 称 为 中 心 节 点 (hub)  声 必 需 基 因 或 其 翻 译 产 物 的 比 例 在 中 心 节 点 中 出 现 的  频 率 显 著 高 于 一 般 节 点 。 "></p><p><img src="clip_image029.png" alt="声 计 算 图 A 和 B 中 A 点 的 连 通 度 ， 以 及 图 A 的 网 络 的  连 通 度 。  = 16 / 7 = 2 · 29 "></p><h2 id="聚类系数："><a href="#聚类系数：" class="headerlink" title="聚类系数："></a>聚类系数：</h2><p><img src="clip_image030.png" alt="2n  ccv "></p><p><img src="clip_image031.png" alt="声 公 式 中 ， K 表 示 节 点 v 的 邻 居 数 目 ， n 表 示 节 点 v 的  K 个 邻 居 两 两 之 间 连 接 的 边 数 ， Ck2 表 示 K 个 邻 居  两 两 相 连 的 最 多 边 数 。  CC  0  2 ”  左@ 一 I 丿 "></p><h2 id="有向网络聚类系数："><a href="#有向网络聚类系数：" class="headerlink" title="有向网络聚类系数："></a>有向网络聚类系数：</h2><p><img src="clip_image032.png" alt="在 有 向 网 络 中 ， 由 于 两 个 节 点 间 可 以 存 在 两 条 方 向  相 反 的 边 ， 则 标 准 化 的 聚 类 系 数 被 定 义 为 ：  CC  佐 。 ut -l 丿  其 中 ， kout 指 v 的 出 度 ， K 指 节 点 A 指 向 的 连 接 的 邻  居 个 数 ， n 指 所 有 A 所 指 向 的 连 接 的 节 点 彼 此 之 间 存  在 的 边 数 。 "></p><h2 id="边介数："><a href="#边介数：" class="headerlink" title="边介数："></a>边介数：</h2><p>边介数：网络中所有最短路径中经过该边的路径的数目占最短路径总数的比例。</p><h2 id="紧密度："><a href="#紧密度：" class="headerlink" title="紧密度："></a>紧密度：</h2><p><img src="clip_image033.png" alt="声 紧 密 度 (closeness) 是 描 述 一 个 节 点 到 网 络 中 其 他 所  有 节 点 平 均 距 离 的 指 标 。 节 点 v 的 紧 密 度 定 义 如 下 ．  C  丿 ve  声 其 中 d 、 j 表 示 节 点 v 到 节 点 j 的 距 离 。  声 紧 密 度 测 度 衡 量 节 点 接 近 网 络 “ 中 心 ” 的 程 度 ， 紧 密  度 测 度 越 小 ， 节 点 越 接 近 中 心 。 "></p><h2 id="拓扑系数："><a href="#拓扑系数：" class="headerlink" title="拓扑系数："></a>拓扑系数：</h2><p><img src="clip_image034.png" alt="声 拓 扑 系 数 (topologycoefficient) 是 反 映 互 作 节 点 间  共 享 连 接 比 例 的 测 度 ， 节 点 v 的 拓 扑 系 数 T 、 可 以 定  义 为 ：  1  龙 其 中 ， q, 表 示 与 节 点 v 和 节 点 t 都 连 接 的 节 点 数 。  M 、 ： 为 所 有 与 节 点 v 分 享 邻 居 的 节 点 集 合 。  龙 拓 扑 系 数 反 映 了 节 点 的 邻 居 间 被 其 他 节 点 连 接 在 一  起 的 比 例 。 "></p><h2 id="直径："><a href="#直径：" class="headerlink" title="直径："></a>直径：</h2><p>网络的直径是指网络中任意两个连通节点间距离的最大值。</p><h2 id="连通度分布函数和聚类系数函数："><a href="#连通度分布函数和聚类系数函数：" class="headerlink" title="连通度分布函数和聚类系数函数："></a>连通度分布函数和聚类系数函数：</h2><p><img src="clip_image035.png" alt="声 除 了 平 均 连 通 度 以 外 ， 连 通 度 的 分 布 p (k) ，  k ： 1 ， 2 ” ． ． 是 另 一 种 重 要 描 述 网 络 连 通 性 的 属 性 。  声 而 类 似 的 针 对 网 络 还 可 以 建 立 起 随 连 通 度 变 化 的 聚  类 系 数 的 连 通 度 函 数 c (k) ， 这 个 函 数 被 定 义 为 当  函 数 自 变 量 等 于 k 时 ， c (k) 等 于 所 有 连 通 度 为 k 的  节 点 的 聚 类 系 数 的 平 均 值 。 "></p><p>C（k）连通度为k的节点聚类系数的平均值。</p><h2 id="无标度网络："><a href="#无标度网络：" class="headerlink" title="无标度网络："></a>无标度网络：</h2><ul><li>由于这类网络的节点连接度没有明显的特征长度，故称为无标(尺)度网络。</li><li>特征长度是属于分形几何的概念。对于某个物体, 特征长度通常是指该物体长度中有代表意义的长度, 如我们考察一个球体, 那么它的特征长度就是该球体的半径或直径。对于具有特征长度的物体, 只要其特征长度不变, 其性质就不会发生什么变化。</li><li>无标度网络中，大部分节点通过少数中心节点连接到一起，这就意味着节点在网络中的地位是不平等的，中心节点在连接网络完整性方面起更加重要的作用。</li><li>在无标度网络中大部分节点的连通度较低，但存在少数连通度非常高的节点使网络连接在一起。在这种网络中，平均连通度等标度已经不足以描述网络的规模和结构。</li></ul><h1 id="计算表观遗传学："><a href="#计算表观遗传学：" class="headerlink" title="计算表观遗传学："></a>计算表观遗传学：</h1><p>表观遗传学是研究不涉及DNA序列改变的情况下，DNA甲基化谱、染色质结构状态和基因表达谱在细胞代间传递的遗传现象的一门科学。</p><ul><li>预测的角度研究表观遗传现象。</li><li>应用生物信息学工具建立遗传与表观遗传调控网络。</li><li>表观遗传数据库。</li><li>建立在表观遗传机制基础的功能基因组及比较基因组研究。</li></ul><h2 id="DNA甲基化："><a href="#DNA甲基化：" class="headerlink" title="DNA甲基化："></a>DNA甲基化：</h2><ul><li>DNA甲基化是一种发生在DNA序列上的化学修饰，可以在转录及细胞分裂前后被稳定地遗传。DNA甲基化是重要的表观遗传代码。</li></ul><h2 id="CpG岛："><a href="#CpG岛：" class="headerlink" title="CpG岛："></a>CpG岛：</h2><ul><li>CpG岛是重要的调控元件,可用于新基因的发现。CpG岛通常是不被甲基化的，作为管家基因的重要标志之一。</li></ul><h2 id="测定蛋白修饰的高通量技术："><a href="#测定蛋白修饰的高通量技术：" class="headerlink" title="测定蛋白修饰的高通量技术："></a>测定蛋白修饰的高通量技术：</h2><p><img src="clip_image036.png" alt="检 测 技 术  定 量 性  分 辨 率 的 影 响  因 素  全 基 因 组 范 围  实 验 花 销  实 验 对 于 测 定  区 域 的 局 限 性  ChlP—chip  受 杂 交 效 率 影  染 色 质 长 度 及  探 针 密 度  多  局 限 于 预 设 的  基 因 组 区 域  Ch IP—SAGE  定 量  酶 切 效 率  多  受 酶 切 位 点  的 限 制  定 量  染 色 质 长 度 ， 测 序 深  度  少  可 覆 盖 大 部 分 基 因 组  区 域 "></p><h1 id="复杂疾病的分子特征与计算分析"><a href="#复杂疾病的分子特征与计算分析" class="headerlink" title="复杂疾病的分子特征与计算分析"></a>复杂疾病的分子特征与计算分析</h1><h2 id="复杂疾病的分子特征"><a href="#复杂疾病的分子特征" class="headerlink" title="复杂疾病的分子特征"></a>复杂疾病的分子特征</h2><ul><li>遗传和环境因素共同决定</li><li>多基因决定</li><li>单核苷酸多态性</li><li>连锁不平衡</li><li>单体型</li></ul><h2 id="常用复杂疾病相关数据库"><a href="#常用复杂疾病相关数据库" class="headerlink" title="常用复杂疾病相关数据库"></a>常用复杂疾病相关数据库</h2><ul><li>OMIM</li><li>dbGap</li><li>CGAP</li><li>HGMD</li><li>GeneCards</li></ul><h2 id="复杂疾病遗传学研究方法"><a href="#复杂疾病遗传学研究方法" class="headerlink" title="复杂疾病遗传学研究方法"></a>复杂疾病遗传学研究方法</h2><ul><li><p>连锁分析</p></li><li><ul><li>参数连锁分析</li><li>非参数连锁分析</li></ul></li><li><p>关联分析</p></li><li><ul><li>质量性状关联分析</li><li>数量性状关联分析</li></ul></li></ul><h1 id="非编码RNA与复杂疾病"><a href="#非编码RNA与复杂疾病" class="headerlink" title="非编码RNA与复杂疾病"></a>非编码RNA与复杂疾病</h1><ul><li>miRNA多态（miRNApolymorphisms）是影响miRNA功能的多态，可能发生在miRNA形成和行使功能的任一个过程，以插入、删除、扩增或染色体异位的形式出现，最终导致miRNA绑定位点或者功能的缺失（获得），是人类基因组一类新的功能多态。</li><li>不仅会影响miRNA的产生和表达，而且会影响miRNA与靶基因的结合从而影响靶基因的表达。</li></ul><h2 id="miRNA靶基因预测遵循的原则和基本步骤"><a href="#miRNA靶基因预测遵循的原则和基本步骤" class="headerlink" title="miRNA靶基因预测遵循的原则和基本步骤"></a>miRNA靶基因预测遵循的原则和基本步骤</h2><ul><li>miRNA的“种子区”与mRNA的3′UTR序列碱基互补</li><li>靶点在多物种间的序列保守性</li><li>miRNA与mRNA形成双链结构的热力学稳定性</li><li>靶基因二级结构和靶点外的序列对靶基因预测的影响</li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;简介&quot;&gt;&lt;a href=&quot;#简介&quot; class=&quot;headerlink&quot; title=&quot;简介&quot;&gt;&lt;/a&gt;简介&lt;/h2&gt;&lt;p&gt;本文是本人基于哈尔滨工业大学生物信息学整个课程的复习提纲&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;绪论&quot;&gt;&lt;a href=&quot;#绪论&quot; class=
      
    
    </summary>
    
    
      <category term="复习" scheme="https://www.rman.top/categories/%E5%A4%8D%E4%B9%A0/"/>
    
    
      <category term="生物信息" scheme="https://www.rman.top/tags/%E7%94%9F%E7%89%A9%E4%BF%A1%E6%81%AF/"/>
    
  </entry>
  
  <entry>
    <title>数据库复习提纲</title>
    <link href="https://www.rman.top/2020/07/02/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%8D%E4%B9%A0%E6%8F%90%E7%BA%B2/"/>
    <id>https://www.rman.top/2020/07/02/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%8D%E4%B9%A0%E6%8F%90%E7%BA%B2/</id>
    <published>2020-07-02T02:35:05.000Z</published>
    <updated>2026-03-13T01:50:06.922Z</updated>
    
    <content type="html"><![CDATA[<h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>本文是本人基于哈尔滨工业大学数据库系统整个课程的总结和复习提纲</p><hr><p>绪论</p><p>2020年6月4日</p><p>9:15</p><h2 id="数据库定义："><a href="#数据库定义：" class="headerlink" title="数据库定义："></a>数据库定义：</h2><p>·     相互关联关系的数据的集合</p><h2 id="Table"><a href="#Table" class="headerlink" title="Table:"></a>Table:</h2><p>·     Table中描述了一批互有关联关系的数据。</p><p><img src="http://image.rman.top/blog20200702104926.jpg" alt="Tab | e 的 构 成 暨 关 于 Tab | e 的 常 用 木 语  E  满 一 0 一 韉 一  蕓 吕  表 标 以 鵂 式 ）  名 “ 三 四 五 弄 四 ． 三 四  轰 内 客 （ 值 ）  关 壓  Table 中 描述 了 ． 批 相 有 关 联 的 数 据 = = k 系 "></p><h2 id="数据库构成："><a href="#数据库构成：" class="headerlink" title="数据库构成："></a>数据库构成：</h2><p>·     数据库（DB）：Database：一组关联关系数据集合</p><p>·     数据库管理系统（DBMS）：Database management system：管理数据的软件</p><p>·     数据库应用（DBAP）：Data base Application：完成某一功能的应用</p><p>·     数据库管理员（DBA）：Database Administrator：管理数据库的人</p><p>·     计算机基本系统</p><p><img src="https://i.loli.net/2020/07/02/6vhUEPkcMWLRXgO.jpg" alt="%&#39;/Databa  Tablet:  DBMS  Oracle  &amp;Sybase  YESQL server  DBAP 1  DBAP 2  DBAP 3  DBAP "></p><h2 id="实例化和抽象化："><a href="#实例化和抽象化：" class="headerlink" title="实例化和抽象化："></a>实例化和抽象化：</h2><p>把数据库的构成实例化成各个具体的应用。</p><h2 id="数据库管理系统的功能：（DBAP）"><a href="#数据库管理系统的功能：（DBAP）" class="headerlink" title="数据库管理系统的功能：（DBAP）"></a>数据库管理系统的功能：（DBAP）</h2><p>·     数据库定义：定义数据库中Table的名称、标题、标题内属性和属性值的要求</p><p>o  DBMS提供DDL语言给用户定义数据库</p><p>o  用户使用DDL创建表格式</p><p>o  DBMS解析DDL并执行</p><p>·     数据库执行：对表中数据库进行增删查改等操作</p><p>·     数据库控制：控制数据库数据的访问</p><p>o  DBMS提供DCL语言给用户</p><p>o  用户使用DCL进行控制</p><p>o  DBMS解析DCL</p><p>·     数据库维护：数据库转存，恢复，重组，性能监控</p><h2 id="数据库语言："><a href="#数据库语言：" class="headerlink" title="数据库语言："></a>数据库语言：</h2><p>·     DDL：用于定义数据格式</p><p>·     DML：数据库内容操作</p><p>·     DCL：数据库控制语言</p><p>·     数据库各种操作执行。</p><h2 id="DBMS功能："><a href="#DBMS功能：" class="headerlink" title="DBMS功能："></a>DBMS功能：</h2><p>·     语言编译器</p><p>·     查询优化</p><p>·     数据存储与索引</p><p>·     通讯控制</p><p>·     事物控制</p><p>·     故障恢复</p><p>·     安全性控制</p><p>·     完整性控制</p><p>数据库系统的标准结构</p><p>2020年6月4日</p><p>10:46</p><h2 id="DBMS的三个层次："><a href="#DBMS的三个层次：" class="headerlink" title="DBMS的三个层次："></a>DBMS的三个层次：</h2><p>·     外部层次（用户层次）：某一个用户能看到和处理的数据，全局数据的某一个部分</p><p>·     概念层次（逻辑层次）：从全局角度管理和理解数据</p><p>·     内部层次（物理层次）：存储在介质上的数据，存储路径、方式、索引等。</p><h2 id="模式（schema）："><a href="#模式（schema）：" class="headerlink" title="模式（schema）："></a>模式（schema）：</h2><p>·     对数据库中的数据进行一种结构性描述</p><p>·     所观察到的结构信息</p><h2 id="视图（view）："><a href="#视图（view）：" class="headerlink" title="视图（view）："></a>视图（view）：</h2><p>·     某一种表现形式下的数据</p><p><strong>外模式、外视图：用户所看到数据库的局部描述</strong></p><p><strong>概念模式、概念视图：从全局理解结构描述、关联约束</strong></p><p><strong>内模式、内视图：数据在介质上的结构描述，含有存储路径，存储方式，索引方式等。</strong></p><h2 id="两层映像："><a href="#两层映像：" class="headerlink" title="两层映像："></a>两层映像：</h2><p>·     <strong>E-C Mapping**</strong>：**将外模式映射为概念模式，支持数据视图向外部视图转换，便于用户观察</p><p>·     <strong>C-I Mapping**</strong>：**将概念模式映射成内模式，方便计算机的存储</p><p><img src="https://i.loli.net/2020/07/02/Rliz1Xr53xNKYa4.jpg" alt="user An  HL •OSL  Host  O•t• Sublanguage  HL •DSL  Mapping  Host Language  Data SubLangu•ge  (Ext•rnal) View A  Stor•d Databas••• "></p><p><strong>逻辑数据独立性：</strong>当概念模式变化时，可以不改外部模式，只改EC mapping</p><p><strong>物理数据独立性：</strong>当内部模式电话，可以不改概念模式，只改CI mapping</p><h2 id="数据模型：模式-与-模式的结构"><a href="#数据模型：模式-与-模式的结构" class="headerlink" title="数据模型：模式 与 模式的结构"></a>数据模型：模式 与 模式的结构</h2><p>·     规定模式统一方式的模型</p><p>·     数据模型是对模式本身的抽象，模式是对数据本身结构形式的抽象</p><p><strong>关系模型：</strong>所有的模式都可为抽象表的形式，而每一个具体的模式都拥有不同的列名的具体的表，这种表形式的数据有哪些操作和约束</p><p><img src="http://image.rman.top/blogclip_image008.jpg" alt="img"></p><p><strong>模式</strong>：对数据的抽象</p><p><strong>数据模型：</strong>对模式的抽象</p><h2 id="三大经典数据模型："><a href="#三大经典数据模型：" class="headerlink" title="三大经典数据模型："></a>三大经典数据模型：</h2><p>·     关系模型：<strong>表</strong>的形式组织</p><p>·     层次模型：<strong>树</strong>的形式组织数据</p><p>·     网状模型：<strong>图</strong>的形式组织数据</p><p><strong>第一代数据库：</strong>基于网状模型或者层次模型的数据库系</p><p><strong>第二代数据库：</strong>基于关系模型的数据库系统</p><p>关系模型的简述</p><p>2020年6月4日</p><p>11:13</p><h2 id="关系模型的构成："><a href="#关系模型的构成：" class="headerlink" title="关系模型的构成："></a>关系模型的构成：</h2><p>·     描述DB各种数据的节本结构形式</p><p>·     描述Table与Table之间可能发生的操作（关系运算）</p><p>·     秒后苏这些操作所应该遵循的约束条件（完整性约束）</p><h2 id="关系模型的三要素："><a href="#关系模型的三要素：" class="headerlink" title="关系模型的三要素："></a>关系模型的三要素：</h2><p>·     基本结构</p><p>·     基本操作：并、差、乘积、选择、投影、交、连接、除</p><p><img src="http://image.rman.top/blogclip_image010.jpg" alt="img"></p><p>·     完整性约束：实体完整性、参照完整性、用户自定义的完整性</p><h2 id="关系代数："><a href="#关系代数：" class="headerlink" title="关系代数："></a>关系代数：</h2><p>·     基于集合的运算，一次一个集合</p><p><img src="clip_image012.jpg" alt="img"></p><h2 id="关系的定义："><a href="#关系的定义：" class="headerlink" title="关系的定义："></a>关系的定义：</h2><p><img src="clip_image014.jpg" alt="img"></p><p><strong>域：</strong>定义列的取值范围。</p><p>·     一组值的集合，拥有相同数据类型</p><p>·     集合中元素的个数成为<strong>基数</strong></p><p><strong>笛卡尔积：</strong></p><p>·     一组域可能构成的全部的元素组合</p><p>·     笛卡尔积的每一个元素称为一个<strong>元组</strong></p><p><img src="clip_image016.jpg" alt="img"></p><p>·     <img src="clip_image018.jpg" alt="img"></p><p><strong>关系：</strong></p><p>·     一组域的笛卡尔积的子集</p><p><img src="clip_image020.jpg" alt="img"></p><p>·     笛卡尔积中具有<strong>某一方面意义</strong>的那些元组被称为一个<strong>关系</strong></p><p>·     由于关系的不同列可能来自同一个域，为了区分需要为每一个列起一个名字，该名字则为<strong>属性名</strong></p><p><strong>关系模式：</strong></p><p><img src="clip_image022.jpg" alt="img"></p><p>n：关系的<strong>度</strong></p><p>基数：关系中元组的数目</p><p><img src="clip_image024.jpg" alt="img"></p><h2 id="关系模式与关系："><a href="#关系模式与关系：" class="headerlink" title="关系模式与关系："></a>关系模式与关系：</h2><p>·     同一关系模式下可以由多种关系</p><p>·     关系模式是关系的结构，关系是关系模式某一个时刻的数据</p><p>·     关系模式是稳定的，而关系是某一个时刻的值，是随时间变化的</p><p><img src="clip_image026.jpg" alt="img"></p><h2 id="关系的特性："><a href="#关系的特性：" class="headerlink" title="关系的特性："></a>关系的特性：</h2><p>·     列是同质的：每一列的分量来自统一域，是同一类型的数据</p><p>·     不同的列可以来自同一个域，所以需要为每一个属性赋予不同的属性名</p><p>·     关系是以内容来区分的，而不是属性在关系的位置来区分：行列互换无关性</p><p>·     关系中不能有两个相同的元素，但是在现实应用中，Table可能不能完全遵守此特性。</p><h2 id="关系第一范式："><a href="#关系第一范式：" class="headerlink" title="关系第一范式："></a>关系第一范式：</h2><p>·     属性不可再分特性</p><p><img src="clip_image028.jpg" alt="img"></p><h2 id="候选键："><a href="#候选键：" class="headerlink" title="候选键："></a>候选键：</h2><p>·     关系中的一个属性组，其值能唯一标识一个元组，若工该属性组中去掉任何一个属性，它就不具有这个性质了，这样的属性组成为候选码（候选键）</p><p>·     关系中可能有多组候选码：（name, address）</p><h2 id="主码："><a href="#主码：" class="headerlink" title="主码："></a>主码：</h2><p>·     当有多个候选码时，可以选定一个作为主码</p><p>·     DBMS以主码为主要线索管理关系总的各个元组</p><h2 id="主属性："><a href="#主属性：" class="headerlink" title="主属性："></a>主属性：</h2><p>·     包含在任一候选码中的属性，被称为主属性，其他属性称为非主属性。</p><p>·     简单：候选码只包含一个属性</p><p>·     极端：所有属性构成主属性</p><h2 id="外码："><a href="#外码：" class="headerlink" title="外码："></a>外码：</h2><p>·     关系R中的一个属性组，他不是R的候选码，但它与另一个关系S的候选码相对应，则称这个属性组为R的<strong>外码</strong>或<strong>外键</strong></p><h2 id="关系模型的完整性："><a href="#关系模型的完整性：" class="headerlink" title="关系模型的完整性："></a>关系模型的完整性：</h2><p>·     <strong>主码完整性：</strong>关系主码中的属性值不能为空值</p><p>o  DBMS的结构保证</p><p>·     <strong>参照完整性：</strong>如果关系R1的外码与关系R2的主码相对应，则R1中的每一个元组的Fk值都等于R2中某一个元组的Pk值或者空</p><p>o  DBMS的结构保证</p><p>·     <strong>用户自定义完整性：</strong>用户根据具体环境定义的完整性约束</p><p>o  DBMS的支持用户自定义约束</p><p>关系代数</p><p>2020年6月4日</p><p>14:48</p><p>基于集合，提供了一系列的关系代数操作：并、差、笛卡尔积（广义积）</p><p>集合操作：并、交、差、笛卡尔积</p><p>纯关系操作：投影、选择、连接、除</p><p><strong>五种基本操作：</strong>并、差、广义积、选择、投影</p><p><img src="clip_image030.jpg" alt="img"></p><h1 id="关系代数的基本操作"><a href="#关系代数的基本操作" class="headerlink" title="关系代数的基本操作"></a>关系代数的基本操作</h1><h2 id="并相容性："><a href="#并相容性：" class="headerlink" title="并相容性："></a>并相容性：</h2><p>·     关系R和关系S存在相容性，当且仅当两个关系的对应属性域相同</p><h2 id="并操作："><a href="#并操作：" class="headerlink" title="并操作："></a>并操作：</h2><p>·     <img src="clip_image032.jpg" alt="img"></p><p>·     <img src="clip_image034.jpg" alt="img"></p><h2 id="差运算："><a href="#差运算：" class="headerlink" title="差运算："></a>差运算：</h2><p>·     <img src="clip_image036.jpg" alt="img"></p><h2 id="广义笛卡尔积："><a href="#广义笛卡尔积：" class="headerlink" title="广义笛卡尔积："></a>广义笛卡尔积：</h2><p>·     <img src="clip_image038.jpg" alt="img"></p><p><img src="clip_image040.jpg" alt="img"></p><h2 id="选择："><a href="#选择：" class="headerlink" title="选择："></a>选择：</h2><p>·     给定一个关系R，同时给定一个选择的条件condition，选择运算结果也是一个关系，他从关系R中选择出满足给定条件的元组构成。</p><p>·     <img src="clip_image042.jpg" alt="img"></p><h2 id="关系运算的优先级："><a href="#关系运算的优先级：" class="headerlink" title="关系运算的优先级："></a>关系运算的优先级：</h2><p><img src="clip_image044.jpg" alt="img"></p><h2 id="投影操作："><a href="#投影操作：" class="headerlink" title="投影操作："></a>投影操作：</h2><p>·     <img src="clip_image046.jpg" alt="img"></p><p>·     如果投影之后出现重复的元组，要去掉</p><p><strong>投影操作选的是列，选择操作选定是行</strong></p><h2 id="交操作："><a href="#交操作：" class="headerlink" title="交操作："></a>交操作：</h2><p>·     <img src="clip_image048.jpg" alt="img"></p><p>·     <img src="clip_image050.jpg" alt="img"></p><h2 id=""><a href="#" class="headerlink" title=""></a><img src="clip_image052.jpg" alt="img"></h2><p>·     <img src="clip_image054.jpg" alt="img"></p><p><img src="clip_image056.jpg" alt="img"></p><p>·     t是关系R中的元组，s是关系S中的元组</p><p>·     属性A和属性B有可比性。</p><p>·     <img src="clip_image058.jpg" alt="img"></p><p>·     <strong>更名操作：</strong>自己和自己连接，用于需要在一个表上进行多个条件过滤操作的时候</p><h2 id="等值连接："><a href="#等值连接：" class="headerlink" title="等值连接："></a>等值连接：</h2><p>·     <img src="clip_image060.jpg" alt="img"></p><h2 id="自然连接："><a href="#自然连接：" class="headerlink" title="自然连接："></a>自然连接：</h2><p>·     关系R和关系S的笛卡尔积中选取相同属性B上值相等的元组构成</p><p>·     <img src="clip_image062.jpg" alt="img"></p><p>·     两个关系肯定有相同的属性组B，所以是一种特殊的等值连接。所有的相同属性都必须相等。</p><p>·     <strong>在结果中去掉重复的属性列。**</strong>（会消除冗余）**</p><h2 id="关系代数的基本思路："><a href="#关系代数的基本思路：" class="headerlink" title="关系代数的基本思路："></a>关系代数的基本思路：</h2><p>·     检查是否涉及多个表，如果不涉及，则可以直接采用并、交、差、选择和投影</p><p>·     如果涉及多个表：</p><p>o  是否能使用自然连接</p><p>o  如果不能，则使用等值或者theta连接</p><p>o  如果还不能则使用广义笛卡尔积</p><p>·     连接完成之后，可以继续使用选择、投影等运算，即数据库的选投联操作</p><h2 id="除运算："><a href="#除运算：" class="headerlink" title="除运算："></a>除运算：</h2><p>·     用于求解：查询。。。。全部的/所有的</p><p>·     给定关系R和关系S，如果可以进行关系R与关系S的除运算，当且仅当：属性集S是属性R的真子集。</p><p>·     <img src="clip_image064.jpg" alt="img"></p><p>·     <img src="clip_image066.jpg" alt="img"></p><p>·     <img src="clip_image068.jpg" alt="img"></p><p>·     <img src="clip_image070.jpg" alt="img"></p><h2 id="外连接："><a href="#外连接：" class="headerlink" title="外连接："></a>外连接：</h2><p>·     两个关系R和S进行连接如果关系R或者S中的元组在另一个关系中找不到相匹配的元组，为了避免该元组信息丢失，从而将该元组与S或R中的假定存在的全为空值的元组进行连接，并放入关系结果中。</p><p>·     <img src="clip_image072.jpg" alt="img"></p><p>·     左外连接：自然连接+左侧失配</p><p>·     右外连接：自然连接+右侧失配</p><p>·     全外连接：自然连接+两侧表中失配的元组</p><p><img src="clip_image074.jpg" alt="img"></p><p>关系模型演算</p><p>2020年6月5日</p><p>10:39</p><p><strong>关系元组演算</strong>：以元组变量作为谓词变量的基本对象</p><p><strong>关系域演算</strong>：是以域变量作为谓词变量的基本对象</p><p><img src="clip_image076.jpg" alt="img"></p><p>上式表示：所有使谓词P为真的元组t的集合</p><p>·     t是元组变量</p><p>·     <img src="clip_image078.jpg" alt="img"></p><p>·     t[A]表示元组t的分量，即t在属性A上的值</p><p>·     P是与谓词逻辑相等的公式，P(t)表示以元组t为变量的公式</p><h2 id="P-t-递归构造："><a href="#P-t-递归构造：" class="headerlink" title="P(t)递归构造："></a>P(t)递归构造：</h2><p>·     <img src="clip_image080.jpg" alt="img"></p><p>·     <img src="clip_image082.jpg" alt="img"></p><p>·     <img src="clip_image084.jpg" alt="img"></p><p>·     <img src="clip_image086.jpg" alt="img"></p><p>·     <img src="clip_image088.jpg" alt="img"></p><p>·     <img src="clip_image090.jpg" alt="img"></p><p>·     <img src="clip_image092.jpg" alt="img"></p><p>·     <strong>公式只限于以上形式</strong></p><p><img src="clip_image094.jpg" alt="img"></p><p><img src="clip_image096.jpg" alt="img"></p><p><img src="clip_image098.jpg" alt="img"></p><p><img src="clip_image100.jpg" alt="img"></p><p><img src="clip_image102.jpg" alt="img"></p><p><img src="clip_image104.jpg" alt="img"></p><h2 id="元组演算的等价性："><a href="#元组演算的等价性：" class="headerlink" title="元组演算的等价性："></a>元组演算的等价性：</h2><p><img src="clip_image106.jpg" alt="img"></p><p><img src="clip_image108.jpg" alt="img"></p><p><img src="clip_image110.jpg" alt="img"></p><h2 id="-1"><a href="#-1" class="headerlink" title=" "></a> </h2><h2 id="元组演算公式实现关系代数："><a href="#元组演算公式实现关系代数：" class="headerlink" title="元组演算公式实现关系代数："></a>元组演算公式实现关系代数：</h2><p><img src="clip_image112.jpg" alt="img"></p><h2 id="关系域演算："><a href="#关系域演算：" class="headerlink" title="关系域演算："></a>关系域演算：</h2><p><img src="clip_image114.jpg" alt="img"></p><p><img src="clip_image116.jpg" alt="img"></p><p>·     <img src="clip_image118.jpg" alt="img"></p><p>·     <img src="clip_image120.jpg" alt="img"></p><p>·     <img src="clip_image122.jpg" alt="img"></p><p>·     <img src="clip_image124.jpg" alt="img"></p><p>·     <img src="clip_image126.jpg" alt="img"></p><p>·     <img src="clip_image128.jpg" alt="img"></p><p>·     <img src="clip_image130.jpg" alt="img"></p><p>域是某一列的取值范围，元组则是一个具体的关系行</p><p>元组是一行行的扫描，域是以列为单位，对每一个列进行扫描</p><p>元组演算是以元组为变量，以元组为基本单位，先找到元组，然后再找到元组分量，进行谓词判断。</p><p><img src="clip_image132.jpg" alt="img"></p><h2 id="QBE操作框架："><a href="#QBE操作框架：" class="headerlink" title="QBE操作框架："></a>QBE操作框架：</h2><p><img src="clip_image134.jpg" alt="img"></p><p>示例元素P，表示输出的集合标志，可以用.X,.Y来进行其子集的过滤</p><p><img src="clip_image136.jpg" alt="img"></p><p><img src="clip_image138.jpg" alt="img"></p><h2 id="关系运算的安全性：不产生无限关系和无穷验证的运算被称为是安全的"><a href="#关系运算的安全性：不产生无限关系和无穷验证的运算被称为是安全的" class="headerlink" title="关系运算的安全性：不产生无限关系和无穷验证的运算被称为是安全的"></a>关系运算的安全性：不产生无限关系和无穷验证的运算被称为是安全的</h2><p>\1.  关系代数是一种集合运算，是安全的</p><p><img src="clip_image140.jpg" alt="img"></p><p>\2.  关系演算不一定是安全的</p><p><img src="clip_image142.jpg" alt="img"></p><h2 id="安全约束有限集合DOM："><a href="#安全约束有限集合DOM：" class="headerlink" title="安全约束有限集合DOM："></a>安全约束有限集合DOM：</h2><p>·     <img src="clip_image144.jpg" alt="img"></p><p>·     DOM只是一个约束谓词的范围，不是最小集合。</p><h2 id="安全元组演算表达式："><a href="#安全元组演算表达式：" class="headerlink" title="安全元组演算表达式："></a>安全元组演算表达式：</h2><p>·     <img src="clip_image146.jpg" alt="img"></p><p><img src="clip_image148.jpg" alt="img"></p><p>·     <img src="clip_image150.jpg" alt="img"></p><p><img src="clip_image152.jpg" alt="img"></p><p>·     <img src="clip_image154.jpg" alt="img"></p><p><img src="clip_image156.jpg" alt="img"></p><h2 id="三种关系运算："><a href="#三种关系运算：" class="headerlink" title="三种关系运算："></a>三种关系运算：</h2><p>·     关系代数—以集合为对象的操作，集合到集合</p><p>·     元组演算—以元组为对象的操作，取出关系的每一个元组进行验证</p><p>·     域演算—以域变量为对象的操作思维，取出域的每一个变量进行验证看是否满足条件</p><p>·     三种运算是等价的</p><p>·     三种运算都是非过程性的：域&gt;元组&gt;关系</p><p>·     三种运算都是抽象的，但都是衡量数据库语言的完备性的基础</p><p>SQL语言概述</p><p>2020年6月5日</p><p>16:11</p><h2 id="DDL"><a href="#DDL" class="headerlink" title="DDL:"></a>DDL:</h2><p>·     Create</p><p>·     Alter</p><p>·     Drop</p><h2 id="DML"><a href="#DML" class="headerlink" title="DML:"></a>DML:</h2><p>·     Insert</p><p>·     Delete</p><p>·     Update</p><p>·     Select</p><h2 id="DCL"><a href="#DCL" class="headerlink" title="DCL:"></a>DCL:</h2><p>·     Grant</p><p>·     Revoke</p><p>交互式SQL-&gt;嵌入式SQL-&gt;动态SQL</p><p>理解查询需求-&gt;用SQL精确表示</p><h2 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h2><p>Create database database name</p><h2 id="创建Table："><a href="#创建Table：" class="headerlink" title="创建Table："></a>创建Table：</h2><p>Create table 表名（列名 数据类型 [Primary key|Unique] [Not null] [, 列名 数据类型 [Not null]])</p><p>·     Primary Key：主键约束，一个表稚嫩给一个</p><p>·     Unique：候选键约束，可以有多个</p><p>·     Not null：非空约束，不允许为空</p><p><strong>数据类型：</strong></p><p><img src="clip_image158.jpg" alt="img"></p><p><img src="clip_image160.jpg" alt="img"></p><h2 id="Insert："><a href="#Insert：" class="headerlink" title="Insert："></a>Insert：</h2><p>Insert into 表名[(列名 [, 列名]…] </p><p>Values (值, [, 值],…)</p><p><img src="clip_image162.jpg" alt="img"></p><p><img src="clip_image164.jpg" alt="img"></p><h2 id="Select"><a href="#Select" class="headerlink" title="Select:"></a>Select:</h2><p>Select 列名 [[, 列名]..]</p><p> from 表名</p><p> [where 条件</p><p><img src="clip_image166.jpg" alt="img"></p><p><strong>唯一性：</strong></p><p>通过关键词<strong>DISTINCT</strong>保证结果的唯一性</p><p><strong>排序问题：</strong></p><p>使用order by 列名 [asc|desc]</p><p><strong>模糊查询：</strong></p><p>列名 [not] like “字符串”</p><p>·     % 匹配零个或者多个字符</p><p>·     _ 匹配单个字符</p><p>·     \ 转义符</p><p><img src="clip_image168.jpg" alt="img"></p><h2 id="多表联合查询："><a href="#多表联合查询：" class="headerlink" title="多表联合查询："></a>多表联合查询：</h2><p><strong>多表笛卡尔积</strong></p><p>Select 列名 [[,列名]..]</p><p>From 表名1，表名2</p><p>Where 检索条件;</p><p><img src="clip_image170.jpg" alt="img"></p><p><strong>重名处理：</strong></p><p> select 列名 as 列别名 [[, 列名 as 列别名]…]</p><p> from 表名 as 表别名1, 表名2 as 表别名2</p><p>Where 检索条件。</p><p><img src="clip_image172.jpg" alt="img"></p><h2 id="批量增加数据命令："><a href="#批量增加数据命令：" class="headerlink" title="批量增加数据命令："></a>批量增加数据命令：</h2><p>Insert into 表名[(列名 [, 列名]…] </p><p>子查询</p><p><img src="clip_image174.jpg" alt="img"></p><h2 id="Delete："><a href="#Delete：" class="headerlink" title="Delete："></a>Delete：</h2><p>Delete from 表名 [where 条件]</p><p><img src="clip_image176.jpg" alt="img"></p><h2 id="Update"><a href="#Update" class="headerlink" title="Update:"></a>Update:</h2><p>Update 表名</p><p>Set 列名=表达式| (子查询)</p><p>[[, 列名=表达式|子查询]]</p><p>[where 条件表达式]</p><p><img src="clip_image178.jpg" alt="img"></p><h2 id="Alter："><a href="#Alter：" class="headerlink" title="Alter："></a>Alter：</h2><p>Alter table tablename</p><p>[add {column datatype}]</p><p>[drop {约束}]</p><p>[modify {column datatype, ….]</p><p><img src="clip_image180.jpg" alt="img"></p><h2 id="Drop："><a href="#Drop：" class="headerlink" title="Drop："></a>Drop：</h2><p>Drop table 表名</p><p><img src="clip_image182.jpg" alt="img"></p><p>Drop database 数据库名</p><p>SQL复杂查询</p><p>2020年6月8日</p><p>11:30</p><h2 id="not-in-子查询："><a href="#not-in-子查询：" class="headerlink" title="(not) in 子查询："></a>(not) in 子查询：</h2><p>表达式 [not] in （子查询）</p><p><img src="clip_image184.jpg" alt="img"></p><p><strong>非相关子查询：内层查询和外层查询独立</strong></p><p><img src="clip_image186.jpg" alt="img"></p><p><strong>相关子查询：内层查询需要外层查询的变量</strong></p><p><img src="clip_image188.jpg" alt="img"></p><h2 id="-2"><a href="#-2" class="headerlink" title=""></a><img src="clip_image190.jpg" alt="img"></h2><p>表示与“某一个”比较还是“所有”比较</p><p><img src="clip_image192.jpg" alt="img"></p><p><img src="clip_image194.jpg" alt="img"></p><p>与Not in等价的是&lt;&gt; all</p><p><img src="clip_image196.jpg" alt="img"></p><h2 id="Exists子查询："><a href="#Exists子查询：" class="headerlink" title="Exists子查询："></a>Exists子查询：</h2><p>[not] Exists （子查询）</p><p>子查询结果中有无元组存在</p><p><img src="clip_image198.jpg" alt="img"></p><p><img src="clip_image200.jpg" alt="img"></p><h2 id="结果计算："><a href="#结果计算：" class="headerlink" title="结果计算："></a>结果计算：</h2><p>Select from where语句中，select子句后面不仅可以是列名，也可以是一些计算表达式或者聚集函数。</p><p>使用计算表达式作为一列</p><p><img src="clip_image202.jpg" alt="img"></p><p><strong>聚集函数：</strong></p><p>SQL提供了五个作用在简单列值集合上的内置聚集函数，分别是：</p><p>COUNT、SUM、AVG、MAX、MIN</p><p><img src="clip_image204.jpg" alt="img"></p><p><img src="clip_image206.jpg" alt="img"></p><h2 id="分组："><a href="#分组：" class="headerlink" title="分组："></a>分组：</h2><p>SQL可以将检索到的元组按照某一条件进行分类，具有相同条件值的元组划分到一个组合</p><p>或一个集合中。</p><p>Group by (…)</p><p><img src="clip_image208.jpg" alt="img"></p><p><strong>分组过滤：</strong></p><p>若要对集合进行分组条件过滤，即满足条件的集合、分组留下，不满足的去掉。</p><p><strong>Having</strong> <strong>子句，又称为分组过滤子句，需要group by子句的支持。</strong></p><p><img src="clip_image210.jpg" alt="img"></p><p><strong>对分组检查用Having子句，对每一行检查用where子句</strong></p><h2 id="union-intersect-except"><a href="#union-intersect-except" class="headerlink" title="union|intersect|except"></a>union|intersect|except</h2><p>(子查询) {union [ALL]| intersect [ALL] | exccept [ALL] 子查询} </p><p>默认自动删除重复元组，若要保留重复元组，则要带ALL</p><p><img src="clip_image212.jpg" alt="img"></p><h2 id="空值的处理"><a href="#空值的处理" class="headerlink" title="空值的处理"></a>空值的处理</h2><p>空值的检测： is [not] null</p><p>测试指定的列是否是空值。</p><p><img src="clip_image214.jpg" alt="img"></p><p>·     空值不满足除了 is [not] null 之外任何查找条件</p><p>·     如果null 参与算数运算，则该算数表达式的值为null</p><p>·     如果null 参与比较运算，则结果可以视false</p><p>·     如果null参与聚集运算，那么除了count(*)之外的其他聚集函数都忽略null</p><h2 id="连接运算："><a href="#连接运算：" class="headerlink" title="连接运算："></a>连接运算：</h2><p><img src="clip_image216.jpg" alt="img"></p><p>连接类型：</p><p>·     Inner join：</p><p>·     Left outer join</p><p>·     Right outer join</p><p>·     Full outer join</p><p>连接条件：</p><p>·     Natural：自然连接</p><p>·     On &lt;连接条件&gt;：theta连接，满足on的的条件</p><p>·     Using (col_1,col_2,… col_n)：col1-coln是两个连接关系的公共属性的子集，元组在col1-coln上的取值相等，且col1-coln只出现一次。</p><h2 id="视图："><a href="#视图：" class="headerlink" title="视图："></a>视图：</h2><p>对应概念模式的数据在SQL中被称为基本表(Table)，而对应外模式的数据被称为视图(view),视图不仅包含外模式，而且包含其E-C映像。</p><p>Create view view_name [(列名 [, 列名]…)]</p><p> as 子查询 [with check option]</p><p><img src="clip_image218.jpg" alt="img"></p><p><strong>使用视图：</strong></p><p>定义好视图，可以像table一样，在SQL各种语句中使用</p><p><strong>视图的更新：</strong></p><p>视图不保存数据，所以对视图的更新最终都要反映到对基本表的更新上，而有时视图的定义是不可逆的，比如使用聚集函数</p><p>·     包含聚集函数，不能更新</p><p>·     使用unique，distinct不能更新</p><p>·     使用group by 不能更新</p><p>·     使用计算表达式，不能更新</p><p>·     视图由单个表构成，<strong>但没有主键</strong>，不能更新</p><p>数据库完整性的概念及分类</p><p>2020年6月8日</p><p>16:37</p><h2 id="数据库完整性："><a href="#数据库完整性：" class="headerlink" title="数据库完整性："></a>数据库完整性：</h2><p><strong>是指DBMS应保证DB在任何情况下的正确性、有效性和一致性</strong></p><p>·     广义完整性：语义完整性、并发控制、安全控制、DB故障恢复</p><p>·     狭义完整性：语义完整性、DBMS通常有专门的完整性管理机制与程序来处理语义完整性问题。</p><h2 id="关系模型中的完整性要求："><a href="#关系模型中的完整性要求：" class="headerlink" title="关系模型中的完整性要求："></a>关系模型中的完整性要求：</h2><p>·     实体完整性</p><p>·     参照完整性</p><p>·     用户自定义完整性</p><p><img src="clip_image220.jpg" alt="img"></p><h2 id="完整性约束条件："><a href="#完整性约束条件：" class="headerlink" title="完整性约束条件："></a>完整性约束条件：</h2><p><img src="clip_image222.jpg" alt="img"></p><p>O: 数据集合，约束的对象</p><p>P: 谓词条件，什么样的约束</p><p>A: 触发条件，什么时候检查</p><p>R: 响应动作，不满足的情况怎么办。</p><h2 id="按约束对象分类："><a href="#按约束对象分类：" class="headerlink" title="按约束对象分类："></a>按约束对象分类：</h2><p>·     域完整性约束条件</p><p>o  施加在某一列上，对给定列上所有要更新的某一后选值是否可以接受进行约束条件判断</p><p>·     关系完整性约束条件</p><p>o  施加在Table上，对给定的table上所有要更新的某一候选元组是否可以接受进行约束条件判断，或者是对一个关系中的若干元组和另一个关系中的若干元组之间的联系进行约束条件判断。</p><h2 id="按约束来源分类："><a href="#按约束来源分类：" class="headerlink" title="按约束来源分类："></a>按约束来源分类：</h2><p>·     结构约束：</p><p>o  来自于模型的约束，比如函数依赖约束，主键约束，外键约束</p><p>·     内容约束：</p><p>o  来自于用户的约束，如用户自定义完整性，关心元组或属性的取值范围。</p><h2 id="按约束状态分类："><a href="#按约束状态分类：" class="headerlink" title="按约束状态分类："></a>按约束状态分类：</h2><p>·     静态约束：</p><p>o  要求DB在任一时刻都应该满足约束</p><p>·     动态约束</p><p>o  要求DB从一个状态到另一状态时满足的约束</p><h2 id="SQL语言的完整性："><a href="#SQL语言的完整性：" class="headerlink" title="SQL语言的完整性："></a>SQL语言的完整性：</h2><p>·     静态约束：</p><p>o  列完整性：域完整性</p><p>o  表完整性：关系完整性约束</p><p>·     动态约束：</p><p>o  触发器</p><p><img src="clip_image224.jpg" alt="img"></p><h2 id="Create-Table-定义完整性约束："><a href="#Create-Table-定义完整性约束：" class="headerlink" title="Create Table 定义完整性约束："></a>Create Table 定义完整性约束：</h2><p><img src="clip_image226.jpg" alt="img"></p><h2 id="Col-constr列约束"><a href="#Col-constr列约束" class="headerlink" title="Col_constr列约束"></a>Col_constr列约束</h2><p><img src="clip_image228.jpg" alt="img"></p><p><img src="clip_image230.jpg" alt="img"></p><h2 id="Table-constr-表约束"><a href="#Table-constr-表约束" class="headerlink" title="Table_constr 表约束"></a>Table_constr 表约束</h2><p><img src="clip_image232.jpg" alt="img"></p><p><img src="clip_image234.jpg" alt="img"></p><p><img src="clip_image236.jpg" alt="img"></p><p><strong>check**</strong>中的条件可以是select-From-Where内任何的Where 后的语句，包含子查询**</p><p><img src="clip_image238.jpg" alt="img"></p><p><strong>列约束只涉及到一列，表约束涉及到多个列</strong></p><h2 id="撤销、增加约束："><a href="#撤销、增加约束：" class="headerlink" title="撤销、增加约束："></a>撤销、增加约束：</h2><p><img src="clip_image240.jpg" alt="img"></p><p><img src="clip_image242.jpg" alt="img"></p><h2 id="断言："><a href="#断言：" class="headerlink" title="断言："></a>断言：</h2><p>·     断言是一个谓词表达式，它表达了希望数据库总能满足的条件</p><p>·     表约束和列约束就是一些特殊的断言</p><p>Create assertion <assertion-name> CHECK <predicate></p><p>·     当一个断言创建后，系统将检查其有效性，并且在每一个更新中测试更新是否违反该断言。</p><p><img src="clip_image244.jpg" alt="img"></p><h2 id="触发器："><a href="#触发器：" class="headerlink" title="触发器："></a>触发器：</h2><p>·     当某一事件发生的时候，对该事件产生的结果，检查条件，如果满足条件，则执行后面的程序段，条件或程序段中引用的变量可用coor_name_def</p><p><img src="clip_image246.jpg" alt="img"></p><p><strong>事件：Before| After {Insert|UPdate|Delete}</strong></p><p>·     当一个事件发生之前或之后，after触发</p><p>·     操作发生，执行触发器操作需要处理的组值，更新之前或更新之后的值，这两个值由corr_name_def的使用来区分</p><p>Corr_name_def的定义：</p><p><img src="clip_image248.jpg" alt="img"></p><p><img src="clip_image250.jpg" alt="img"></p><p><img src="clip_image252.jpg" alt="img"></p><h2 id="数据库的安全性："><a href="#数据库的安全性：" class="headerlink" title="数据库的安全性："></a>数据库的安全性：</h2><p>·     私人信息保护</p><p>·     信息公开和非公开</p><p>·     最小数据访问策略</p><p>·     数据安全级别</p><p>·     数据库系统的安全级别</p><h2 id="DBMS的安全机制："><a href="#DBMS的安全机制：" class="headerlink" title="DBMS的安全机制："></a>DBMS的安全机制：</h2><p>·     自主安全性控制：存取控制</p><p>o  权限在用户之间传递，使用户自主管理数据库安全性</p><p>·     强制安全性：</p><p>o  对用户进行强制分类，使得不同类别用户能够访问不同类别的数据</p><p>·     推断控制机制</p><p>o  防止通过历史信息，推断出不该被知道的信息</p><p>o  防止通过公开信息推断出私密信息</p><p>·     数据加密存储机制</p><h2 id="数据库的自主安全控制："><a href="#数据库的自主安全控制：" class="headerlink" title="数据库的自主安全控制："></a>数据库的自主安全控制：</h2><p>·     自主安全性是通过授权机制来实现的</p><p>·     DBMS允许用户自定义一些安全性控制规则</p><p>·     当有DB访问操作时，DBMS自动按照安全性控制规则进行检查，检查通过则允许访问，不通过则不允许。</p><p><img src="clip_image254.jpg" alt="img"></p><p>AccessRule ::= (S, O, t, P)</p><p>·     S: 请求主体</p><p>·     O：访问对象</p><p>·     t：访问权利</p><p>·     P：谓词，</p><p>理解：S这个用户，对O这个访问对象，在P这个条件下，拥有t这个权利。</p><p><img src="clip_image256.jpg" alt="img"></p><h3 id="控制方法："><a href="#控制方法：" class="headerlink" title="控制方法："></a>控制方法：</h3><p><strong>1.</strong>  <strong>存储矩阵：</strong></p><p><img src="clip_image258.jpg" alt="img"></p><p><strong>2.</strong>  <strong>视图：</strong></p><p>·     <strong>通过视图，可以限制用户对于关系中某些数据项的存取</strong></p><p>·     <strong>通过视图，可以将数据访问对象与谓词结合起来，限制用户对关系中某些元组的存取。</strong></p><p>·     <strong>在视图定义之后便成为了一个新的数据对象</strong></p><p>·     <strong>视图可以定义条件P。</strong></p><p><img src="clip_image260.jpg" alt="img"></p><h2 id="SQL的关系级别："><a href="#SQL的关系级别：" class="headerlink" title="SQL的关系级别："></a>SQL的关系级别：</h2><p>\1.  select：读</p><p>\2.  Modify：更新</p><p>\3.  Create：创建</p><p>Grant {all PRIVILEGES| privilege, {privilege…}}</p><p>On [TABLE] tablename | viewname</p><p>To {public |user-id {, user-id…}}</p><p>[with GRANT Option]</p><p>·     User-id: 用户账号，由DBA创建的合法账户</p><p>·     Public：允许所有有效用户使用授权的权利</p><p>·     Privilege：</p><p>·     SELECT| INSERT| UPDATE| DELETE| ALL PRIVILEDGES</p><h2 id="收回权力："><a href="#收回权力：" class="headerlink" title="收回权力："></a>收回权力：</h2><p>·     Revoke {all privileges | priv {, priv}} on tablename |viewname FROM {public |user {, user…}}</p><h2 id="自主安全性控制："><a href="#自主安全性控制：" class="headerlink" title="自主安全性控制："></a>自主安全性控制：</h2><p>·     水平传播：授权者再授权</p><p>·     垂直传播：授权者传播给被授权者，再传播给另一个被授权用户</p><p>如果用户从多个用户处获得授权，则当其中某一个用户被收回权利时，该用户可能还存在其他用户授予的权利。</p><h2 id="强制安全性机制："><a href="#强制安全性机制：" class="headerlink" title="强制安全性机制："></a>强制安全性机制：</h2><p>·     强制安全性通过对数据对象进行安全性分级</p><p>·     从而实现不同级别用户访问不同级别数据的一种机制</p><h3 id="访问规则："><a href="#访问规则：" class="headerlink" title="访问规则："></a>访问规则：</h3><p>·     用户s不能读取数据对象O，除非Level(S) &gt;= Level(O)</p><p>·     用户s不能写数据对象，除非Level(S) &lt;= Level(O) ：高级别用户不允许改低级别数据，如果高级别用户进行修改了，低级别用户就无法读取了。</p><h2 id="安全性级别："><a href="#安全性级别：" class="headerlink" title="安全性级别："></a>安全性级别：</h2><p><img src="clip_image262.jpg" alt="img"></p><p>关系中的每一个元组都带有安全性的分级</p><p>嵌入式SQL语言</p><p>2020年6月16日</p><p>8:51</p><p>以下嵌入式SQL以C语言为例</p><h2 id="变量的声明与使用："><a href="#变量的声明与使用：" class="headerlink" title="变量的声明与使用："></a>变量的声明与使用：</h2><p><img src="clip_image264.jpg" alt="img"></p><p>Exec sql select Sname, Sage into :vSname, :vSage from Student where Sname=:specName</p><h2 id="程序与数据库的连接和断开："><a href="#程序与数据库的连接和断开：" class="headerlink" title="程序与数据库的连接和断开："></a>程序与数据库的连接和断开：</h2><p>Exec sql connect to target-server as connect-name user user-name</p><p>Exec sql disconnect connect-name</p><h2 id="SQL执行的提交与撤销："><a href="#SQL执行的提交与撤销：" class="headerlink" title="SQL执行的提交与撤销："></a>SQL执行的提交与撤销：</h2><p>Exec sql commit work</p><p>Exec sql rollback work</p><h2 id="事务的执行："><a href="#事务的执行：" class="headerlink" title="事务的执行："></a>事务的执行：</h2><p>是一个存取或者改变数据库内容的程序的一次执行，或者说一条或多条SQL语句的一次执行被看作是一个事务。</p><p>Begin Transaction</p><p>Exec sql</p><p>….</p><p>Exec sql commit work | exec sql rollback work</p><p>End Transaction</p><p>一个事务的结束是需要程序员通过commit或rollback确认。</p><p><img src="clip_image266.jpg" alt="img"></p><h2 id="事务的特性：ACID"><a href="#事务的特性：ACID" class="headerlink" title="事务的特性：ACID"></a>事务的特性：ACID</h2><p>·     原子特性Atomicity：DBMS能够保证事务的一组更新操作是原子不可分的，对DB而言，要么全做，要么全不做</p><p>·     一致性Consistency：DBMS保证事务的操作状态是正确的，符合一致性操作规则</p><p>·     隔离性Isolation：DBMS保证并发执行的多个事务之间互相不受影响，例如事务T1和T2即使并发执行，也相当于或者先执行了T1再执行了T2，或者反之</p><p>·     持久性Durability：DBMS保证已经提交事务的影响是持久的，被撤销事务的影响是可恢复的。</p><p>具有ACID特性的若干数据库基本操作的组合被称为事务。</p><h2 id="检索单行结果与多行结果获取："><a href="#检索单行结果与多行结果获取：" class="headerlink" title="检索单行结果与多行结果获取："></a>检索单行结果与多行结果获取：</h2><p>单行结果可以直接将结果传送到宿主变量中</p><p><img src="clip_image268.jpg" alt="img"></p><p>多行结果，则需要使用游标Cursor</p><p>·     游标是指向某检索记录集的指针</p><p>·     通过移动指针，每次读一行，处理一行，再读一行，直至处理完毕。</p><h3 id="游标Cursor："><a href="#游标Cursor：" class="headerlink" title="游标Cursor："></a>游标Cursor：</h3><p>游标需要先定义再使用，接着一条条处理，最后再关闭</p><p>Exec sql declare cur_student cursor for </p><p>Select Sno, Sname, Sclass from Student where Sclass=’035101’</p><p>Exec sql open cur_sutdent</p><p>Exec sql fetch cur_student into :vSno, :vSname, :vSclass</p><p>游标可以定义一次，多次打开，多次关闭。</p><h3 id="可滚动游标Cursor"><a href="#可滚动游标Cursor" class="headerlink" title="可滚动游标Cursor"></a>可滚动游标Cursor</h3><p>在fetch的时候可以自定义移动的行。</p><p><img src="clip_image270.jpg" alt="img"></p><h2 id="数据库记录的删除："><a href="#数据库记录的删除：" class="headerlink" title="数据库记录的删除："></a>数据库记录的删除：</h2><p>Exec SQL DELETE FROM tablename [corr_name] where search_condition | Where current of cursor_name</p><p><img src="clip_image272.jpg" alt="img"></p><h2 id="数据库记录的更新："><a href="#数据库记录的更新：" class="headerlink" title="数据库记录的更新："></a>数据库记录的更新：</h2><p><img src="clip_image274.jpg" alt="img"></p><h2 id="数据记录的插入："><a href="#数据记录的插入：" class="headerlink" title="数据记录的插入："></a>数据记录的插入：</h2><p><img src="clip_image276.jpg" alt="img"></p><h2 id="状态错误捕获："><a href="#状态错误捕获：" class="headerlink" title="状态错误捕获："></a>状态错误捕获：</h2><p>·     设置SQL通信区</p><p>·     设置状态捕获语句</p><p>·     状态处理语句</p><h2 id="SQLCA："><a href="#SQLCA：" class="headerlink" title="SQLCA："></a>SQLCA：</h2><p>·     SQLCA是被声明的C语言结果形式的内存区，用于和SQL进行数据交互</p><p><strong>状态捕获语句：</strong></p><p>Exec sql whenever condition action</p><p>Whenever 是一个条件陷阱，该条语句会对后面所有由Exec SQL语句所引起的对数据库系统调用自动检查他是否满足条件condition</p><p>·     SQLERROR：检查是否有SQL语句出错</p><p>·     NOTFOUND：执行某一SQL语句后，没有相应的结果记录出现</p><p>·     SQLWARNING：不是错误，但是要引起注意</p><p>如果满足condition，则要进行一些动作：</p><p>·     CONTINUE：忽略条件或错误，继续执行</p><p>·     GOTO标号：转移到标号所指示的语句，去进行相应的处理</p><p>·     STOP：终止程序运行，撤销当前的工作、断开数据库的连接</p><p>·     DO函数、CALL函数：调用宿主程序的函数进行处理，函数返回后从引发该condition exec SQL语句之后的语句继续执行。</p><p>状态捕获的Whenever的作用范围是其后的所有Exec SQL语句，一直到程序中出现另一条相同条件的Whenever语句为止，后面的将覆盖前面的</p><p>动态SQL</p><p>2020年6月16日</p><p>11:03</p><p>动态SQL特点：SQL语句可以在程序中动态构造，形成一个字符串，如上例的sqltext，然后再交给DBMS执行，交给DBMS执行时仍旧可以传递变量。</p><h2 id="动态SQL执行方式："><a href="#动态SQL执行方式：" class="headerlink" title="动态SQL执行方式："></a>动态SQL执行方式：</h2><p>·     立即执行语句：</p><p>o  Exec sql execute immediate :host-variable;</p><p>·     Prepare-Execute-Using语句：</p><p>o  Prepare语句先编译，编译后的SQL语句运行动态参数，EXECUTE语句，用USING语句将动态参数值传递给编译好的SQL语句</p><p>o  EXEC SQL PREPARE sql_temp FROM :host-variable</p><p>o  EXEC SQL EXECUTE sql_temp USING :cond-variable</p><p>·     <img src="clip_image278.jpg" alt="img"></p><h2 id="数据字典："><a href="#数据字典：" class="headerlink" title="数据字典："></a>数据字典：</h2><p>·     是系统的一些表或者视图的集合，这些表或视图存储了数据库中各类对象的定义信息，这些对象包括用Create定义的表、列、索引、视图、权限、约束等，这些信息又称为数据库的元数据—关于数据的数据</p><p><strong>数据字典的内容构成：information_schema?</strong></p><p>·     数据字典常存储的是数据库和表的元数据，即模式本身的信息</p><p>o  与关系相关的信息</p><p>·     关系名字</p><p>·     每一个关系的属性名及其类型</p><p>·     视图的名字及其定义</p><p>·     完整性约束</p><p>o  账户信息</p><p>o  统计与描述的信息</p><p>o  物理文件组织信息</p><p>·     关系如何存储</p><p>·     关系的物理位置</p><p><strong>数据字典的结构：</strong></p><p><img src="clip_image280.jpg" alt="img"></p><p><strong>模式的含义：</strong></p><p>·     模式指的是某一用户所设计和使用的表、索引和其他与数据库有关对象的集合，因此完整的表名应该是：<strong>模式名：表名</strong>，这样可以做到允许不同用户使用相同的表名而不会混淆。</p><p><img src="clip_image282.jpg" alt="img"></p><p><strong>SQLDA**</strong>：**</p><p>·     是一个描述符区域，是一个内存数据结构，内科装载关系模式的定义信息，如列的数目，每一列的名字和类型等等。</p><p>·     通过读取SQLDA信息可以进行更为复杂的动态SQL的处理。</p><p>·     不同的DBMS提供的SQLDA格式并不是一致的。</p><p><strong>ODBC**</strong>：**</p><p>·     是一种标准的，不同的应用程序与不同数据库服务器之间通讯的标准。</p><p>·     应用程序调用ODBCAPI时，ODBC API会调用具体的DBMS Driver库函数，交由DBMS Driver库函数则与数据库服务器通讯，执行相应的请求动作，并返回检索结果。</p><p><strong>JDBC**</strong>：**</p><p>·     Java版本的ODBC</p><p>数据建模与数据库设计</p><p>2020年6月16日</p><p>16:33</p><h2 id="数据模型和概念模型："><a href="#数据模型和概念模型：" class="headerlink" title="数据模型和概念模型："></a>数据模型和概念模型：</h2><p>·     数据模型：数据的存储模型，存储于计算机中</p><p>·     概念模型：抽象模型，独立与计算机系统，E-R模型，O-O模型</p><p>数据建模就是抽象：理解-区分-命名-表达</p><h2 id="E-R模型："><a href="#E-R模型：" class="headerlink" title="E-R模型："></a>E-R模型：</h2><p>·     世界是由一组对象实体和这些对象之间关系构成。 </p><h2 id="实体与实例："><a href="#实体与实例：" class="headerlink" title="实体与实例："></a>实体与实例：</h2><p>·     实体：客观存在并可相互区分的事物</p><p>·     实体有类和个体的概念（实体的型，实例）</p><p><img src="clip_image284.jpg" alt="img"></p><h2 id="属性："><a href="#属性：" class="headerlink" title="属性："></a>属性：</h2><p><strong>实体用属性来刻画：</strong></p><p>·     <strong>属性：</strong>实体具有的某一方面特性</p><p><strong>实例用值来刻画：</strong></p><p>·     每一个实例都有具体的值</p><p><img src="clip_image286.jpg" alt="img"></p><h2 id="-3"><a href="#-3" class="headerlink" title=" "></a> </h2><h3 id="关键字-码"><a href="#关键字-码" class="headerlink" title="关键字/码"></a>关键字/码</h3><p>·     实体能够用其值唯一区分开每个实例的属性或属性组合。</p><h2 id="联系："><a href="#联系：" class="headerlink" title="联系："></a>联系：</h2><p>·     指的是一个实体实例和其他实体实例之间所可能发生的联系。</p><h3 id="联系的元-度："><a href="#联系的元-度：" class="headerlink" title="联系的元/度："></a>联系的元/度：</h3><p>·     参与发生联系的实体数目</p><p><img src="clip_image288.jpg" alt="img"></p><p>一元联系：联系在同一个实体中产生</p><p><img src="clip_image290.jpg" alt="img"></p><h3 id="角色"><a href="#角色" class="headerlink" title="角色:"></a>角色:</h3><p>·     实体在联系中的作用称为实体的角色</p><p>·     当同一实体的不同实例参与一个联系时，为区分各个实例参与联系的方式</p><p><img src="clip_image292.jpg" alt="img"></p><h2 id="联系的种类："><a href="#联系的种类：" class="headerlink" title="联系的种类："></a>联系的种类：</h2><p>·     一对一：实体A只能和实体B一个实例产生关系。</p><p>·     一对多：实体A能和实体B多个实例发生关系。</p><p>·     多对多：实体A能和实体B的多个实例发生联系。</p><h3 id="联系的基数："><a href="#联系的基数：" class="headerlink" title="联系的基数："></a>联系的基数：</h3><p>·     实体实例之间的联系数量，即一个实体的实例通过一个联系能与另一个实体中相关联的实例的数目。</p><p>·     （1：1），（1：m），（m：n)几种情况</p><p>·     实体之间的联系常采用最小基数和最大基数来表示（MinCard…MaxCard）</p><p>·     <img src="clip_image294.jpg" alt="img"></p><p>·     完全参与联系：最小基数为1</p><p>·     部分参与联系：最小基数为0，可能不产生联系。</p><h2 id="E-R图的表示（chen方法）："><a href="#E-R图的表示（chen方法）：" class="headerlink" title="E-R图的表示（chen方法）："></a>E-R图的表示（chen方法）：</h2><p>·     实体：矩形框</p><p>·     属性：椭圆</p><p>o  多值属性：双线椭圆</p><p>o  导出属性：虚线椭圆</p><p>·     关键字：下划线</p><p>·     连接实体和属性：直线</p><p>·     联系：菱形框</p><p>·     连接实体与联系：直线</p><p>·     连接联系和属性：直线</p><p>·     复合关键字：标有相同数字</p><p>·     多组关键字：标有不同数字</p><p><img src="clip_image296.jpg" alt="img"></p><p>·     1：1联系：箭头直线，由联系指向实体</p><p>·     1：m联系：指向1端为箭头直线，指向多端为无箭头直线</p><p>·     m：n联系：无箭头直线</p><p>·     完全参与联系：双直线</p><p>·     部分参与联系：单直线</p><p><img src="clip_image298.jpg" alt="img"></p><p>·     也可用直线边上标记数字来表示</p><p><img src="clip_image300.jpg" alt="img"></p><h2 id="运用ER图建模的步骤："><a href="#运用ER图建模的步骤：" class="headerlink" title="运用ER图建模的步骤："></a>运用ER图建模的步骤：</h2><p>\1.  理解需求，寻找实体：</p><p>a.  能用一个个、一件件、一串串等叠词形容的，而不是一个、一件</p><p>\2.  用属性刻画每一个实体</p><p>a.  至少给出重要的属性</p><p>\3.  确定每一个实体的关键字/码</p><p>\4.  数据建模的重点是分析实体之间的联系</p><p>\5.  检查是否覆盖了需求</p><h2 id="E-R模型（Crow’s-foot方法）："><a href="#E-R模型（Crow’s-foot方法）：" class="headerlink" title="E-R模型（Crow’s foot方法）："></a>E-R模型（Crow’s foot方法）：</h2><p>·     实体：矩形框</p><p>·     属性：实体框的横线下面</p><p>·     关键字：属性下加下划线</p><p><img src="clip_image302.jpg" alt="img"></p><p>·     联系：菱形框，也可以省略只用关系名表示</p><p><img src="clip_image304.jpg" alt="img"></p><p>·     基数表示：</p><p><img src="clip_image306.jpg" alt="img"></p><p><img src="clip_image308.jpg" alt="img"></p><h2 id="数据库设计中的抽象："><a href="#数据库设计中的抽象：" class="headerlink" title="数据库设计中的抽象："></a>数据库设计中的抽象：</h2><p>·     现实世界-信息世界-计算机世界</p><p>·     现实-观念-实现</p><h2 id="型与值："><a href="#型与值：" class="headerlink" title="型与值："></a>型与值：</h2><p>·     型：对一系列值的抽象</p><p><img src="clip_image310.jpg" alt="img"></p><p>·     型与型的型：将可无限拓展的内容，或内容暂无法枚举的情况，抽象为可有限描述的概念</p><p><img src="clip_image312.jpg" alt="img"></p><p>·     类似的概念：</p><p>o  模式：数据</p><p>o  数据模型：模式</p><p>o  模式：实例</p><p>o  类：对象</p><p>o  实体：实例</p><h2 id="数据模型："><a href="#数据模型：" class="headerlink" title="数据模型："></a>数据模型：</h2><p>·     不同范围的人对现实事物的描述和抽象可能是不同的</p><p>·     数据模型是一组相互关联且严格定义的概念集合</p><p>·     表达计算机世界的模型成为<strong>数据模型</strong>，表达信息世界的模型称概念数据模型，简称<strong>概念模型。</strong></p><h2 id="建模的不同层次："><a href="#建模的不同层次：" class="headerlink" title="建模的不同层次："></a>建模的不同层次：</h2><p>·     模型与元模型，模型（型）与实例（值）</p><p><img src="clip_image314.jpg" alt="img"></p><p>IDEF1x数据建模方法</p><p>2020年6月17日</p><p>9:22</p><h1 id="IDEF1x中的重要概念："><a href="#IDEF1x中的重要概念：" class="headerlink" title="IDEF1x中的重要概念："></a>IDEF1x中的重要概念：</h1><p>IDEF又可以被看成是一个特殊的E-R图表示方法。</p><p>·     实体：</p><p>o  独立实体-强实体</p><p>o  从属实体-若实体</p><p>·     联系：</p><p>o  可标定连接联系</p><p>o  非标定连接联系</p><p>o  分类联系</p><p>o  非确定联系</p><p>·     属性：</p><p>o  属性</p><p>o  主码</p><p>o  候选码</p><p>o  外来码</p><h2 id="独立实体："><a href="#独立实体：" class="headerlink" title="独立实体："></a>独立实体：</h2><p>·     一个实体的实例都被唯一的标识而不决定于它与其他实体的联系</p><p><img src="clip_image316.jpg" alt="img"></p><h2 id="从属实体："><a href="#从属实体：" class="headerlink" title="从属实体："></a>从属实体：</h2><p>·     一个实体的实例的唯一标识需要依赖于该实体与其他实体的联系</p><p>·     从属实体需要从其他实体继承属性作为关键字的一部分。</p><p>·     主关键字包含了外来属性的实体为从属实体。</p><p><img src="clip_image318.jpg" alt="img"></p><p>·     独立实体：直角方形框，从属实体：圆角方形框。</p><p>·     独立实体没有外键，从属实体有外键。</p><h2 id="属性：-1"><a href="#属性：-1" class="headerlink" title="属性："></a>属性：</h2><p>·     表示一类现实或抽象是服务的一种特征或性质</p><p>关键字：能够唯一确定实体的每一个实例的关键字。</p><p><img src="clip_image320.jpg" alt="img"></p><p>外来关键字：是其他实体的关键字</p><p>·     存在一个联系，只能有一个外来关键字</p><p>·     被继承属性只能是主关键字所包含的属性</p><h2 id="联系：-1"><a href="#联系：-1" class="headerlink" title="联系："></a>联系：</h2><p>·     标定联系：子实体的实例都是由它与父实体的联系而确定的，<strong>父实体的主关键字</strong>是<strong>子实体主关键字</strong>的一部分。（1对多）</p><p><img src="clip_image322.jpg" alt="img"></p><p>·     非标定联系：子实体的实例能够被唯一标识而无需依赖与其实体的联系，父实体的主关键字不是子实体的主关键字。（一对多）</p><p><img src="clip_image324.jpg" alt="img"></p><p>·     非确定联系：实体之间的多对多联系</p><p>o  非确定联系是通过引入<strong>相交实体</strong>来进行</p><p><img src="clip_image326.jpg" alt="img"></p><p>·     分类联系：一个实体实例是由一个一般实体和多个分类实体实例构成的（有点类似对象继承的感觉）</p><p><img src="clip_image328.jpg" alt="img"></p><p>·     具体化：</p><p>o  实体的实例集中，某些实例子集具有区别于该实例集内其他实例的特性，可以根据这些差异特性对该实例集进行分组、分类。</p><p>·     泛化：</p><p>o  若干个实体，具有共有的性质，可以合成一个较高层次的实体。</p><p>·     具体化和泛化的表示：</p><p>o  具体化和泛化在E-R图中用标记为ISA的三角形来表示</p><p><img src="clip_image330.jpg" alt="img"></p><p>·     完全分类：一个父类只能是子类的一种</p><p>·     非完全分类联系：子类分类不一定是全部的父类可能性</p><p><img src="clip_image332.jpg" alt="img"></p><p><img src="clip_image334.jpg" alt="img"></p><p>需求分析</p><p>2020年6月17日</p><p>14:32</p><h1 id="E-R图向关系模式的转换："><a href="#E-R图向关系模式的转换：" class="headerlink" title="E-R图向关系模式的转换："></a>E-R图向关系模式的转换：</h1><p>·     E-R图的实体转换为关系</p><p>·     E-R图的属性转为关系的属性</p><p>·     E-R图的关键字转换为关系的关键字</p><p><img src="clip_image336.jpg" alt="img"></p><h2 id="复合属性的转换："><a href="#复合属性的转换：" class="headerlink" title="复合属性的转换："></a>复合属性的转换：</h2><p>·     将分量属性作为符合属性所在实体的属性</p><p>·     将符合属性本身作为所在实体的属性</p><p><img src="clip_image338.jpg" alt="img"></p><h2 id="多值属性："><a href="#多值属性：" class="headerlink" title="多值属性："></a>多值属性：</h2><p>·     将多值属性与所在实体的关键字一起组成一个新的关系</p><h2 id="联系的转换："><a href="#联系的转换：" class="headerlink" title="联系的转换："></a>联系的转换：</h2><p>·     一对一联系：</p><p>o  若联系的双方均部分参与（0…1)，则将联系定义为一个新的属性，属性为参与双方的关键字属性</p><p><img src="clip_image340.jpg" alt="img"></p><p>o  若联系一方全部参与（1…1)，则将联系另一方的关键字作为全部参与另一方的属性</p><p><img src="clip_image342.jpg" alt="img"></p><p>·     一对多联系：</p><p>o  将单方参与实体的关键字作为多方参与实体对应关系的属性</p><p><img src="clip_image344.jpg" alt="img"></p><p>·     多对多联系：</p><p>o  将联系定义为新的关系，属性作为参与双方实体的关键字</p><p><img src="clip_image346.jpg" alt="img"></p><h2 id="弱实体的转换："><a href="#弱实体的转换：" class="headerlink" title="弱实体的转换："></a>弱实体的转换：</h2><p>·     所对应关系的关键字由弱实体本身的区分属性再加上所依赖的强实体的关键字构成</p><p><img src="clip_image348.jpg" alt="img"></p><p>·     弱实体（从属实体）与强实体（独立实体）之间的联系已经在弱实体集所对应的关系中表现出来了</p><h2 id="泛化与具体化："><a href="#泛化与具体化：" class="headerlink" title="泛化与具体化："></a>泛化与具体化：</h2><p>·     高层实体和底层实体分辨转为不同的关系。</p><p>·     底层实体所对应的关系包含高层实体的关键字。</p><p><img src="clip_image350.jpg" alt="img"></p><p>·     如果泛化实例是具体化的实体实例的全部，即对每一个高层实体实例至少属于一个低层实体，则可以不为高层实体建立关系，但低层实体所对应的关系应包含上层实体的所有属性。</p><h2 id="多元联系的转换："><a href="#多元联系的转换：" class="headerlink" title="多元联系的转换："></a>多元联系的转换：</h2><p>·     多元联系可以通过继承参与联系的各个实体的关键字而形成新的关系</p><p>·     也可新增一个区分属性作为关键字</p><p>·     多元联系需要分析参与联系的实体的最小基数和最大基数</p><p>·     是否允许参与联系的多实体中有一个或多个实体不参与</p><p><img src="clip_image352.jpg" alt="img"></p><p><img src="clip_image354.jpg" alt="img"></p><h1 id="IDEF1X图转换成关系模式："><a href="#IDEF1X图转换成关系模式：" class="headerlink" title="IDEF1X图转换成关系模式："></a>IDEF1X图转换成关系模式：</h1><p>·     IDEF1X图只需要将实体转换成关系模式即可，而其联系的信息已经融入相关实体的关系描述中了</p><p>·     对IDEF1x图的分类联系，可以如E-R图的泛化和具体化一样进行相关的处理</p><p>·     对IDEF1X图的复合属性和多值属性，则如前面一样相关处理</p><p><img src="clip_image356.jpg" alt="img"></p><h1 id="范式数据库设计："><a href="#范式数据库设计：" class="headerlink" title="范式数据库设计："></a>范式数据库设计：</h1><p>需要分析数据库设计中的属性依存关系</p><p><strong>数据库设计理论：</strong></p><p>·     函数依赖理论</p><p>·     关系范式理论</p><p>·     模式分解理论</p><p><img src="clip_image358.jpg" alt="img"></p><p>函数依赖</p><p>2020年6月17日</p><p>16:33</p><h2 id="函数依赖的定义："><a href="#函数依赖的定义：" class="headerlink" title="函数依赖的定义："></a>函数依赖的定义：</h2><p>·     <img src="clip_image360.jpg" alt="img"></p><p>·     <img src="clip_image362.jpg" alt="img"></p><p>·     <img src="clip_image364.jpg" alt="img"></p><h2 id="函数依赖的特性："><a href="#函数依赖的特性：" class="headerlink" title="函数依赖的特性："></a>函数依赖的特性：</h2><p><img src="clip_image366.jpg" alt="img"></p><h2 id="部分函数依赖和完全函数依赖："><a href="#部分函数依赖和完全函数依赖：" class="headerlink" title="部分函数依赖和完全函数依赖："></a>部分函数依赖和完全函数依赖：</h2><p><img src="clip_image368.jpg" alt="img"></p><p><img src="clip_image370.jpg" alt="img"></p><p>否则称为部分函数依赖于x，记为</p><p><img src="clip_image372.jpg" alt="img"></p><p><img src="clip_image374.jpg" alt="img"></p><p>（如果有不需要的关键字，那就是部分函数依赖）</p><h2 id="传递函数依赖："><a href="#传递函数依赖：" class="headerlink" title="传递函数依赖："></a>传递函数依赖：</h2><p><img src="clip_image376.jpg" alt="img"></p><p><img src="clip_image378.jpg" alt="img"></p><h2 id="候选键：-1"><a href="#候选键：-1" class="headerlink" title="候选键："></a>候选键：</h2><p>设K为R(U)的属性或属性组合，若</p><p><img src="clip_image380.jpg" alt="img"></p><p>则称K为R(U)上的候选键。</p><p>·     唯一性：</p><p>·     最小性：</p><p>·     任一候选键都可以作为R的主键</p><p>·     包含任意候选键中的属性称为主属性，其他属性称为非主属性。</p><p>·     <img src="clip_image382.jpg" alt="img"></p><p><img src="clip_image384.jpg" alt="img"></p><h2 id="外来键："><a href="#外来键：" class="headerlink" title="外来键："></a>外来键：</h2><p>若R(U)中的属性或属性组合X并非R的候选键，但是X却是另一关系的候选键，则称X为R的外来键</p><p><img src="clip_image386.jpg" alt="img"></p><h2 id="逻辑蕴含："><a href="#逻辑蕴含：" class="headerlink" title="逻辑蕴含："></a>逻辑蕴含：</h2><p><img src="clip_image388.jpg" alt="img"></p><p><img src="clip_image390.jpg" alt="img"></p><h2 id="闭包："><a href="#闭包：" class="headerlink" title="闭包："></a>闭包：</h2><p><img src="clip_image392.jpg" alt="img"></p><p><img src="clip_image394.jpg" alt="img"></p><p>·     小集合，大闭包</p><p>·     包含了平凡的函数依赖</p><h2 id="阿姆斯特朗公理："><a href="#阿姆斯特朗公理：" class="headerlink" title="阿姆斯特朗公理："></a>阿姆斯特朗公理：</h2><p>设R(U)是属性集U={A1, A2,…,An}上的一个关系模式，F为R(U)的一组函数依赖，记为R(U,F)</p><p>·     <img src="clip_image396.jpg" alt="img"></p><p>·     <img src="clip_image398.jpg" alt="img"></p><p>·     <img src="clip_image400.jpg" alt="img"></p><p><img src="clip_image402.jpg" alt="img"></p><h3 id="引理："><a href="#引理：" class="headerlink" title="引理："></a>引理：</h3><p>·     <img src="clip_image404.jpg" alt="img"></p><p>·     <img src="clip_image406.jpg" alt="img"></p><p>·     <img src="clip_image408.jpg" alt="img"></p><p><img src="clip_image410.jpg" alt="img"></p><h3 id="引理2："><a href="#引理2：" class="headerlink" title="引理2："></a>引理2：</h3><p><img src="clip_image412.jpg" alt="img"></p><h2 id="属性闭包："><a href="#属性闭包：" class="headerlink" title="属性闭包："></a>属性闭包：</h2><p><img src="clip_image414.jpg" alt="img"></p><h2 id="引理：-1"><a href="#引理：-1" class="headerlink" title="引理："></a>引理：</h2><p><img src="clip_image416.jpg" alt="img"></p><p><img src="clip_image418.jpg" alt="img"></p><h2 id="覆盖："><a href="#覆盖：" class="headerlink" title="覆盖："></a>覆盖：</h2><p><img src="clip_image420.jpg" alt="img"></p><p><img src="clip_image422.jpg" alt="img"></p><p>证明两个函数依赖集相等，其实等价于求这两者的属性闭包相等</p><p><img src="clip_image424.jpg" alt="img"></p><h2 id="-4"><a href="#-4" class="headerlink" title=" "></a> </h2><h2 id="求属性闭包的方法："><a href="#求属性闭包的方法：" class="headerlink" title="求属性闭包的方法："></a>求属性闭包的方法：</h2><p><img src="clip_image426.jpg" alt="img"></p><h3 id="引理：-2"><a href="#引理：-2" class="headerlink" title="引理："></a>引理：</h3><p>每个函数依赖集F可被一个其右端至多有一个属性的函数依赖集G覆盖</p><p><img src="clip_image428.jpg" alt="img"></p><h2 id="最小覆盖："><a href="#最小覆盖：" class="headerlink" title="最小覆盖："></a>最小覆盖：</h2><p>若F满足以下条件，则称F为最小覆盖或者最小依赖集</p><p>\1.  F中每一个函数依赖的右部是单个属性</p><p>\2.  <img src="clip_image430.jpg" alt="img"></p><p>\3.  <img src="clip_image432.jpg" alt="img"></p><p><img src="clip_image434.jpg" alt="img"></p><p><img src="clip_image436.jpg" alt="img"></p><p><strong>最小函数依赖集的求解</strong></p><p> <strong>一、定义</strong></p><p><strong>最小函数依赖集</strong>也称为<strong>极小函数依赖集</strong>、<strong>最小覆盖</strong>；如果函数依赖集 <strong><em>F\</em></strong> 满足下列条件，则称 <strong><em>F\</em></strong> 为一个最小依赖集。</p><p><strong><em>1.\</em></strong>  <strong><em>F\</em></strong> 中任意函数依赖的右部仅含有一个属性</p><p><strong><em>2.\</em></strong>  <strong><em>F\</em></strong> 中不存在这样的函数依赖<strong>X**</strong>→<strong>**A,</strong>使得 <strong><em>F\</em></strong> 与 <strong><em>F\</em> - {X**</strong>→<strong>**A}</strong>等价，即 <strong><em>F\</em></strong> 中的函数依赖均不能由 <em>F</em> 中其他函数依赖导出</p><p><strong><em>3.\</em></strong>  <strong><em>F\</em></strong> 中不存在这样的函数依赖<strong>X**</strong>→<strong><strong>A</strong></strong>，<strong>**X</strong>有真子集 <strong>Z</strong> 使得 <strong><em>F\</em> - {X**</strong>→<strong>**A}</strong> <strong>∪</strong> <strong>{Z**</strong>→<strong>**A}</strong>与 <strong><em>F\</em></strong> 等价，即 <strong><em>F\</em></strong> 中各函数依赖左部均为最小属性集（不存在冗余属性）</p><p> <strong>二、算法步骤：</strong></p><p>·     将 <strong><em>F\</em></strong> 中的所有函数依赖的右边化为单一属性</p><p>·     去掉 <strong><em>F\</em></strong> 中的所有函数依赖左边的冗余属性（只针对<strong><em>F\</em></strong>中左部不是单一属性的函数依赖）</p><p>·     去掉 <strong><em>F\</em></strong> 中的所有冗余的函数依赖</p><p><strong>三、例子说明</strong></p><p>假设<strong>R<U , \*F\*></strong> <strong>，**</strong>U = ABCD<strong>**，</strong>函数依赖集<strong><em>F**</em></strong>={A<strong><strong>→</strong></strong>BD<strong><strong>，</strong></strong>AB<strong><strong>→</strong></strong>C<strong><strong>，</strong></strong>C<strong><strong>→</strong></strong>D}<strong>，求：*</strong>F*** 最小函数依赖集</p><p>第一步：将<strong><em>F\</em></strong>中的所有函数依赖的右边化为单一属性：</p><p>因为<strong><em>F\</em></strong> <strong>= {A**</strong>→<strong><strong>BD</strong></strong>，<strong><strong>AB</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>，函数依赖右边化为单一属性得：<strong><em>F\</em></strong> <strong>= {A**</strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>D</strong></strong>，<strong><strong>AB</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>；</p><p>第二步：去掉<strong><em>F\</em></strong>中的所有函数依赖左边的冗余属性（只针对F中左部不是单一属性的函数依赖）</p><p><strong>F={A**</strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>D</strong></strong>，<strong><strong>AB</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>中只有函数依赖<strong>AB**</strong>→<strong>**C</strong>左部不是单一属性，所以要对其进行去掉左边冗余属性的处理<strong>：</strong></p><p>\1.  先看<strong>A</strong>是不是冗余属性<strong>：</strong>因为<strong>BF+ ={ B }</strong>不包含<strong>A**</strong>，<strong>所以</strong>A<strong>属性不冗余     </strong>//<strong>这里应该注意的是，要看哪一个属性是否是冗余属性，则求该函数依赖左部除要查看的属性外的其他属性的集关于 *</strong>F*** 的闭包是否包含要查看属性</p><p>\2.  再看<strong>B</strong>是不是冗余属性：因为<strong>AF+ ={A**</strong>，<strong><strong>B</strong></strong>，<strong><strong>C</strong></strong>，<strong>**D}</strong> 包含的<strong>B</strong>，所以<strong>B</strong>属性冗余</p><p> 　因此只将函数依赖<strong>AB**</strong>→<strong>**C</strong>左部<strong>B</strong>属性去掉，所以<strong>F={A**</strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>D</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>。</p><p>第三步：去掉 <strong><em>F\</em></strong> 中的所有冗余的函数依赖</p><p>依据引理：设<strong><em>F\</em></strong>为属性集<strong>U</strong>上的一组函数依赖，<strong>X</strong>，<strong>Y</strong> <strong>⊆</strong> <strong>U**</strong>，<strong><strong>X</strong></strong>→<strong>**Y</strong> 能由 <strong><em>F\</em></strong> 根据<strong>Armstrong</strong>公理导出的充分必要条件是<strong>Y**</strong>⊆<strong> </strong>XF+<strong> 。即判断 *</strong>F*<strong> 中一个函数依赖</strong>X<strong><strong>→</strong></strong>Y<strong>是否冗余，则只需要判定 </strong>Y<strong> 是否为的</strong>XF+** 子集。</p><p> 因为有<strong><em>F**</em></strong>={A<strong><strong>→</strong></strong>B<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>D<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>C<strong><strong>，</strong></strong>C<strong><strong>→</strong></strong>D}<strong>**：</strong></p><p>\1.  先看判断函数依赖<strong>A**</strong>→<strong>**D</strong>是否冗余，则把函数依赖<strong>A**</strong>→<strong>**D</strong>从<strong><em>F**</em></strong>={A<strong><strong>→</strong></strong>B<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>D<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>C<strong><strong>，</strong></strong>C<strong><strong>→</strong></strong>D}<strong>中去掉后得*</strong>F*<strong><strong>={A</strong></strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>，求得<strong>AF+ = { A**</strong>，<strong><strong>B</strong></strong>，<strong><strong>C</strong></strong>，<strong>**D}</strong> 包含了<strong>D</strong>，所以为函数依赖<strong>A**</strong>→<strong>**D</strong>冗余，所以应该从<strong><em>F**</em></strong>={A<strong><strong>→</strong></strong>B<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>D<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>C<strong><strong>，</strong></strong>C<strong><strong>→</strong></strong>D}<strong>中去掉函数依赖</strong>A<strong><strong>→</strong></strong>D<strong>，得*</strong>F*<strong><strong>={A</strong></strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong></p><p>\2.  再从<strong><em>F**</em></strong>={A<strong><strong>→</strong></strong>B<strong><strong>，</strong></strong>A<strong><strong>→</strong></strong>C<strong><strong>，</strong></strong>C<strong><strong>→</strong></strong>D}<strong>依次判断每一个函数依赖是否冗余，直至所有冗余的函数依赖都被消除。本例子中经过第1步后已消除 *</strong>F*<strong> 中的所有冗余函数依赖了，因此原*</strong>F*<strong><strong>={A</strong></strong>→<strong><strong>BD</strong></strong>，<strong><strong>AB</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>的最小函数依赖集为 <strong><em>F\</em> ={A**</strong>→<strong><strong>B</strong></strong>，<strong><strong>A</strong></strong>→<strong><strong>C</strong></strong>，<strong><strong>C</strong></strong>→<strong>**D}</strong>。</p><p> <strong>注意点：</strong></p><p><strong><em>1.\</em></strong>  <strong><em>F**</em></strong>的最小依赖集<strong>*</strong>F*<strong> </strong>m<strong> </strong>不一定是唯一的，它与对个函数依赖<strong>**FDi</strong> <strong>及**</strong>X<strong><strong>→</strong></strong>A<strong><strong>中个属性的处置的顺序有关。在本例子中在去掉</strong></strong>F<strong><strong>中的冗余的函数依赖时（绿色字体那一步）若不是首先判断</strong></strong>A<strong><strong>→</strong></strong>D<strong>**是否冗余，而是首先判断其它函数依赖是否冗余，那么所得的最小函数依赖就可能不同了</strong></p><p><strong>2.</strong>  <strong>要搞清楚在判断一个函数依赖**</strong>X<strong><strong>→</strong></strong>A<strong><strong>是否为冗余时，是求</strong></strong>X<strong>**关于上一步所求得的新的函数依赖集</strong> <strong><em>F\</em></strong> <strong>的闭包**</strong>XF+<strong> </strong>，然后在判断<strong><strong>A</strong></strong>是否包含在该<strong>**XF+</strong> </p><p>来自 <a href="[*https://www.cnblogs.com/xiaolu266/p/8041073.html*](https://www.cnblogs.com/xiaolu266/p/8041073.html)">[*https://www.cnblogs.com/xiaolu266/p/8041073.html*](https://www.cnblogs.com/xiaolu266/p/8041073.html)</a></p><p><strong>求最小函数依赖集分三步**</strong>:**</p><p>1.将F中的所有依赖右边化为单一元素</p><p>此题fd={abd-&gt;e,ab-&gt;g,b-&gt;f,c-&gt;j,cj-&gt;i,g-&gt;h};已经满足</p><p>2.去掉F中的所有依赖左边的冗余属性.</p><p>作法是属性中去掉其中的一个,看看是否依然可以推导</p><p>此题:abd-&gt;e,去掉a,则(bd)+不含e,故不能去掉,同理b,d都不是冗余属性</p><p>ab-&gt;g,也没有</p><p>cj-&gt;i,因为c+={c,j,i}其中包含i所以j是冗余的.cj-&gt;i将成为c-&gt;i</p><p>F={abd-&gt;e,ab-&gt;g,b-&gt;f,c-&gt;j,c-&gt;i,g-&gt;h};</p><p>3.去掉F中所有冗余依赖关系.</p><p>做法为从F中去掉某关系,如去掉(X-&gt;Y),然后在F中求X+,如果Y在X+中,则表明x-&gt;是多余的.需要去掉.</p><p>此题如果F去掉abd-&gt;e,F将等于{ab-&gt;g,b-&gt;f,c-&gt;j,c-&gt;i,g-&gt;h},而(abd)+={a,d,b,f,g,h},其中不包含e.所有不是多余的.</p><p>同理(ab)+={a,b,f}也不包含g,故不是多余的.</p><p>b+={b}不多余,c+={c,i}不多余</p><p>c-&gt;i,g-&gt;h多不能去掉.</p><p>所以所求最小函数依赖集为 F={abd-&gt;e,ab-&gt;g,b-&gt;f,c-&gt;j,c-&gt;i,g-&gt;h};</p><p>来自 <a href="[*https://www.cnblogs.com/wangyige/p/6786047.html*](https://www.cnblogs.com/wangyige/p/6786047.html)">[*https://www.cnblogs.com/wangyige/p/6786047.html*](https://www.cnblogs.com/wangyige/p/6786047.html)</a></p><p>关系范数</p><p>2020年6月19日</p><p>15:19</p><h2 id="1NF-（不含多值属性）"><a href="#1NF-（不含多值属性）" class="headerlink" title="1NF:（不含多值属性）"></a>1NF:（不含多值属性）</h2><p><img src="clip_image438.jpg" alt="img"></p><p><img src="clip_image440.jpg" alt=": Star( name, address(street. city) )  FÉINF "></p><p><strong>不符合1NF的处理：</strong></p><p>·     将1NF转换为1NF</p><p><img src="clip_image442.jpg" alt=": Star( name. address(street. city) )  Star( name, address) Star ( name. street city ) "></p><p>·     引入新的数据模型处理：面向对象的数据模型</p><p><img src="clip_image444.jpg" alt="img"></p><h2 id="2NF-（没有非主属性对候选键的部分依赖）"><a href="#2NF-（没有非主属性对候选键的部分依赖）" class="headerlink" title="2NF:（没有非主属性对候选键的部分依赖）"></a>2NF:（没有非主属性对候选键的部分依赖）</h2><p><img src="clip_image446.jpg" alt="img"></p><p><img src="clip_image448.jpg" alt=". se:&quot;. SN.•RZ. SD:nn. CN:N. G•.n.  S#.SN.  : csg,CN) . : SNOSD.  SN, SD). Ra(Sg. CN. G). , 2.e2NF. "></p><p>第二范式消除了非主属性对候选键的部分依赖</p><p><strong>判断模式是否属于第二范式：</strong></p><p>\1.  找出候选键和非主属性</p><p>\2.  判断是否存在部分依赖</p><p><img src="clip_image450.jpg" alt="学 生 ( 学 号 ′ 姓 名 . 班 級 . 号 . 深 名 . 成 . 教 師 . 教 師 各 )  ロ 蹊 造 健 : ( 学 号 . 深 号 ) ー は リ : 非 主 属 性 : 姓 名 、 深 程 名  ロ 部 分 依 最 : ( 学 号 . 深 号 ) ー な 深 程 名 : ( 学 号 . 深 号 ) ー な 姓 名  ・ 員 工 ( 員 工 姓 名 . 出 生 日 財 鉄 系 用 活 . 最 后 学 厖 並 学 校 一 培 Ⅶ  日 期 . 培 汎 内 容 )  ロ 健 : { 員 工 日 . 培 Ⅶ 日 期 } 亠 U : 非 主 属 性 : 性 名 . 出 生 日 期  ロ 部 分 依 飆 : ( 員 工 円 . 培 Ⅶ 日 期 ) - な { 﨡 名 . 出 生 日 期 ) :  囲 も ( 号 ′ 名 . 出 版 日 期 . 出 版 社 . 事 号 . 房 同 号 )  ロ : 事 号 - 、 U : 非 主 属 性 : 強 外 買 他 属 性  ロ 无 部 分 依 : 第 号 - 、 毎 ー 个 属 性 . "></p><h2 id="3NF-（没有候选键的传递函数依赖）"><a href="#3NF-（没有候选键的传递函数依赖）" class="headerlink" title="3NF:（没有候选键的传递函数依赖）"></a>3NF:（没有候选键的传递函数依赖）</h2><p><img src="clip_image452.jpg" alt="img"></p><p><strong>第三范式没有传递函数依赖</strong></p><p><img src="clip_image454.jpg" alt=": Store(Sid, Pid, Did, Mgr)  , Did:GüE. Mgr:en.  : (Sid. Pid) Did. (Sid. Did).Mgr  Re : (Sid.Pid) , Mgr.  Pid»Did. (Sid, Didy»Mgr ,  WA B Pid. Did), Did. Mgr),  ae3NF. "></p><p>第三范式消除了非主属性的传递依赖</p><p><strong>判断模式是否属于第三范式：</strong></p><p>\1.  找到候选键</p><p>\2.  有无传递依赖</p><p>\3.  有无部分依赖</p><p><img src="clip_image456.jpg" alt="・ 学 生 ( 学 号 . 系 号 . 系 主 任 )  ロ 載 : 学 号 、 U : 非 主 属 性 : 系 主 任  ロ 倍 道 依 : 学 号 今 系 号 . 系 号 今 系 主 任  ロ 无 部 分 依 報  所 以 : 滿 足 第 2NF 但 不 満 足 第 3NF.  ・ 員 工 ( 員 工 碼 . 姓 名 . 部 冂 . 部 冂 理 )  ロ 健 : 員 工 円 コ ・ U : ヨ E 主 属 性 : 部 ロ 理  ロ 倍 通 依 : 工 円 今 部 ロ . 部 冂 今 部 冂 理  ロ 无 部 分 依  所 以 : 足 第 2NF 但 不 満 足 第 3NF. "></p><p>关系模式满足第三范式则一定能满足第二范式。</p><p><strong>将关系模式分解成3NF：</strong></p><p>分解规则：</p><p>将每一个函数依赖单独组成一个关系。</p><p><img src="clip_image458.jpg" alt=": R(A, B, C, D, E, F. G)  C*E. E*FG )  RI(A.B).  R12(A. F, G)) "></p><h2 id="Boyce-Codd范式：（所有函数依赖都包含候选键）"><a href="#Boyce-Codd范式：（所有函数依赖都包含候选键）" class="headerlink" title="Boyce-Codd范式：（所有函数依赖都包含候选键）"></a>Boyce-Codd范式：（所有函数依赖都包含候选键）</h2><p><img src="clip_image460.jpg" alt="img"></p><p><strong>模式上的所有函数依赖都含有候选键，没有不依赖于候选键的函数依赖</strong></p><p><img src="clip_image462.jpg" alt="示 例 ． 邮 编 （ 城 市 ， 街 道 ， 政 编 黝  甬 数 依 赖 ： { 城 市 ， 街 道 } 乛 鄒 政 编 码 ： 邮 政 编 码 一 城 市 ，  》 候 选 踺 ： { 喊 市 ． 街 0 } 一 、 U  》 因 不 候 选 ： 政 编 码 城 市 ： 所 以 不 满 足 B （ NF  因 无 传 递 铱 隸 ， 所 以 認 足 第 3 范 式 ：  示 例 ： 选 谭 （ 学 号 ． 课 程 号 。 緻 獅 编 号 ）  假 设 規 定 ， 师 只 开 一 冂 则 有 ： { 学 号 ． 课 程 号 产 师 号 ： 师 号  一 课 程 号 ． 0 \ 咳 模 式 满 足 第 3 范 式 但 不 满 足 ％ y （ e ． （ 。 dd 范 式 ． "></p><p><img src="clip_image464.jpg" alt="img"></p><p><strong>满足BCNF的一定满足第三范式，不满足第三范式的一定不满足BCNF</strong></p><p><img src="clip_image466.jpg" alt=": , iRR(U.F) cBCNF . , ,  . YA. . AA. Agy, Y .X.  EA«Y. . "></p><p><strong>关系模式分解成BCNF：</strong></p><p><img src="clip_image468.jpg" alt="可 以 出 , RI 「 F :  也 可 以 和 R2 合  F; R3 EBCNF; R4 CBCNF;  p=(R12(C.D,E).R3(E,F.G).R4(A.B.C)) "></p><h2 id="多值依赖："><a href="#多值依赖：" class="headerlink" title="多值依赖："></a>多值依赖：</h2><p><img src="clip_image470.jpg" alt="img"></p><p>对于元组t,s，交换属性Y之后，仍然会出现在关系中</p><p><img src="clip_image472.jpg" alt="img"></p><p><strong>多值依赖的特性：</strong></p><p><img src="clip_image474.jpg" alt="多 值 依 赖 的 持 性  1 ） 0 观 地 ． 对 于 × 焓 定 值 ， Y 有 一 组 喳 与 之 对 瓯 （ 0 或 n 个 ） 且 这 组 Y 值 不 以  任 何 方 式 与 U ． X ． Y 中 属 性 值 相 以 ， 有 X 一 、 一 》 Y ．  2 ） 若 交 换 t,s 的 Y 億 而 得 到 的 新 元 组 仍 在 冲 ．  3 ） × ， Y 不 不 相 交 ． u ． v 可 以 与 t.s 相 同 ·  4 ） 函 数 賴 是 多 的 依 隸 的 特 例 · "></p><p><img src="clip_image476.jpg" alt=": R N&amp;ZC, пЮДт. НВ*ЯН. ПТ.  С , ЖАС "></p><h2 id="4NF-已经是BC范式，并且不包含多值依赖关系。"><a href="#4NF-已经是BC范式，并且不包含多值依赖关系。" class="headerlink" title="4NF:(已经是BC范式，并且不包含多值依赖关系。)"></a>4NF:(已经是BC范式，并且不包含多值依赖关系。)</h2><p><img src="clip_image478.jpg" alt="img"></p><p>当一个表中的非主属性互相独立时（3NF），这些非主属性不应该有多值。若有多值就违反了第四范式。定义比较抽象，可以参照下面的例子理解。</p><p><strong>第四范式消除了非主属性对候选键以外属性的多值依赖，如果有多值依赖则一定依赖于候选键。</strong></p><p><img src="clip_image480.jpg" alt="img"></p><p><img src="clip_image482.jpg" alt=": iQRe4NF, . У-х  = . . ХОВИ.  . ЕХ“У . ИХ..У . "></p><p><img src="clip_image484.jpg" alt="img"></p><h2 id="W4NF"><a href="#W4NF" class="headerlink" title="W4NF:"></a>W4NF:</h2><p><img src="clip_image486.jpg" alt="i2R(U)e3NF. 若 R 上 的 任 何 互 补 多 值 依 隸 × 一 ， 一 》 Y （ × U ， Y × ） 和  X 。 一 ， （ U 一 X 一 Y ） 中 老 有 一 个 是 函 依 隸 ， 则 称 R 是 弱 第 四 范 式 的 ， 记 力  RcW4NF.  淺 ： W4NF 不 —ENBCNF. 反 之 有 胳 “ "></p><p>模式分解</p><p>2020年6月19日</p><p>20:02</p><h2 id="模式分解："><a href="#模式分解：" class="headerlink" title="模式分解："></a>模式分解：</h2><p><img src="clip_image488.jpg" alt="img"></p><p><img src="clip_image490.jpg" alt="img"></p><p>·     R与p在数据内容方面是否等价：分解的无损连接性</p><p>·     R与p在数据依赖方面是否等价：分解的保持依赖性</p><h3 id="引理1："><a href="#引理1：" class="headerlink" title="引理1："></a>引理1：</h3><p><img src="clip_image492.jpg" alt="img"></p><p><strong>有损连接</strong></p><p><img src="clip_image494.jpg" alt="img"></p><h2 id="无损连接分解："><a href="#无损连接分解：" class="headerlink" title="无损连接分解："></a>无损连接分解：</h2><p><img src="clip_image496.jpg" alt="img"></p><p><strong>大的关系模式分解成小的关系分解，在小的关系模式进行连接的情况下查询是相等的。</strong></p><h2 id="无损连接性检验算法："><a href="#无损连接性检验算法：" class="headerlink" title="无损连接性检验算法："></a>无损连接性检验算法：</h2><p><img src="clip_image498.jpg" alt="img"></p><p><img src="clip_image500.jpg" alt="img"></p><p><strong>简单判定定理：</strong></p><p><img src="clip_image502.jpg" alt="img"></p><h2 id="无损连接的特性："><a href="#无损连接的特性：" class="headerlink" title="无损连接的特性："></a>无损连接的特性：</h2><p><img src="clip_image504.jpg" alt="img"></p><p>·     无损连接分解的无损分解仍然是无损分解</p><p>·     无损连接分解加上一个分解仍然是无损连接分解</p><h2 id="保持依赖分解："><a href="#保持依赖分解：" class="headerlink" title="保持依赖分解："></a>保持依赖分解：</h2><p><img src="clip_image506.jpg" alt="img"></p><p><img src="clip_image508.jpg" alt="img"></p><p>·     保持依赖的分解可能不是无损连接的。</p><p>·     无损连接的分解可能不是保持依赖的。</p><p><img src="clip_image510.jpg" alt="img"></p><p><img src="clip_image512.jpg" alt="img"></p><p>如果F上的每一个函数依赖都在其分解后的某一个关系上成立，则这个分解是保持依赖的（这是一个充分条件）。</p><p>如果上述判断失败，并不能断言分解不是保持依赖的，还要使用下面的通用方法来做进一步判断。</p><p>该方法的表述如下：</p><p>算法二：</p><p>对F上的每一个α→β使用下面的过程：</p><p>result:=α;</p><p>while(result发生变化)do</p><p>  for each 分解后的Ri</p><p>​    t=(result∩Ri)+ ∩Ri</p><p>​    result=result∪t</p><p>这里的属性闭包是在函数依赖集F下计算出来的。如果result中包含了β的所有属性，则函数依赖α→β。分解是保持依赖的当且仅当上述过程中F的所有依赖都被保持。</p><p>下面给出一个例题，2006年5月系分上午43题：</p><p>●设关系模式R<U, F>，其中U=｛A, B, C, D, E｝，F＝{A→BC，C→D，BC→E，E→A｝，则分解ρ={R1（ABCE），R2（CD）｝满足 （43） 。</p><p>（43） A．具有无损连接性、保持函数依赖</p><p>​       B．不具有无损连接性、保持函数依赖</p><p>​       C．具有无损连接性、不保持函数依赖</p><p>​       D．不具有无损连接性、不保持函数依赖</p><p>先做无损链接的判断。R1∩R2={C}，计算C+。</p><p>Result=C</p><p>由于C→D，C∈result，所以result=result∪D=CD</p><p>可见C是R2的超码，该分解是一个无损分解。</p><p>再做保持依赖的判断。</p><p>A→BC，BC→E， E→A都在R1上成立（也就是说每一个函数依赖左右两边的属性都在R1中），C→D在R2上成立，因此给分解是保持依赖的。</p><p>选A。</p><p>再看一个复杂点的例题。2007年5月数工40-41题。</p><p>●给定关系模式R<U, F>，U=｛A, B, C, D, E｝，F＝{B→A，D→A，A→E，AC→B｝，其候选关键字为</p><p>（40） ，则分解ρ={R1（ABCE），R2（CD）｝满足 （41） 。</p><p>（40） A．ABD</p><p>​        B．ABE</p><p>​       C．ACD</p><p>​       D．CD</p><p>（41） A．具有无损连接性、保持函数依赖</p><p>​       B．不具有无损连接性、保持函数依赖</p><p>​       C．具有无损连接性、不保持函数依赖</p><p>​       D．不具有无损连接性、不保持函数依赖</p><p>看见了吧，和前面一题多么的相像！</p><p>对于第一问，分别计算ABCD四个选项的闭包，</p><p>（ABD）+ = { ABDE }</p><p>（ABE）+ = { ABE }</p><p>（ACD）+ = { ABCDE }</p><p>（CD）+ = { ABCDE }</p><p>选D。</p><p>再看第二问。</p><p>先做无损链接的判断。R1∩R2={C}，计算C+。</p><p>result=C</p><p>因此C既不是R1也不是R2的超码，该分解不具有无损分解性。</p><p>再做保持依赖的判断。</p><p>B→A，A→E，AC→B在R1上成立，D→A在R1和R2上都不成立，因此需做进一步判断。</p><p>由于B→A，A→E，AC→B都是被保持的（因为它们的元素都在R1中），因此我们要判断的是D→A是不是也被保持。</p><p>对于D→A应用算法二：</p><p>result=D</p><p>对R1，result∩R1=ф（空集，找不到空集的符号，就用这个表示吧），t=ф，result=D</p><p>再对R2，result∩R2=D，D+ =ADE ，t=D+ ∩R2=D，result=D</p><p>一个循环后result未发生变化，因此最后result=D，并未包含A，所以D→A未被保持，该分解不是保持依赖的。</p><p>选D。</p><p>来自 <a href="[*http://www.blogjava.net/RiKeR/articles/153733.html*](http://www.blogjava.net/RiKeR/articles/153733.html)">[*http://www.blogjava.net/RiKeR/articles/153733.html*](http://www.blogjava.net/RiKeR/articles/153733.html)</a></p><p>·     左端属性必须是某一个关系模式的属性。</p><p>·     求关于G的属性闭包结果属性也必须是此关系模式的属性。</p><h2 id="无损连接分解成BCNF算法"><a href="#无损连接分解成BCNF算法" class="headerlink" title="无损连接分解成BCNF算法"></a>无损连接分解成BCNF算法</h2><p>分解规则：</p><p>·     将左侧不含候选键的函数依赖单独组成一个关系，将包含候选键的组成一关系</p><p><img src="clip_image514.jpg" alt="img"></p><p><img src="clip_image516.jpg" alt="img"></p><h2 id="关系模式分解成成3NF"><a href="#关系模式分解成成3NF" class="headerlink" title="关系模式分解成成3NF"></a>关系模式分解成成3NF</h2><p>分解规则：</p><p>·     将每一个函数依赖单独组成一个关系</p><p><img src="clip_image518.jpg" alt="img"></p><p><img src="clip_image520.jpg" alt="img"></p><h2 id="既保持依赖，又保持无损连接的分解"><a href="#既保持依赖，又保持无损连接的分解" class="headerlink" title="既保持依赖，又保持无损连接的分解"></a>既保持依赖，又保持无损连接的分解</h2><p><img src="clip_image522.jpg" alt="img"></p><p><img src="clip_image524.jpg" alt="img"></p><p><img src="clip_image526.jpg" alt="img"></p><h2 id="无损连接分解成4NF"><a href="#无损连接分解成4NF" class="headerlink" title="无损连接分解成4NF"></a>无损连接分解成4NF</h2><p><img src="clip_image528.jpg" alt="img"></p><h2 id="连接依赖："><a href="#连接依赖：" class="headerlink" title="连接依赖："></a>连接依赖：</h2><p><img src="clip_image530.jpg" alt="img"></p><p>·     多值依赖是连接依赖的特例， 2-JD多值依赖</p><h2 id="5NF：（按照候选键连接）"><a href="#5NF：（按照候选键连接）" class="headerlink" title="5NF：（按照候选键连接）"></a>5NF：（按照候选键连接）</h2><p><img src="clip_image532.jpg" alt="img"></p><p><strong>第五范式消除了不按候选键连接的连接依赖，（R的无损连接分解中各个模式必有一个候选键），但其语义背景抽象。</strong></p><h2 id="本章总结："><a href="#本章总结：" class="headerlink" title="本章总结："></a>本章总结：</h2><p><img src="clip_image534.jpg" alt="img"></p><p>数据库的存储体系</p><p>2020年6月20日</p><p>15:35</p><h2 id="存储体系："><a href="#存储体系：" class="headerlink" title="存储体系："></a>存储体系：</h2><p>·     将不同性价比的存储器组织在一起，满足高速度、大容量、低价格的需求</p><p>·     CPU与内存直接交换信息，按存储单元进行访问</p><p>·     外存按存储块进行访问，其信息需先装入内存，才能被CPU处理</p><p><img src="clip_image536.jpg" alt="img"></p><h2 id="操作系统对数据的组织："><a href="#操作系统对数据的组织：" class="headerlink" title="操作系统对数据的组织："></a>操作系统对数据的组织：</h2><p>·     FAT-目录-磁盘块</p><p>·     FAT（文件分配表）</p><p><img src="clip_image538.jpg" alt="img"></p><h2 id="-5"><a href="#-5" class="headerlink" title=" "></a> </h2><h2 id="内存管理："><a href="#内存管理：" class="headerlink" title="内存管理："></a>内存管理：</h2><p>·     一条记录的地址=存储单元地址=内存地址=页面：页面偏移量</p><p>·     页面（page）=块（Block）</p><p>·     内存页面的分配</p><p>·     内存页面的置换</p><p><img src="clip_image540.jpg" alt="img"></p><h2 id="磁盘结构："><a href="#磁盘结构：" class="headerlink" title="磁盘结构："></a>磁盘结构：</h2><p>磁盘读写单位：簇Cluster/块Block连续的若干个扇区</p><p>算的时候不能算圆盘，只能算盘面</p><p><img src="clip_image542.jpg" alt="img"></p><p>盘面：磁道：扇区</p><p><strong>物理存取算法考虑的关键：</strong></p><p>·     降低I/O次数</p><p>·     降低排队等待时间</p><p>·     降低寻道、旋转延迟时间：</p><p>o  同一磁道连续块存储</p><p>o  同一柱面不同磁道并行块存储</p><p>o  多个磁盘并行块存储</p><h2 id="RAID技术："><a href="#RAID技术：" class="headerlink" title="RAID技术："></a>RAID技术：</h2><p>·     并行处理：并行读取多个磁盘</p><p>o  <strong>比特级拆分：</strong>以字节拆分  </p><p>o  <strong>块集拆分：</strong>以块为单位并行</p><p>·     可靠性：奇偶校验</p><p>o  <strong>扇区、块读写校验</strong>：对扇区、块进行校验</p><p>o  <strong>磁盘间读写校验：</strong>对多个磁盘间共同构成的信息读写做校验</p><h2 id="DBMS数据存储的映射关系："><a href="#DBMS数据存储的映射关系：" class="headerlink" title="DBMS数据存储的映射关系："></a>DBMS数据存储的映射关系：</h2><p>·     逻辑中表的每一条记录都有一个映射表，用来记录存储的磁盘号。</p><p>·     数据库通过操作系统先占用磁盘块，然后通过自己的映射表来保存记录和对应的磁盘块。</p><p>·     通过内存缓存磁盘块。</p><p><img src="clip_image544.jpg" alt="img"></p><p>查询操作-文件管理-缓存区交互-磁盘管理</p><p><img src="clip_image546.jpg" alt="img"></p><h2 id="数据库记录和磁盘块的记录："><a href="#数据库记录和磁盘块的记录：" class="headerlink" title="数据库记录和磁盘块的记录："></a>数据库记录和磁盘块的记录：</h2><p><img src="clip_image548.jpg" alt="img"></p><p>·     定长记录：按长度区分</p><p>·     变长记录：按照标志区分</p><p><img src="clip_image550.jpg" alt="img"></p><p>·     记录的跨块存储：靠着指针连接</p><p>·     数据库所占磁盘块的分配方法：</p><p>o  连续分配：数据块被分配到连续的磁盘块上</p><p>o  链接分配：数据块中包含指向下一个数据块的指针</p><p>o  按簇分配：簇是若干连续的磁盘块，簇之间靠指针进行连接。</p><h2 id="数据组织与存储方法："><a href="#数据组织与存储方法：" class="headerlink" title="数据组织与存储方法："></a>数据组织与存储方法：</h2><p>·     <strong>数据组织：</strong>指的是数据组织成记录、块和访问结构的方式，包括把记录和块存储在磁盘上的方式，以及记录和块之间相互联系的方法。</p><p>·     <strong>存取方法：</strong>指的是对文件所采取的存取防范。</p><h3 id="文件组方法："><a href="#文件组方法：" class="headerlink" title="文件组方法："></a>文件组方法：</h3><p>·     无序记录文件：（堆文件）</p><p>o  特点：可以存储于任意空间位置，磁盘存储的记录是无序</p><p>o  新记录总插入到尾部，在删除记录所在位置标记为删除</p><p>o  新增记录可以利用那些被删除的记录。</p><p>o  数据库需要定时进行数据库重组，移走被删除的记录。</p><p>o  按照输入顺序进行排序存储</p><p>·     有序存储：</p><p>o  记录按照属性或者属性组值顺序插入，磁盘上存储的记录是有序的，检索效率很高。</p><p>o  但是更新效率很低，需要移动其他记录，为插入记录留出空间。</p><p>o  改进措施是可以将未来插入的元组预留空间，或者使用一个临时的无序文件，保留新增记录。但是当溢出文件较大时性能会受到影响。</p><p><img src="clip_image552.jpg" alt="img"></p><p>o  数据库重组：将溢出文件重组排序到主文件中。</p><p>·     散列文件：</p><p>o  特点：按照记录的某些属性或者属性组的值，根据散列函数来计算其存放的位置：桶号</p><p>o  用于散列函数计算的属性通常被称为散列字段，散列字段通常采用关系中的主码，所以又称为散列码。</p><p><img src="clip_image554.jpg" alt="img"></p><p>·     不同的记录可能被放到同一个桶，桶内需要顺序查找。</p><p>·     聚簇文件：</p><p>·     将相同或者属性值相似的记录存放于连续的磁盘块簇中</p><p>·     多表聚簇：将若干个相互关联的Table存储于一个文件中，这可以提高多表查询下的查询速度。</p><p>·     <img src="clip_image556.jpg" alt="img"></p><p><img src="clip_image558.jpg" alt="img"></p><p>增删改需求：无序记录文件、散列记录文件。</p><p>检索需求：有序记录文件。</p><p>在性能下降之后使用数据库重组。</p><h2 id="Oracle数据库的数据组织："><a href="#Oracle数据库的数据组织：" class="headerlink" title="Oracle数据库的数据组织："></a>Oracle数据库的数据组织：</h2><p>·     每个数据库分成一个或多个表空间</p><p>·     分为SYSTEM表空间和用户表空间，SYSTEM表空间用于存储数据字典的管理，用户表空间可以由用户创建</p><p>·     每个表空间由一个或者多个操作系统文件构成。</p><p>·     一个表可以存在一个文件中也可以存储在多个文件中，在进入DBMS后由DBMS进行组织</p><p>数据库索引</p><p>2020年6月23日</p><p>14:20</p><h2 id="索引："><a href="#索引：" class="headerlink" title="索引："></a>索引：</h2><p>·     所以是定义在存储表基础之上，有助于无需检查所有记录而快速定位所需记录的一种辅助存储结构，由一系列存储在磁盘上的索引项组成，每一索引项又由两部分组成：</p><p>o  索引字段：由Table中的某些列的值组成，索引中通常存储了索引字段的每一个值。</p><p>o  行指针：指向Table中包含索引字段值的记录在磁盘上的存储位置。</p><p>·     存储索引项为索引文件，相对应存储表又称为主文件。</p><h2 id="索引文件："><a href="#索引文件：" class="headerlink" title="索引文件："></a>索引文件：</h2><p>·     索引文件是一种辅助存储结构，其存在与否不改变存储表的物理存储结构，然而其存在可以显著提高存储表的访问速度。索引文件也有多种组织方式：</p><p>o  排序索引文件：按照索引字段的某一种顺序组织存储</p><p>o  散列索引文件：按照索引字段值使用散列函数分配散列桶的方式索引</p><p>·     在一个表上可以针对不同的属性或者属性组合建立不同的索引文件，可以建立多个索引文件。索引字段的值可以是Table中任何一个属性的值或者多个属性值的组合值</p><p>·     索引文件比主文件小很多，通过检索一个小的索引文件，可以快速定位，然后再针对性读取非常大的主文件，</p><p>·     有索引的时候，必须同步更新索引文件和主文件。</p><p>·     索引技术可以使得检索效率大幅度提高，但也增加了存储空间</p><p>·     衡量索引性能的好坏：</p><p>o  访问时间</p><p>o  插入时间</p><p>o  删除时间</p><p>o  空间负载</p><p>o  支持存储的有效性：是否支持多属性，属性索引的范围…</p><p>·     索引字段：</p><p>o  字段、排序字段、索引字段</p><p>o  码，主码，表键：具有唯一性和最小性</p><p>o  排序码：对主文件进行排序的那些属性或者属性组</p><p>o  索引码：索引字段，不一定具有唯一性</p><p>o  搜索码：在主文件中查找记录的属性或属性集</p><h2 id="-6"><a href="#-6" class="headerlink" title=" "></a> </h2><h2 id="索引的定义："><a href="#索引的定义：" class="headerlink" title="索引的定义："></a>索引的定义：</h2><p>Create [unique] INDEX indexname </p><p>ON tablename ( colname [asc|desc] {, colname [asc|desc]…})</p><p><img src="clip_image560.jpg" alt="img"></p><p><strong>删除索引：</strong></p><p>Drop INDEX indexname</p><h2 id="稠密索引："><a href="#稠密索引：" class="headerlink" title="稠密索引："></a>稠密索引：</h2><p>·     对主文件中<strong>每一个</strong>记录，都有一个索引项和它对于，指明该记录所在位置</p><p><img src="clip_image562.jpg" alt="img"></p><p>·     候选键属性索引：</p><p>o  每一条索引对应一条记录</p><p><img src="clip_image564.jpg" alt="img"></p><p>·     非候选键索引：</p><p>o  索引文件中的索引字段值是不重复的，主文件按照索引字段排序，且索引字段不是候选键。</p><p>o  <img src="clip_image566.jpg" alt="img"></p><p>o  索引字段可以有重复：</p><p><img src="clip_image568.jpg" alt="img"></p><p>o  引入中间层：</p><p><img src="clip_image570.jpg" alt="img"></p><h2 id="稀疏索引："><a href="#稀疏索引：" class="headerlink" title="稀疏索引："></a>稀疏索引：</h2><p>·     对于主文件中的<strong>部分</strong>记录，都有索引项和它对应</p><p><img src="clip_image572.jpg" alt="img"></p><p>·     索引中不存在搜索码的值，不代表主文件中没有对应搜索码的记录</p><p>·     定位索引字段为K记录的值：</p><p>o  首先找相邻的小于K的最大索引字段值所对应的索引项</p><p>o  从该项所对应的记录开始顺序对Table进行检索，一旦找到比他大的值就结束查找</p><p>·     稀疏索引要求主文件必须按照索引字段属性排序</p><p>·     索引项可以不指向记录指针，而是指向记录所在存储块的指针</p><p><img src="clip_image574.jpg" alt="img"></p><h2 id="主索引："><a href="#主索引：" class="headerlink" title="主索引："></a>主索引：</h2><p>·     对每一个存储块有一个索引项，索引项的综述和存储表所占的存储块数目相同，存储表的每一个存储块的低一些记录，又称为锚记录或者成为块锚</p><p>·     主索引的索引字段值为块锚的索引字段值，而指针指向所在的存储块</p><p>·     <img src="clip_image576.jpg" alt="img"></p><h2 id="辅助索引："><a href="#辅助索引：" class="headerlink" title="辅助索引："></a>辅助索引：</h2><p>·     是定义在主文件的任一个或者多个非排序字段上的辅助存储结构。</p><p>·     辅助对一个非排序字段上的每一个不同值有一个索引项：索引字段即是该字段的不同值，而指针则包含该记录的块活该记录本身</p><p>·     当非排序字段为索引字段时，如该字段值不唯一，则需要采用一个链表结构来保存字段值记录的所有位置。</p><p><img src="clip_image578.jpg" alt="img"></p><p>·     辅助索引是一个稠密索引</p><p>·     一个主文件仅可以有一个主索引，但可以有多个辅助索引</p><p>·     主索引通常建立在主码/排序码上，辅助索引建立与其他属性上</p><p>·     可以利用主索引重新组织文件数据，但辅助索引不能改变主文件数据</p><p>·     主索引指向块地址，辅助索引不能仅指向块地址。</p><p><img src="clip_image580.jpg" alt="img"></p><h2 id="聚簇索引："><a href="#聚簇索引：" class="headerlink" title="聚簇索引："></a>聚簇索引：</h2><p>·     索引中临近的记录在主文件中也是临近存储的</p><h2 id="非聚簇索引："><a href="#非聚簇索引：" class="headerlink" title="非聚簇索引："></a>非聚簇索引：</h2><p>·     索引中临近的记录在主文件中不一定是临近存储的</p><p><img src="clip_image582.jpg" alt="img"></p><p>·     如果主文件的某一排序字段不是主码，则该字段上每一个记录取值便不唯一，此时该字段被称为聚簇字段，聚簇索引通常是定义在聚簇字段上的。</p><p>·     聚簇索引通常是对聚簇字段上的每一个不同值有一个索引项</p><p>·     主文件只有一个聚簇索引文件，但可以有多个非聚簇索引文件</p><p>·     主索引通常是是聚簇索引，辅助索引通常是非聚簇索引</p><h2 id="倒排索引："><a href="#倒排索引：" class="headerlink" title="倒排索引："></a>倒排索引：</h2><p><img src="clip_image584.jpg" alt="img"></p><p><img src="clip_image586.jpg" alt="img"></p><h2 id="B-树索引："><a href="#B-树索引：" class="headerlink" title="B+树索引："></a>B+树索引：</h2><p>是一种以树型数据结构来组织索引项的多级索引</p><p><img src="clip_image588.jpg" alt="img"></p><p>叶子节点指向索引块，或者是数据块中记录的指针</p><p><img src="clip_image590.jpg" alt="img"></p><p>·     能够自动保持与主文件大小相适应的树的层次。</p><p>·     每个索引块的指针利用率都在50%-100%之间。</p><h3 id="B-树的存储约定："><a href="#B-树的存储约定：" class="headerlink" title="B+树的存储约定："></a>B+树的存储约定：</h3><p>一个块中存放n个索引项</p><p><img src="clip_image592.jpg" alt="img"></p><p><img src="clip_image594.jpg" alt="img"></p><h3 id="叶子节点和非叶子节点："><a href="#叶子节点和非叶子节点：" class="headerlink" title="叶子节点和非叶子节点："></a>叶子节点和非叶子节点：</h3><p>·     非叶节点的指针指向索引块，叶子节点指针指向主文件的数据块或数据记录。</p><p>·     叶节点的最后一个指针可能不同于其他指针—始终指向其下一个数据块。</p><p><strong>非叶节点：</strong></p><p><img src="clip_image596.jpg" alt="img"></p><p><strong>叶子节点：</strong></p><p><img src="clip_image598.jpg" alt="img"></p><p>一个索引块实际使用的索引指针个数d，满足：</p><p><img src="clip_image600.jpg" alt="img"></p><p>根节点至少两个指针被使用。</p><p><img src="clip_image602.jpg" alt="img"></p><p>索引字段值：有可能重复出现于叶子节点和非叶子节点</p><p>·     指向主文件的指针仅可能出现于叶节点</p><p>·     所有叶结点即可覆盖所有键值索引</p><p>·     索引字段中在叶节点中按顺序排列。</p><p>B+树仅有叶结点块的集合就是主文件的完整索引，其他每一层都是索引的索引</p><h3 id="-7"><a href="#-7" class="headerlink" title=" "></a> </h3><h3 id="用B-树建立键属性的稠密索引："><a href="#用B-树建立键属性的稠密索引：" class="headerlink" title="用B+树建立键属性的稠密索引："></a>用B+树建立键属性的稠密索引：</h3><p>·     索引字段是主文件的主键，索引是稠密的，主文件可以按照主键排序，也可也不按照主键排序，指针指向的是记录。</p><p><img src="clip_image604.jpg" alt="img"></p><h3 id="B-树建立稀疏索引："><a href="#B-树建立稀疏索引：" class="headerlink" title="B+树建立稀疏索引："></a>B+树建立稀疏索引：</h3><p>·     索引字段是指向的数据块。</p><p><img src="clip_image606.jpg" alt="img"></p><h3 id="B-树建立非键属性稠密索引："><a href="#B-树建立非键属性稠密索引：" class="headerlink" title="B+树建立非键属性稠密索引："></a>B+树建立非键属性稠密索引：</h3><p>·     索引字段是主文件的非键属性，索引是稠密的，主文件按照<strong>非键属性排序</strong></p><p>·     索引文件的索引字段是无重复的，指针指向的是记录</p><p>·     然后再磁盘块上顺序访问，直到访问到不同属性的记录</p><p><img src="clip_image608.jpg" alt="img"></p><h3 id="B-树建立非键属性的稠密索引："><a href="#B-树建立非键属性的稠密索引：" class="headerlink" title="B+树建立非键属性的稠密索引："></a>B+树建立非键属性的稠密索引：</h3><p>·     索引字段是非键属性，主文件不按照此非键属性排序</p><p>·     索引文件的索引字段是有重复的，指针指向的是记录。</p><p>·     B+树中就会有多个重复索引</p><p><img src="clip_image610.jpg" alt="img"></p><h3 id="B-树的节点键值插入与节点分裂过程示意："><a href="#B-树的节点键值插入与节点分裂过程示意：" class="headerlink" title="B+树的节点键值插入与节点分裂过程示意："></a>B+树的节点键值插入与节点分裂过程示意：</h3><p><img src="clip_image612.jpg" alt="img"></p><p><img src="clip_image614.jpg" alt="img"></p><p><img src="clip_image616.jpg" alt="img"></p><h2 id="B-树分裂的条件："><a href="#B-树分裂的条件：" class="headerlink" title="B+树分裂的条件："></a>B+树分裂的条件：</h2><p>·     当节点全满的时候就需要分裂</p><p>·     由叶子节点像根节点逐层处理</p><p>o  自动保持与主文件大小相适应的树的层次</p><p>o  每个索引块的指针利用率都在50%-100%</p><p>·     指针要指向正确的块。</p><h3 id="B-树键值删除的过程："><a href="#B-树键值删除的过程：" class="headerlink" title="B+树键值删除的过程："></a>B+树键值删除的过程：</h3><p><strong>无需合并</strong></p><p><img src="clip_image618.jpg" alt="img"></p><h2 id="需要合并"><a href="#需要合并" class="headerlink" title="需要合并"></a>需要合并</h2><p><img src="clip_image620.jpg" alt="img"></p><p><img src="clip_image622.jpg" alt="img"></p><p><img src="clip_image624.jpg" alt="img"></p><h2 id="B-树删除键值规则："><a href="#B-树删除键值规则：" class="headerlink" title="B+树删除键值规则："></a>B+树删除键值规则：</h2><p>·     当指针数目少于规定数目</p><p>·     由叶节点向根节点逐层处理</p><p>·     指针的调整：调整指针指向正确的位置</p><h2 id="B树："><a href="#B树：" class="headerlink" title="B树："></a>B树：</h2><p>·     索引字段值仅出现一次或者在叶节点或者非叶节点</p><p>·     指向主文件的指针出现于叶节点或非叶节点（中间查询到了就直接退出）</p><p>·     所有节点才能覆盖所有键值的索引</p><p><img src="clip_image626.jpg" alt="img"></p><p>B树索引块和属性块的个数求法：</p><p>已知存储块大小为4096字节，在整型属性(一个整型数值占有4个字节)上建立B树索引，一个指针占有8个字节，则该非叶结点存储块最多能有<strong>__</strong>个索引项和<strong>__</strong>个指针。</p><p>设属性格式为n</p><p>4n+8(2n+2)&lt;=4096</p><p>n=204， 410；</p><h2 id="散列索引："><a href="#散列索引：" class="headerlink" title="散列索引："></a>散列索引：</h2><p><strong>散列：</strong></p><p>·     有M个桶，每个桶都是有相同容量的存储地（可以是内存页，也可以是磁盘块）。</p><p>·     散列函数h(k)，可以将键值k映射到{0，1，…., M-1}中的某一个值。</p><p>·     将具有键值k的记录，存储在编号k的桶中。</p><p><strong>目标：</strong></p><p>·     选择一个合适的散列函数，将record集合中的每一个关键字k均匀映射到M个桶中。</p><p><strong>散列索引：</strong></p><p>·     内存数据可以采用散列确定存储页，主文件可以采用散列确定存储块，索引也可以采用散列确定索引项的存储块。</p><p>·     M个桶，一个桶可以是一个存储块，也可以是若干个连续的存储块。</p><p><img src="clip_image628.jpg" alt="img"></p><p><strong>散列索引的目标：</strong></p><p>·     最好没有溢出桶，每个散列值仅有一个桶，读写每一个键值都只读写一个存储块。</p><p><strong>均匀分布：</strong></p><p>·     设置合理的散列函数，使得每个桶的数据成为具有某种特征值h(k)的数据的集合</p><p><strong>桶的数目M的确定：</strong></p><p>·     当键值多余数倍的桶的数目时，每个散列值都可能多于一个桶，形成一个主桶和多个溢出桶的列表，此时需要二次检索，先散列找到主桶号，然后根据链表逐一找到每一个溢出桶。</p><p>一趟扫描算法</p><p>2020年6月26日</p><p>14:49</p><h2 id="数据库的三大类操作"><a href="#数据库的三大类操作" class="headerlink" title="数据库的三大类操作"></a>数据库的三大类操作</h2><p>·     一次单一元组的操作：Select，Project</p><p>·     整个关系的一元操作：Distince, Group By, Sorting</p><p>·     整个关系的二元操作：</p><p>o  集合上的操作：交、并、差</p><p>o  包上的操作：交、并、差</p><p>o  积、连接：Project，Join</p><h2 id="连接操作的逻辑实现算法："><a href="#连接操作的逻辑实现算法：" class="headerlink" title="连接操作的逻辑实现算法："></a>连接操作的逻辑实现算法：</h2><h3 id="逻辑算法："><a href="#逻辑算法：" class="headerlink" title="逻辑算法："></a>逻辑算法：</h3><p><img src="clip_image630.jpg" alt="img"></p><h3 id="物理算法的考量："><a href="#物理算法的考量：" class="headerlink" title="物理算法的考量："></a>物理算法的考量：</h3><p>·     关系是存储在磁盘上的，磁盘是以磁盘块为操作单位的，首先要先被装载进内存中，然后再进行操作。</p><p><img src="clip_image632.jpg" alt="img"></p><p><strong>基本算法：</strong></p><p>拆分成4层循环，外层是磁盘块的读写。</p><p><img src="clip_image634.jpg" alt="img"></p><p><strong>全主存实现算法：</strong></p><p><img src="clip_image636.jpg" alt="img"></p><p><img src="clip_image638.jpg" alt="img"></p><p><strong>半主存实现算法：</strong></p><p><img src="clip_image640.jpg" alt="img"></p><p><img src="clip_image642.jpg" alt="img"></p><p><strong>大关系实现算法：</strong></p><p><img src="clip_image644.jpg" alt="img"></p><p><img src="clip_image646.jpg" alt="img"></p><p><img src="clip_image648.jpg" alt="img"></p><p><img src="clip_image650.jpg" alt="img"></p><h3 id="算法比较："><a href="#算法比较：" class="headerlink" title="算法比较："></a>算法比较：</h3><p><img src="clip_image652.jpg" alt="img"></p><h2 id="迭代器构造查询实现算法："><a href="#迭代器构造查询实现算法：" class="headerlink" title="迭代器构造查询实现算法："></a>迭代器构造查询实现算法：</h2><p><img src="clip_image654.jpg" alt="img"></p><h3 id="迭代器："><a href="#迭代器：" class="headerlink" title="迭代器："></a>迭代器：</h3><p>·     迭代的读取集合中的每一个元素，而封装其读取细节。</p><p>定义了一个迭代器：</p><p>·     包括Open，GetNext，Close三个函数</p><p><strong>R**</strong>的迭代器**</p><p><img src="clip_image656.jpg" alt="img"></p><p><strong>Union**</strong>（R,S）**</p><p><img src="clip_image658.jpg" alt="img"></p><p><strong>Selection(R)</strong></p><p><img src="clip_image660.jpg" alt="img"></p><p><strong>Projection(Selection (R))</strong></p><p><img src="clip_image662.jpg" alt="img"></p><p><strong>Join**</strong>（R,S）:**</p><p><img src="clip_image664.jpg" alt="img"></p><h2 id="一趟扫描算法："><a href="#一趟扫描算法：" class="headerlink" title="一趟扫描算法："></a>一趟扫描算法：</h2><h3 id="关系的读取：完整的读取一个关系"><a href="#关系的读取：完整的读取一个关系" class="headerlink" title="关系的读取：完整的读取一个关系"></a>关系的读取：完整的读取一个关系</h3><p><img src="clip_image666.jpg" alt="img"></p><p>·     聚簇关系：关系的元组集中存放</p><p>o  TableScan（R）:表空间扫描算法</p><p>·     扫描结果未排序：B( R )</p><p>o  SortTableScan( R ):</p><p>·     扫描结果排序：3B( R )</p><p>·     非聚簇关系：关系的元组不一定集中存放</p><p>o  扫描结果未排序：T（R）</p><p>o  扫描结果排序：T（R）+2B （R）</p><h3 id="去重操作："><a href="#去重操作：" class="headerlink" title="去重操作："></a>去重操作：</h3><p>·     需要内存中保存已处理的元组。</p><p>·     当新元组到达时，需与之前处理过的元组进行比较。</p><p>·     建立不同的内存数据结构，来保存之前处理过的数据，以便快速处理整个关系上的操作。</p><p>·     复杂性：B( R )</p><p>·     应用复杂性：B(&amp;( R )) &lt;=M</p><p><img src="clip_image668.jpg" alt="img"></p><h3 id="分组聚集："><a href="#分组聚集：" class="headerlink" title="分组聚集："></a>分组聚集：</h3><p>·     需要在内存中保存所有的分组</p><p>·     保存每个分组上的聚集信息</p><p>·     复杂性：B( R )</p><p>·     应用复杂性：所有的分组数量应该能在内存中完整保存。</p><p><img src="clip_image670.jpg" alt="img"></p><h3 id="集合上的操作和包上的操作：交、并、差"><a href="#集合上的操作和包上的操作：交、并、差" class="headerlink" title="集合上的操作和包上的操作：交、并、差"></a>集合上的操作和包上的操作：交、并、差</h3><p>·     扫描一个关系，然后再扫描另一个关系</p><p>·     集合上的操作还需要去重复，包上的操作需要计数每个元组出现的次数。</p><p>·     复杂性：B(R )+ B(S )</p><p>·     应用复杂性：min(B(R ), B(S ))&lt;=M</p><p><img src="clip_image672.jpg" alt="img"></p><h2 id="基于索引的选择算法："><a href="#基于索引的选择算法：" class="headerlink" title="基于索引的选择算法："></a>基于索引的选择算法：</h2><p>·     选择条件中有涉及到索引属性时，可以使用索引，辅助快速检索</p><p>·     在某些属性上存在索引，可能在多个属性上都存在索引</p><p><img src="clip_image674.jpg" alt="img"></p><p><img src="clip_image676.jpg" alt="img"></p><p><img src="clip_image678.jpg" alt="img"></p><p>两趟扫描算法</p><p>2020年6月27日</p><p>7:24</p><p>当内存远远小于元组的块数时，则需要两趟排序算法。</p><p><strong>第一趟：</strong></p><p>·     划分子集，并使得子集具有某种特性，如有序或相同散列值等。</p><p><strong>第二趟：</strong></p><p>·     处理全局性内容的操作，形成结果关系。如多子集间的归并排序，相同散列值子集的操作等。</p><p>大数据集上的操作可否等于（子集上操作）的并集 ？</p><p>例如：元组在某一子集上无重复即可 相当于在全集上无重复。</p><h2 id="两阶段多路归并排序TPMMS："><a href="#两阶段多路归并排序TPMMS：" class="headerlink" title="两阶段多路归并排序TPMMS："></a>两阶段多路归并排序TPMMS：</h2><p>·     内排序问题：待排序数据可以一次性装入内存</p><p>·     外排序问题：待排序数据不能一次性装入内存</p><p>·     <img src="clip_image680.jpg" alt="img"></p><p><img src="clip_image682.jpg" alt="img"></p><p><img src="clip_image684.jpg" alt="img"></p><p><img src="clip_image686.jpg" alt="img"></p><p><img src="clip_image688.jpg" alt="img"></p><p>·     <img src="clip_image690.jpg" alt="img"></p><p>·     <img src="clip_image692.jpg" alt="img"></p><p>算法的条件：</p><p>·     <img src="clip_image694.jpg" alt="img"></p><p>·     <img src="clip_image696.jpg" alt="img"></p><p>·     <img src="clip_image698.jpg" alt="img"></p><p><strong>当更大规模的数据集排序时，可采用多趟排序</strong></p><p><img src="clip_image700.jpg" alt="img"></p><p><img src="clip_image702.jpg" alt="img"></p><h2 id="基于散列的两趟扫描算法："><a href="#基于散列的两趟扫描算法：" class="headerlink" title="基于散列的两趟扫描算法："></a>基于散列的两趟扫描算法：</h2><p>大数据集上的操作 可以转换为某个子集上的操作</p><p>第一趟散列的目的是使数据子集具有某一种特性(如具有相同的散列值)，而第二趟散列的目的是提高数据处理的速度。</p><p><img src="clip_image704.jpg" alt="img"></p><h3 id="Dinstinct"><a href="#Dinstinct" class="headerlink" title="Dinstinct"></a>Dinstinct</h3><p><img src="clip_image706.jpg" alt="img"></p><p><img src="clip_image708.jpg" alt="img"></p><h3 id="分组计算"><a href="#分组计算" class="headerlink" title="分组计算"></a>分组计算</h3><p><img src="clip_image710.jpg" alt="img"></p><p><img src="clip_image712.jpg" alt="img"></p><h3 id="集合上的并、交、差"><a href="#集合上的并、交、差" class="headerlink" title="集合上的并、交、差"></a>集合上的并、交、差</h3><p><img src="clip_image714.gif" alt="这里写图片描述"></p><p><img src="clip_image716.jpg" alt="img"></p><h3 id="基于散列的连接操作"><a href="#基于散列的连接操作" class="headerlink" title="基于散列的连接操作"></a>基于散列的连接操作</h3><p><img src="clip_image718.jpg" alt="img"></p><p><img src="clip_image720.jpg" alt="img"></p><p>查询优化</p><p>2020年6月27日</p><p>10:39</p><h2 id="查询优化："><a href="#查询优化：" class="headerlink" title="查询优化："></a>查询优化：</h2><p>·     语义优化：利用模型的语义以及完整性，优化查询</p><p>·     语法优化：逻辑层优化，利用语法结构，优化操作执行顺序</p><p>·     执行优化：物理层优化，存取路径和执行算法的选择与执行次序优化</p><h2 id="逻辑优化、语法优化："><a href="#逻辑优化、语法优化：" class="headerlink" title="逻辑优化、语法优化："></a>逻辑优化、语法优化：</h2><p><strong>基本思想：</strong></p><p>·     改变关系代数的操作次序，尽可能早做选择和投影</p><p>·     关系代数的基本操作中哪些能交换次序</p><p>·     次序改变前后两个表达式等价</p><p>·     关系代数表达式等价变化定理</p><h3 id="逻辑优化的策略："><a href="#逻辑优化的策略：" class="headerlink" title="逻辑优化的策略："></a>逻辑优化的策略：</h3><p>·     尽可能早做选择和投影：减少中间结果</p><p>·     把选择与投影串联起来：只用做一次扫描</p><p>·     把投影与前或后的二元运算结合起来：在用关系时去掉一些无关属性</p><p>·     把某些选择与其前的笛卡尔积合并成一个连接：当RxS前有选择运算且其中有条件是R、S属性间相比较运算时，可将其转换为连接运算，可以节省时间。</p><h2 id="物理优化、执行优化："><a href="#物理优化、执行优化：" class="headerlink" title="物理优化、执行优化："></a>物理优化、执行优化：</h2><p>为每个关系代数操作选取优化的执行层程序，形成物理查询计划</p><p><strong>基本思想：</strong></p><p>·     获取数据库的相关信息（定期统计）。</p><p>·     选取相应的执行层例行程序。</p><p>·     依据相关信息进行代价估算，并选择代价最少的例行程序以及确定相应的参数。</p><h2 id="关系代数操作次序的等价性："><a href="#关系代数操作次序的等价性：" class="headerlink" title="关系代数操作次序的等价性："></a>关系代数操作次序的等价性：</h2><p>基本关系代数：并、差、积、选择、投影。</p><p><img src="clip_image722.jpg" alt="img"></p><p>（同名属性，顺序不同）</p><p><strong>定理L1:连接与连接，积与积的交换律</strong></p><p><strong>考虑把哪个关系装入内存</strong></p><p><img src="clip_image724.jpg" alt="img"></p><p><strong>定理L2：连接与连接，积与积的结合律</strong></p><p><strong>考虑把哪个关系先计算</strong></p><p><img src="clip_image726.jpg" alt="img"></p><p><strong>定理L3：投影串接律</strong></p><p>·     <strong>投影运算可以向下或向上移动</strong></p><p>·     <strong>先做更多属性的投影，然后再做更少属性的投影，这时候更少属性的投影就没有意义了。</strong></p><p><img src="clip_image728.jpg" alt="img"></p><p><strong>定理L4：选择串接律</strong></p><p><img src="clip_image730.jpg" alt="img"></p><p><strong>定理L5：选择和投影交换律</strong></p><p><strong>条件F需要只涉及投影的属性，如果不满足则需要扩展属性达到F中的全部属性</strong></p><p><img src="clip_image732.jpg" alt="img"></p><p><strong>定理L6：选择和积的交换律</strong></p><p><strong>尽可能的早做选择</strong></p><p><img src="clip_image734.jpg" alt="img"></p><p><strong>定理L7：投影和积的交换律</strong></p><p><img src="clip_image736.jpg" alt="img"></p><p><strong>定理L8：选择和并的交换律</strong></p><p><img src="clip_image738.jpg" alt="img"></p><p><strong>定理L9：选择和差的交换律</strong></p><p><img src="clip_image740.jpg" alt="img"></p><p><strong>定理L9：投影和并的交换律</strong></p><p><img src="clip_image742.jpg" alt="img"></p><h2 id="关系代数查询优化算法："><a href="#关系代数查询优化算法：" class="headerlink" title="关系代数查询优化算法："></a>关系代数查询优化算法：</h2><p><img src="clip_image744.jpg" alt="img"></p><p><strong>例子：</strong></p><p><img src="clip_image746.jpg" alt="img"></p><p><img src="clip_image748.jpg" alt="img"></p><p>这一步的构造思路是把\Pi TITLE 和F3一起根据L3构造</p><p><img src="clip_image750.jpg" alt="img"></p><p><img src="clip_image752.jpg" alt="img"></p><p><strong>乘积操作和其后选择操作构成连接</strong></p><p><img src="clip_image754.jpg" alt="img"></p><div class="table-container"><table><thead><tr><th></th><th><img src="clip_image756.jpg" alt="img"></th></tr></thead><tbody><tr><td></td></tr></tbody></table></div><p><strong>七、非SPJ优化</strong></p><p>1.GROUP BY优化</p><p>1) 分组转换技术：对分组操作、聚集操作与连接操作的位置进行交换</p><p>a) 分组操作下移：GROUP BY操作可能较大幅度减少关系元组的个数，如果能够对某个关系先进行分组操作，然后再进行表之间的连接，很可能提高连接效率。这种优化方式是把分组操作提前执行。下移的含义，是在查询树上，让分组操作尽量靠近叶子节点，使得分组操作的节点低于一些选择操作。</p><p>b) 分组操作上移：如果连接操作能够过滤掉大部分元组，则先进行连接操作，后进行GROUP BY操作，可能提高分组操作的效率。这种优化方式是把分组操作置后执行。上移的含义和下移相反。</p><p>2) MySQL的GROUP BY优化：MySQL对于GROUP BY的处理，通常采用的方式是扫描整个表、创建一个临时表以执行分组操作。MySQL不支持分组转换技术。<strong>对于GROUP BY的优化，尽量利用索引。</strong></p><p>利用索引的条件：分组子句中的列对象源自同一个BTREE索引(不支持利用HASH索引进行优化)的全部或前缀部分的部分有序的键(分组使用的索引列与索引建立的顺序不匹配则不能使用索引)。　　　　 </p><p>2.ORDER BY优化</p><p>ORDER BY 如果操作的列不是主键或索引等，会创建一个临时表(Using temporary、Using flesort)</p><p>1) 排序消除：优化器在生成执行计划前，将语句中没有必要的排序操作消除(如利用索引)，避免在执行计划中出现排序操作或由排序导致的操作(如在索引列上排序，可以利用索引消除排序操作)</p><p>2) 排序下推：把排序操作尽量下推到基表中，有序的基表进行连接后的结果符合排序的语义，这样能避免在最终的大的连接结果集上执行排序操作。</p><p>3.DISTINCT优化</p><p>DISTINCT操作的列，如果该列有索引(唯一性约束)或者为主键，则直接使用索引排序；否则会使用一张临时表(Using temporary)，先去重，再排序(可以看到输出结果是根据该列排好序的)。</p><p>1) DISTINCT消除：如果表中存在主键、唯一约束、索引等，则可以消除查询语句中的DISTINCT </p><p>2) DISTINCT推入：生成含DISTINCT的反半连接查询执行计划时，先进行反半连接再进行DISTINCT操作；也许先执行DISTINCT操作再执行反半连接，可能更优。</p><p>3) DISTINCT迁移：对连接操作的结果执行DISTINCT，可能把DISTINCT移到一个子查询中优先进行</p><p><strong>总结：GROUP BY / ORDER BY / DISTINCT 优化尽量利用索引、主键、唯一性约束，这样可以不创建临时表。</strong></p><p>4.LIMIT优化</p><p>1) LIMIT对单表扫描的影响：如果索引扫描可用且花费低于全表扫描，则用索引扫描实现LIMIT(LIMIT取出很少量的行，否则优化器更倾向于使用全表扫描)</p><p>2) LIMIT对排序的影响：如果LIMIT和ORDER BY子句协同使用，当取到LIMIT设定个数的有序元组数后，后续的排序操作将不再进行。</p><p>3) LIMIT对去重的影响：如果LIMIT和DISTINCT子句协同使用，当取到LIMIT设定个数的唯一元组数后，后续的去重操作将不再进行。</p><p>4) LIMIT受分组的影响：如果LIMIT和GROUP BY子句协同使用，GROUP BY按索引有序计算每个组的总数的过程中，LIMIT操作不必计数直到下一个分组开始。</p><p>5) LIMIT 0：直接返回空结果集。</p><p>6) MYSQL支持对不带HAVING的子句进行优化。</p><p>5.常见的一些优化规则</p><p>1) 在索引键上执行排序操作，通常利用索引的有序性按序读取数据而不进行排序。</p><p>2) 选择率低于10%时，利用索引的效果通常比读取表数据的效果好。</p><p>3) 当表的数据量较少时，全表扫描可能优于其它方式(如索引)。</p><p>来自 <a href="[*https://www.cnblogs.com/chiangchou/p/mysql-6.html*](https://www.cnblogs.com/chiangchou/p/mysql-6.html)">[*https://www.cnblogs.com/chiangchou/p/mysql-6.html*](https://www.cnblogs.com/chiangchou/p/mysql-6.html)</a></p><h2 id="物理层查询优化："><a href="#物理层查询优化：" class="headerlink" title="物理层查询优化："></a>物理层查询优化：</h2><p>物理查询运算符</p><p>·     获取关系元组的操作</p><p>·     关系操作的各种实现算法</p><p>·     迭代器构造—流水化、物化</p><p><img src="clip_image758.jpg" alt="img"></p><p>DBMS提供了一些命令用于收集这些信息，但是这些信息需要DBA进行手动的统计。</p><p><img src="clip_image760.jpg" alt="img"></p><p><img src="clip_image762.jpg" alt="img"></p><h2 id="代价估算："><a href="#代价估算：" class="headerlink" title="代价估算："></a>代价估算：</h2><p><strong>投影运算的估计</strong></p><p><img src="clip_image764.jpg" alt="img"></p><p><strong>选择运算的估计</strong></p><p><img src="clip_image766.jpg" alt="img"></p><p><img src="clip_image768.jpg" alt="img"></p><p><img src="clip_image770.jpg" alt="img"></p><p><strong>连接运算：</strong></p><p><img src="clip_image772.jpg" alt="img"></p><p><strong>总结：</strong></p><p><img src="clip_image774.jpg" alt="img"></p><p>并发控制</p><p>2020年6月27日</p><p>17:22</p><h2 id="事务处理技术"><a href="#事务处理技术" class="headerlink" title="事务处理技术"></a>事务处理技术</h2><p>·     事物是数据库管理系统提供的控制数据操作的一组手段，通过这一手段，应用程序员将一系列的数据库操作组合在一起作为一个整体进行操作和控制以便数据库管理系统能够提供一致性状态转换的保证</p><h2 id="事务的宏观性："><a href="#事务的宏观性：" class="headerlink" title="事务的宏观性："></a>事务的宏观性：</h2><p>·     一个存取或改变数据库内容的程序的一次执行，或者说一条或多条SQL语句的一次执行被看作是一个事物</p><p>·     事物一般由程序员提出，因此有开始和结束，结束前需要提交或者撤销</p><h2 id="事务的微观性："><a href="#事务的微观性：" class="headerlink" title="事务的微观性："></a>事务的微观性：</h2><p>·     对数据库的一系列基本操作的整体执行</p><h2 id="事务的特性：ACID-1"><a href="#事务的特性：ACID-1" class="headerlink" title="事务的特性：ACID"></a>事务的特性：ACID</h2><p>·     <strong>原子性</strong>：DBMS保证事务的一组更新操作是原子不可分的</p><p>·     <strong>一致性：</strong>DBMS保证事务的操作状态是正确的，符合一致性的操作规则，不能出现三种典型的不一致性</p><p>·     <strong>隔离性</strong>：BDMS保证并发执行的多个事务之间互相不受到影响</p><p>·     <strong>持久性：</strong>DBMS保证已提交的事务的影响是持久的，而可撤销的事务影响是可恢复的</p><p>具有ACID的一组操作被称为事务。</p><h2 id="事务调度："><a href="#事务调度：" class="headerlink" title="事务调度："></a>事务调度：</h2><p>·     一组事务的基本步骤（读、写、其他控制操作如加锁、解锁）的一种执行顺序称为这组事务的一个调度，并发（或并行）调度：多个事务从宏观上看是并行的，但其微观上基本操作则是交叉执行的。</p><h2 id="并发调度的正确性："><a href="#并发调度的正确性：" class="headerlink" title="并发调度的正确性："></a>并发调度的正确性：</h2><p>·     当且仅当一个并发调度下 得到的新数据库结果与分别串行运行这些事务得到的结果一致</p><h2 id="可串行性："><a href="#可串行性：" class="headerlink" title="可串行性："></a>可串行性：</h2><p>·     如果不管数据库的初始状态如何，一个调度对数据库的状态影响都和某个串行调度相同，则我们说这个调度是可串行化的。</p><p>·     <strong>可串行化调度一定是正确的并行调度，但是正确的并行调度不一定都是可串行化的调度。</strong></p><p>·     <strong>并行调度的正确性是结果上的，不考虑过程如何。而可串行性是指形式上的正确性。</strong></p><h2 id="冲突："><a href="#冲突：" class="headerlink" title="冲突："></a>冲突：</h2><p>·     调度中一对连续的工作，如果他们满足：顺讯交换，那么涉及的事务至少有一个事务的行为会改变。</p><p>o  同一个事务的任何两个操作都是冲突的。</p><p><img src="clip_image776.jpg" alt="img"></p><p>o  不同事物对同一个元素的两个写操作是冲突的。</p><p><img src="clip_image778.jpg" alt="img"></p><p>o  不同事物对同一个元素的一读一写是冲突的。</p><p><img src="clip_image780.jpg" alt="img"></p><h2 id="冲突可串行性："><a href="#冲突可串行性：" class="headerlink" title="冲突可串行性："></a>冲突可串行性：</h2><p>·     如果一个调度，通过交换相邻两个无冲突的操作哦能够转换到某一个串行调度，则称此调度为冲突可串行化调度。</p><p>·     <strong>冲突可串行新是比可串行性更严格的概念</strong></p><p>·     <strong>满足冲突可串行性一定满足可串行性，反之不然</strong></p><p><img src="clip_image782.jpg" alt="img"></p><h2 id="冲突可串行性的判别算法："><a href="#冲突可串行性的判别算法：" class="headerlink" title="冲突可串行性的判别算法："></a>冲突可串行性的判别算法：</h2><p>·     构造一个前驱图</p><p>·     <img src="clip_image784.jpg" alt="img"></p><p>·     测试检查：如果此有向图没有环，则冲突是可串行化的</p><p><img src="clip_image786.jpg" alt="img"></p><h2 id="基于封锁的控制并发手段："><a href="#基于封锁的控制并发手段：" class="headerlink" title="基于封锁的控制并发手段："></a>基于封锁的控制并发手段：</h2><p>锁 是一种控制并发的手段：</p><p>·     每一个数据元素都有唯一的锁</p><p>·     每一事务读写数据元素前，要获得所</p><p>·     如果被其他事务持有元素的锁，则要等待</p><p>·     事务处理完之后要释放锁。</p><p>锁 本身不能保证冲突可串行性</p><p>锁 为调度提供了控制的手段，但如何用锁仍需要说明</p><h2 id="锁的类型："><a href="#锁的类型：" class="headerlink" title="锁的类型："></a>锁的类型：</h2><p>·     排他锁：</p><p>o  只有一个事务可以读、写，其他任何事务都能不能对该事务进行读、写</p><p>·     共享锁：</p><p>o  所有事务可以读，但任何事务都不能写。</p><p>·     更新锁：</p><p>o  初始读，以后升级为可写</p><p>·     增量锁I</p><p>o  增量更新，例如A=A+x</p><p>o  区分增量更新和其他类型的更新</p><p><img src="clip_image788.jpg" alt="img"></p><p><img src="clip_image788.jpg" alt="img"></p><h2 id="0级协议：加锁、解锁的时机"><a href="#0级协议：加锁、解锁的时机" class="headerlink" title="0级协议：加锁、解锁的时机"></a>0级协议：加锁、解锁的时机</h2><p><img src="clip_image790.jpg" alt="img"></p><h2 id="1级协议："><a href="#1级协议：" class="headerlink" title="1级协议："></a>1级协议：</h2><p><img src="clip_image792.jpg" alt="img"></p><h2 id="2级协议："><a href="#2级协议：" class="headerlink" title="2级协议："></a>2级协议：</h2><p><img src="clip_image794.jpg" alt="img"></p><h2 id="3级协议："><a href="#3级协议：" class="headerlink" title="3级协议："></a>3级协议：</h2><p><img src="clip_image796.jpg" alt="img"></p><h2 id="SQL隔离性级别："><a href="#SQL隔离性级别：" class="headerlink" title="SQL隔离性级别："></a>SQL隔离性级别：</h2><p>·     读未提交：0级协议</p><p>·     读已提交：1级协议</p><p>·     可重复读：2级协议</p><p>·     可串行化：3级协议</p><p><img src="clip_image798.jpg" alt="img"></p><p>幻读：</p><p><img src="clip_image800.jpg" alt="img"></p><h2 id="封锁粒度："><a href="#封锁粒度：" class="headerlink" title="封锁粒度："></a>封锁粒度：</h2><p>·     封锁粒度：是指封锁数据对象的大小</p><p>·     粒度单位：属性值-元组-元组集合-整个关系-整个DB-某个索引项-整个索引</p><p>·     由前往后：并发度小，封锁开销小</p><h2 id="两段封锁协议："><a href="#两段封锁协议：" class="headerlink" title="两段封锁协议："></a>两段封锁协议：</h2><p>·     <strong>读写数据之前都要获得锁</strong>，每个事物中所有的封锁请求都要先于任何一个解锁请求</p><p>·     两阶段：加锁段，解锁段，加锁段中不能有解锁操作，解锁段中不能有加锁操作。</p><p><img src="clip_image802.jpg" alt="img"></p><p><img src="clip_image804.jpg" alt="img"></p><h2 id="基于时间戳的并发控制方法："><a href="#基于时间戳的并发控制方法：" class="headerlink" title="基于时间戳的并发控制方法："></a>基于时间戳的并发控制方法：</h2><p><strong>时间戳：</strong></p><p>·     一种基于时间的标志，将某一时刻转换成的一个数值。</p><p>·     时间戳具有唯一性和传递性。</p><p><strong>事务的时间戳：</strong></p><p>·     事务T启动时，系统将该时时刻赋予为T</p><p>·     时间戳可以表征一系列事物执行的先后次序，时间戳小的事务先执行，时间戳大的事务后执行</p><p>·     利用时间戳，可以不用锁，来实现并发控制。</p><h2 id="基于时间戳的并发控制："><a href="#基于时间戳的并发控制：" class="headerlink" title="基于时间戳的并发控制："></a>基于时间戳的并发控制：</h2><p>·     借助时间戳，强制使得一组并发事务交叉执行，等价于一个特定顺序的串行执行</p><p>·     特定顺序：时间戳由小到大</p><p>·     如何强制：执行时判断冲突</p><p>o  如果没有冲突，允许执行</p><p>o  如有冲突，则撤销事务，并重启该事务，此时该事务获得了一个更大时间戳，表明是后执行的事务。</p><p>·     冲突类型：</p><p>o  读-读：无冲突</p><p>o  读-写或者写-读冲突</p><p>o  写-写冲突</p><h2 id="调度规则"><a href="#调度规则" class="headerlink" title="调度规则:"></a>调度规则:</h2><p><strong>核心规则：先执行的先操作</strong></p><p>对DB中的每个数据元素x，系统个保留其上最大时间戳</p><p>·     RT(X)：读过该数据事务中的最大时间戳，即最后读x的事务时间戳</p><p>·     WT(X)：写过该数据事务中的最大时间戳，即最后写x的事务时间戳</p><p>·     TS(T)：事务的时间线</p><p><img src="clip_image806.jpg" alt="img"></p><p><img src="clip_image808.jpg" alt="img"></p><p><img src="clip_image810.jpg" alt="img"></p><p><img src="clip_image812.jpg" alt="img"></p><p>以上规则不能解决：</p><p>·     脏读：读的数据被撤销</p><p>·     托马斯写：先写的事务被后写的覆盖</p><h2 id="调度规则2："><a href="#调度规则2：" class="headerlink" title="调度规则2："></a>调度规则2：</h2><p><img src="clip_image814.jpg" alt="img"></p><p><img src="clip_image816.jpg" alt="img"></p><p><img src="clip_image818.jpg" alt="img"></p><p><img src="clip_image820.jpg" alt="img"></p><h2 id="基于有效性确认的并发控制方法："><a href="#基于有效性确认的并发控制方法：" class="headerlink" title="基于有效性确认的并发控制方法："></a>基于有效性确认的并发控制方法：</h2><p>·     事务在启动时刻被赋予唯一的时间戳，以示其启动顺序</p><p>·     为每一个活跃事务保存其读写数据的集合，RS(T)：事务T读数据集合，WS(T)：事务T写数据集合</p><p>·     通过对多个事务的读写集合，判断是否有冲突，即有效性确认，来完成事务的提交和回滚，强制事务以可串行化的方式执行。</p><h3 id="基于有效性确认的调度器："><a href="#基于有效性确认的调度器：" class="headerlink" title="基于有效性确认的调度器："></a>基于有效性确认的调度器：</h3><p>·     事务在启动时刻被赋予唯一的时间戳，以示其启动顺序</p><p>·     为每一个活跃事务保存其读写数据的集合，RS(T)：事务T读数据集合，WS(T)：事务T写数据集合</p><p>·     事务分为三个阶段：</p><p>o  读阶段：事务从数据库中读取集合中所有的元素，事务还在局部地址空间计算它要写的所有值</p><p>o  有效性确认：调度器通过比价该事务与其他事务的读写集合来确认该事务的有效性</p><p>o  写阶段：事务往数据库中写入其集合中的元素的值</p><p>·     调度器维护三个集合：</p><p>o  START：已经开始但尚未完成有效性确认的事务集合。对此中的事务，调度器维护START（T），即事务的开始时间</p><p>o  VAL：已经确认有效性但尚未完成第三阶段的写事务，对此中的事务，调度器维护START（T）和VAL（T），即T的确认时间</p><p>o  FIN：已经完成第三阶段写任务的事务，对这样的事务T，调度器记录START（T）,VAL(T)，FIN（T），即T的完成时间。</p><p><strong>冲突一：T启动之前，U没有完成，则需要检查U和T是否有读写交集</strong></p><p><img src="clip_image822.jpg" alt="img"></p><p><strong>冲突二：T有效确认之前，U没有完成，则需要检查是否有两个写的交集</strong></p><p><img src="clip_image824.jpg" alt="img"></p><h2 id="有效性确认："><a href="#有效性确认：" class="headerlink" title="有效性确认："></a>有效性确认：</h2><p><img src="clip_image826.jpg" alt="img"></p><p><img src="clip_image828.jpg" alt="img"></p><p>数据库故障类型及其影响</p><p>2020年6月29日</p><p>13:53</p><h2 id="数据库的故障及其影响："><a href="#数据库的故障及其影响：" class="headerlink" title="数据库的故障及其影响："></a>数据库的故障及其影响：</h2><p>·     事务故障</p><p>o  某一个程序自身故障</p><p>o  影响该程序事务本身</p><p>·     系统故障</p><p>o  由于掉电、非正常关机所引起的故障</p><p>o  影响正在运行的事务以及数据库缓存区</p><p>·     介质故障</p><p>o  由于介质损坏所引起的故障</p><p>o  影响是全面的，即影响内存中的数据，又影响介质中存储的数据</p><h2 id="数据库故障恢复"><a href="#数据库故障恢复" class="headerlink" title="数据库故障恢复"></a>数据库故障恢复</h2><p>·     把数据库由当前不正确状态恢复到正确状态</p><p>·     需要保证事务的：</p><p>o  原子性</p><p>o  持久性</p><h2 id="事务故障的恢复："><a href="#事务故障的恢复：" class="headerlink" title="事务故障的恢复："></a>事务故障的恢复：</h2><p>·     事务故障可通过重做事务，撤销事务来恢复</p><h2 id="系统故障的恢复："><a href="#系统故障的恢复：" class="headerlink" title="系统故障的恢复："></a>系统故障的恢复：</h2><p>·     运行日志是DBMS维护的一个文件，该文件以流水的方式记录了每一个事务对数据库的每一层操作及其操作顺序</p><p>·     运行日志直接写入介质存储</p><p>·     当事务对数据进行操作时：先写运行日志，写成功之后再与数据库缓冲区进行数据交换。</p><p>·     系统故障可以通过运行日志来恢复：</p><p>o  按照运行日志记录的事务操作顺序来重做事务</p><h3 id="检查点："><a href="#检查点：" class="headerlink" title="检查点："></a>检查点：</h3><p>·     在检查点时刻，DBMS强制使用内存DBBuffer中的内容与介质DB中的内容保持一致，即将DB Buffer更新的所有内容写回DB中</p><p>·     检查点表征了：在检查点之前内存数据与介质中数据是保持一致的。</p><h3 id="系统故障的恢复：-1"><a href="#系统故障的恢复：-1" class="headerlink" title="系统故障的恢复："></a>系统故障的恢复：</h3><p>·     检查点之前结束的事务不需要恢复</p><p>·     检查点之后结束或发生的事务需要依据运行日志进行恢复（不能确定是否写回DB）：故障点前结束的重做，故障点时刻未结束的撤销。</p><h2 id="介质故障的恢复："><a href="#介质故障的恢复：" class="headerlink" title="介质故障的恢复："></a>介质故障的恢复：</h2><p>·     副本：</p><p>o  在某一时刻，对数据库在其他介质存储上产生另一份等同的记录，在问题发生时，用副本数据替换。</p><p>·     构建转储点：</p><p>o  用副本替换被破话的数据库</p><p>o  由于介质故障影响全面，在用副本恢复之后还需要依据运行认知进行恢复。</p><p>·     如何确认转储点：</p><p>o  过频：影响系统工作效率，过疏，会造成运行日志过大 ，也影响系统运行性能</p><p>o  备份转储周期与运行日志的大小密切相关，应注意防止衔接不畅而引起的漏洞。</p><p><img src="clip_image830.jpg" alt="img"></p><h2 id="日志："><a href="#日志：" class="headerlink" title="日志："></a>日志：</h2><p>·     每个事务都会写或者读一些元素</p><p>·     <img src="clip_image832.jpg" alt="img"></p><p>·     一个包含日志记录的只能追加的顺序文件，不同事务的日志记录交错存储，按发生时间存储</p><p>·     发生系统故障，使用日志进行恢复</p><p>o  故障时已提交的事务，重做</p><p>o  故障时未提交的事务，撤销</p><p>·     日志记录的信息：</p><p>o  <img src="clip_image834.jpg" alt="img"></p><p>·     DBMS需要保证事务的持久性、原子性：</p><p>o  持久性：已提交的事务—在缓冲区里的内容要写回磁盘，未提交的事务—缓存区内容不能影响磁盘</p><p>·     三种日志：Undo日志、Redo日志、Undo/Redo日志</p><h3 id="缓冲区处理策略："><a href="#缓冲区处理策略：" class="headerlink" title="缓冲区处理策略："></a>缓冲区处理策略：</h3><p>·     Force：内存中的数据最晚在commit时候写入磁盘</p><p>·     No steal：不允许事务在commit之前把内存中的数据写入磁盘</p><p>·     No Force：内存中的数据可以一直保留，在commit之后过一段时间再写入磁盘</p><p>·     Steal：允许事务在commit之前把内存的数据写入磁盘。</p><h3 id="缓冲区处理策略与日志-恢复策略的关系："><a href="#缓冲区处理策略与日志-恢复策略的关系：" class="headerlink" title="缓冲区处理策略与日志/恢复策略的关系："></a>缓冲区处理策略与日志/恢复策略的关系：</h3><p><img src="clip_image836.jpg" alt="img"></p><h2 id="Undo型日志和其故障恢复："><a href="#Undo型日志和其故障恢复：" class="headerlink" title="Undo型日志和其故障恢复："></a>Undo型日志和其故障恢复：</h2><p><img src="clip_image838.jpg" alt="img"></p><p><img src="clip_image840.jpg" alt="img"></p><p><strong>从后往前</strong></p><p><img src="clip_image842.jpg" alt="img"></p><h3 id="检查点：-1"><a href="#检查点：-1" class="headerlink" title="检查点："></a>检查点：</h3><p>·     静止检查点：周期性对日志设置检查点</p><p>o  停止接受新的事务，等待所有当前活跃事务提交或终止，并在日志中写入了COMMIT或ABORT记录后</p><p>o  将日志刷新到磁盘，写入日志记录<CKPT>，并再次刷新日志。</p><p>o  <img src="clip_image844.jpg" alt="img"></p><p>·     非静止检查点：</p><p>o  在设置时不需要关闭系统个，运行新事务进入</p><p>o  写入一条<START CKPT(T1,…Tk)>，其中T1,….Tk是所有活跃的未结束的事务</p><p>o  继续正常的操作，知道T1,….Tk都完成时候，写入<END CKPT></p><p>o  <img src="clip_image846.jpg" alt="img"></p><h2 id="Redo型日志和其故障恢复："><a href="#Redo型日志和其故障恢复：" class="headerlink" title="Redo型日志和其故障恢复："></a>Redo型日志和其故障恢复：</h2><p><img src="clip_image848.jpg" alt="img"></p><p><strong>先提交在输出，还是先输出再提交，就是Redo和Undo日志的区别**</strong>1<strong>**，Redo记录的更新后的新值，Undo记录的是更新前的值</strong></p><p><img src="clip_image850.jpg" alt="img"></p><p><img src="clip_image852.jpg" alt="img"></p><p><strong>从前往后</strong></p><p><img src="clip_image854.jpg" alt="img"></p><h3 id="非静止检查点："><a href="#非静止检查点：" class="headerlink" title="非静止检查点："></a>非静止检查点：</h3><p>·     通过End CKPT找到找到START CKPT然后进行Redo</p><p><img src="clip_image856.jpg" alt="img"></p><h2 id="Undo-Redo结合型日志极其故障恢复："><a href="#Undo-Redo结合型日志极其故障恢复：" class="headerlink" title="Undo/Redo结合型日志极其故障恢复："></a>Undo/Redo结合型日志极其故障恢复：</h2><p><img src="clip_image858.jpg" alt="img"></p><p><img src="clip_image860.jpg" alt="img"></p><p><img src="clip_image862.jpg" alt="img"></p><p><img src="clip_image864.jpg" alt="img"></p><p><strong>先撤销再重做</strong></p><p><img src="clip_image866.jpg" alt="img"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;简介&quot;&gt;&lt;a href=&quot;#简介&quot; class=&quot;headerlink&quot; title=&quot;简介&quot;&gt;&lt;/a&gt;简介&lt;/h2&gt;&lt;p&gt;本文是本人基于哈尔滨工业大学数据库系统整个课程的总结和复习提纲&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;绪论&lt;/p&gt;
&lt;p&gt;2020年6月4日&lt;/p&gt;
&lt;p
      
    
    </summary>
    
    
      <category term="复习" scheme="https://www.rman.top/categories/%E5%A4%8D%E4%B9%A0/"/>
    
    
      <category term="数据库" scheme="https://www.rman.top/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/"/>
    
  </entry>
  
  <entry>
    <title>Finally Meet My Girl</title>
    <link href="https://www.rman.top/2020/06/23/Finally-Meet-My-Girl/"/>
    <id>https://www.rman.top/2020/06/23/Finally-Meet-My-Girl/</id>
    <published>2020-06-23T13:34:32.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<p>从初二到大四，八年的等待，曾经因为胆小而错过的那双手终于被我牵上了，从今往后再也不会放开。</p><p><img src="http://image.rman.top/20200623221636.jpg" style="zoom: 25%;" /></p><p><img src="http://image.rman.top/20200623214155.jpg" alt="微信图片_202006232125322" style="zoom: 25%;" /></p><p><img src="http://image.rman.top/20200623214311.jpg" alt="微信图片_202006232125321" style="zoom: 80%;" /></p><p><img src="http://image.rman.top/20200623214520.jpg" alt="微信图片_20200623212532" style="zoom: 80%;" /></p><p><img src="http://image.rman.top/20200623214526.jpg" alt="微信图片_20200623212532" style="zoom: 80%;" /></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;从初二到大四，八年的等待，曾经因为胆小而错过的那双手终于被我牵上了，从今往后再也不会放开。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://image.rman.top/20200623221636.jpg&quot; style=&quot;zoom: 25%;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;im
      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>Cant stop thinking about u</title>
    <link href="https://www.rman.top/2020/06/11/Think-about-u/"/>
    <id>https://www.rman.top/2020/06/11/Think-about-u/</id>
    <published>2020-06-11T15:09:16.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<center>第一次心里一直想着一个人</center><p><img src="http://image.rman.top/20200612000011.jpg" style="zoom: 33%;" /></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;center&gt;第一次心里一直想着一个人&lt;/center&gt;

&lt;p&gt;&lt;img src=&quot;http://image.rman.top/20200612000011.jpg&quot; style=&quot;zoom: 33%;&quot; /&gt;&lt;/p&gt;

      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="Girl" scheme="https://www.rman.top/tags/Girl/"/>
    
  </entry>
  
  <entry>
    <title>Heterogeneous Graph Transformer</title>
    <link href="https://www.rman.top/2020/06/02/Heterogeneous-Graph-Transformer/"/>
    <id>https://www.rman.top/2020/06/02/Heterogeneous-Graph-Transformer/</id>
    <published>2020-06-02T08:52:22.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>在传统的GNN中，所有的节点和边都属于一个种类，导致一些传统的GNN手段没有办法适应异构图的结构。在这篇文章中作者提出了一种基于异构图的transformer结构，用来生成不同种类的节点、边的attention值。为了解决任意时间的动态图，作者提出了一个 relative temporal encoding technique。同时为了解决大量的 图数据库，作者提出了一种基于mini-batch的图采样算法，来在图上进行高效的训练。</p><h2 id="Current-Problem"><a href="#Current-Problem" class="headerlink" title="Current Problem"></a>Current Problem</h2><ol><li>基于meta-path的方法需要专家知识</li><li>简单的假设所有的边和节点都有相同的特征表示空间</li><li>对不同的边采用了不同的权重矩阵，有大量的种类的边和节点，同时不同种类的边和节点出现的次数也不一样，对出现数量较少的边可能不是很好建模</li><li>忽视了图的动态性</li></ol><h2 id="Contribution"><a href="#Contribution" class="headerlink" title="Contribution"></a>Contribution</h2><ol><li>针对Heterogeneous Graph 边和点的种类数目过多的问题，作者采用对Meta Relation建模的，方式，通过起点和终点，以及边的种类来对一个meta relation建模。这样可以使用较少的参数。</li><li>通过神经网络结构来捕获高阶的异构图邻居特征，自动的学习meta path的重要性</li><li>通过relative temporal encoding technique来对动态的异构图进行建模</li><li>通过图采样的方式，在超大的图上进行了实验</li></ol><h2 id="Approach"><a href="#Approach" class="headerlink" title="Approach"></a>Approach</h2><h3 id="Definition"><a href="#Definition" class="headerlink" title="Definition"></a>Definition</h3><p>Heterogeneous Graph:</p><p>$G=(\mathcal{V,E,A,R})$</p><p>$\mathcal{V}$：节点</p><p>$\mathcal{E}$：边</p><p>$\mathcal{A}$：邻接矩阵</p><p>$\mathcal{R}$：边的种类</p><p>Meta Relation：</p><p>$&lt;\tau(s),\phi(e),\tau(t)&gt;$</p><p>Dynamic Heterogeneous Graph</p><p>$e=(s, t)$ with timestamp $T$, denote $s,t$ connected in $T$</p><h3 id="HGT-Architecture"><a href="#HGT-Architecture" class="headerlink" title="HGT Architecture"></a>HGT Architecture</h3><p><img src="http://image.rman.top/20200602234759.png" alt="image-20200602234752259"></p><p>HGT希望能从源节点和目标节点直接获取上下文的表示，整个过程可以分为：</p><p>Heterogeneous Mutual Attention，Heterogeneous Message Passing，Target-Specific Aggregation</p><p>三个部分</p><h4 id="Heterogeneous-Mutual-Attention："><a href="#Heterogeneous-Mutual-Attention：" class="headerlink" title="Heterogeneous Mutual Attention："></a>Heterogeneous Mutual Attention：</h4><p>calculate the mutual attention between source node $s$ and target node $t$ .</p><p><img src="http://image.rman.top/20200602235652.png" alt="image-20200602235652186"></p><p>Attention: estimates the importance of each source node</p><p>Message: extracts the message by using only the source node $s$;</p><p>Aggregate: leverages the information from its neighbors</p><p>Map target node $t$ into a Query vector, and source node $s$ into a Key vector and calculate their dot product as attention.</p><p><img src="http://image.rman.top/20200603001948.png" alt="image-20200603001948473"></p><p>整体结构和传统的transformer类似，只不过对不同的边有一个$W_{\phi(e)}^{ATT}$进行了线性变化。然后把所有的pair结果合并起来得到对不同meta的attention值。</p><h4 id="Heterogeneous-Message-Passing"><a href="#Heterogeneous-Message-Passing" class="headerlink" title="Heterogeneous Message Passing"></a>Heterogeneous Message Passing</h4><p>For a pari of nodes $e=(s, t)$, we calculate its multi-head Message by:</p><p><img src="http://image.rman.top/20200603092320.png" alt="image-20200603092319904"></p><p>为了获得$i-th$个message head $MSG-head^i(s,e,t)$，作者首先先把$\tau(s)$-type的source node映射到$i$-th message的空间，使用一个$W^{MSG}$矩阵。</p><h4 id="Target-specific-Aggregation"><a href="#Target-specific-Aggregation" class="headerlink" title="Target specific Aggregation"></a>Target specific Aggregation</h4><p>在得到了节点attention和节点message的表达之后，我们可以简单的把attention值和message相乘，然后相加。</p><p><img src="http://image.rman.top/20200603093155.png" alt="image-20200603093155025"></p><p>然后通过一个线性变换矩阵，来把target node变换到其目标的空间。</p><p><img src="http://image.rman.top/20200603093830.png" alt="image-20200603093830805"></p><h3 id="Relative-Temporal-Encoding"><a href="#Relative-Temporal-Encoding" class="headerlink" title="Relative Temporal Encoding"></a>Relative Temporal Encoding</h3><p>作者提出了一个 Relative Temporal Encoding 机制，受到Transformer的 position encoding影响，可以对节点和图在不同时刻进行建模。</p><p>给定一个源节点$s$和一个目标节点$t$，在一个时间$T$内，相对的time gap$\bigtriangleup T(t,s)=T(t)-T(s)$作为其在时间上的encoding $RTE(\bigtriangleup(t,s))$. 但是由于这种方法不一定能cover所有的时间，所以作者还是借助了传统transformer的正弦函数，配合$\bigtriangleup$来构建时序的encoding。这样做融合了离散和连续两个时间戳表示方法。</p><p><img src="http://image.rman.top/20200603131657.png" alt="image-20200603131657531"></p><p><img src="http://image.rman.top/20200603131717.png" alt="image-20200603131717886"></p><h3 id="HGSampling"><a href="#HGSampling" class="headerlink" title="HGSampling"></a>HGSampling</h3><p>为了解决传统的图算法不能支持大量的图计算的问题，作者提出了一种基于图采样的算法。整体思想为：为每一个节点类型构造一个budget $B[\tau]$，然后采样相同的数量的节点。给定一个已经采样的节点$t$，我们把他的所有直接邻居加入对应的budget，然后更新其被采样的概率，并通过度数进行归一化，防止采样过多度数较高的节点。然重复L次，直到采样了所有节点的L阶邻居。</p><p><img src="http://image.rman.top/20200603095308.png" alt="image-20200603095308068" style="zoom:67%;" /></p><h4 id="Inductive-Timestamp-Assignment"><a href="#Inductive-Timestamp-Assignment" class="headerlink" title="Inductive Timestamp Assignment"></a>Inductive Timestamp Assignment</h4><p>在异构图中，一个节点往往可能会有多个timestamp，作者要解决选择给节点加入什么时刻的timestamp，解决方法也很直接：</p><pre><code>1. 对于有着固定时间的node，比如论文，有一个唯一的发表时间，则就把该时间作为论文的timestamp 2. 对于没有固定时间的node，比如一个会议，则以与他相关的那个的节点的时间作为这个会议的timestamp</code></pre><p><img src="http://image.rman.top/20200603104412.png" alt="image-20200603104412682"></p><p><img src="http://image.rman.top/20200603104424.png" alt="image-20200603104424572"></p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><p>作者在开放学术图谱（OAG）上进行试验。该数据集包含 1.79 亿个节点和 20 亿个边组成，时间跨度从 1900 年到 2019 年。实验结果表明，与传统的 GNNs 和异构图模型相比，在下游任务中 HGT 可以显著提高 9-21%。</p><p><img src="http://image.rman.top/20200603105557.png" alt="image-20200603105557029"></p><p>同时，利用提出的相对时间编码（RTE），我们可以动态地计算出任意一个年份的节点表示。例如，通过距离，我们可以观测出每个会议在不同时间其相似会议的变化。如下图所示，WWW 在 2020 年与一些网络、数据库的会议更接近，而在 2020 年却与一些数据挖掘的会议更接近。</p><p><img src="http://image.rman.top/20200603105925.png" alt="image-20200603105925633"></p><p>同时，作者还验证了 HGT 可以隐性地抽取出对下游任务重要的元路径，而不需要人为定义。例如下图中的 <paper, is_published_at, venue, is_published_at-1, paper> 路径就有着最高的重要性。</p><p><img src="http://image.rman.top/20200603110029.png" alt="image-20200603110029430"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Abstract&quot;&gt;&lt;a href=&quot;#Abstract&quot; class=&quot;headerlink&quot; title=&quot;Abstract&quot;&gt;&lt;/a&gt;Abstract&lt;/h2&gt;&lt;p&gt;在传统的GNN中，所有的节点和边都属于一个种类，导致一些传统的GNN手段没有办法适应异构图的
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
      <category term="Transformer" scheme="https://www.rman.top/tags/Transformer/"/>
    
  </entry>
  
  <entry>
    <title>An Attention-based Graph Neural Network for Heterogeneous Structural Learning</title>
    <link href="https://www.rman.top/2020/05/27/An-Attention-based-Graph-Neural-Network-for-HIN/"/>
    <id>https://www.rman.top/2020/05/27/An-Attention-based-Graph-Neural-Network-for-HIN/</id>
    <published>2020-05-27T08:34:19.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><p>作者提出了一种在异构图上进行GNN图卷积的方式，主要是利用了对不同类型的边设定一个独有的参数$W$转到一个相同的空间，同时还用了多头的和边有关的attention机制来进行邻居信息的聚合。</p><h2 id="Approach"><a href="#Approach" class="headerlink" title="Approach"></a>Approach</h2><p>TAL层：</p><p>根据节点两个节点之间种类，用一个对应的线性变换矩阵$W$，把邻居的embedding转换到目标的空间。</p><p><img src="http://image.rman.top/20200527164235.png" alt="image-20200527164235504"></p><p>邻居聚合：</p><p><img src="http://image.rman.top/20200527165006.png" alt="image-20200527165006142"></p><ol><li>对不同的边的做了一个各自的线性变化$a_r$</li></ol><p><img src="http://image.rman.top/20200527165118.png" alt="image-20200527165118108"></p><ol><li><p>然后通过一个attention，在对邻居进行聚合。</p><p><img src="http://image.rman.top/20200527165423.png" alt="image-20200527165423020"></p></li><li><p>然后通过一个multi-head机制，同时使用多个attention参数，并把结果拼接起来，作为一个节点最后的表达。</p></li></ol><p><img src="http://image.rman.top/20200527165847.png" alt="image-20200527165847468"></p><ol><li><p>并在多层卷积的过程中加入了残差层</p><p><img src="http://image.rman.top/20200527170201.png" alt="image-20200527170201869"></p></li></ol><h2 id="Extension"><a href="#Extension" class="headerlink" title="Extension"></a>Extension</h2><ol><li><p>针对边和回边的问题，作者希望attention的值应该是正好相反的。</p><p><img src="http://image.rman.top/20200527173607.png" alt="image-20200527173607152"></p></li><li><p>环理论，一个j-&gt;j的转换应该等于j-&gt;i, i-&gt;i, i-&gt;j这两个应该是相等的。所以变换矩阵应该有如下的性质。</p><p><img src="http://image.rman.top/20200527173948.png" alt="image-20200527173948104"> </p></li></ol><p>i-&gt;i的矩阵是有方向的，所以需要求一个逆矩阵，这个工作很耗时，所以作者用train的方法来实现求得该逆矩阵。</p><p><img src="http://image.rman.top/20200527174155.png" alt="image-20200527174155225"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Introduction&quot;&gt;&lt;a href=&quot;#Introduction&quot; class=&quot;headerlink&quot; title=&quot;Introduction&quot;&gt;&lt;/a&gt;Introduction&lt;/h2&gt;&lt;p&gt;作者提出了一种在异构图上进行GNN图卷积的方式，主要是利用了
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图卷积" scheme="https://www.rman.top/tags/%E5%9B%BE%E5%8D%B7%E7%A7%AF/"/>
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
  </entry>
  
  <entry>
    <title>AddGraph, Anomaly Detection in Dynamic Graph Using Attention-based Temporal GCN</title>
    <link href="https://www.rman.top/2020/05/26/AddGraph/"/>
    <id>https://www.rman.top/2020/05/26/AddGraph/</id>
    <published>2020-05-26T13:12:16.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction:"></a>Introduction:</h2><p>异常检测常见的领域就是在电商。比如异常的用户会通过对目标商品以及流行商品做大量的相同操作，比如同时点击目标商品和流行商品，从而增加了目标商品和流行商品的相似性。从而在推荐系统里增加了评分。这篇文章是针对动态图的异常检测，异常检测 对于下流任务很重要。 和传统的图方法相比，GCN能够自动的传播从邻居节点的信息，从而扩散节点的异常概率。GCN在异常检测方面主要的问题在于没有考虑时间特征（不能在动态图上忽略的）目前的一些工作 CAD [Sricharan and Das, 2014] and Netwalk [Yu et al., 2018] 把 graph embedding方法应用到动态图，但是不能 捕捉节点的 “长期模式”和“短期模式”。 主要贡献：</p><ol><li>提出AddGraph框架，提出一个attention-based     GRU的GCN框架，获得短时和长时特征。</li><li>受到知识图谱的启发，引入一个negative     sampling 和margin loss来检测异常边</li></ol><h2 id="Problem-Definition"><a href="#Problem-Definition" class="headerlink" title="Problem Definition:"></a>Problem Definition:</h2><p>$T$是最大的时间步长，图的集合${G^t}^T_{t=1}$,每个$G^t$代表着一个时间点子图，$A^t\in\mathbb{R}^{m\times n}$，代表每个时间点的邻接矩阵。$e = (i,j,w）\in E^t$意味着在时刻t，i和j之间存在一个权重为w的边吗，本文的目的是训练一个函数$f$，使得能对$e\in E, f(e)$能输出一个异常边的概率。</p><h2 id="Framework"><a href="#Framework" class="headerlink" title="Framework"></a>Framework</h2><p><img src="http://image.rman.top/20200526212959.png" alt="image-20200526212959877"></p><h3 id="图卷积"><a href="#图卷积" class="headerlink" title="图卷积"></a>图卷积</h3><p>在每个时间 $t$, 我们都可对$G^t$借助$A^t$来使用GCN进行卷积，获得每个节点的隐藏层信息$H^{t-1}\in \mathbb{R}^{n \times d}$ ，同时对每层卷积层$GCN_L$计算方式如下，其实就是一个普通的卷积加了一个非线性变化。：</p><script type="math/tex; mode=display">Z^0=H^{t-1}\\Z^l=ReLU(A^tZ^{L-1}W^{L-1})\\Current^t=ReLU(A^tZ^{L-1}W^{L-1})</script><h3 id="带Attention机制的GRU门"><a href="#带Attention机制的GRU门" class="headerlink" title="带Attention机制的GRU门"></a>带Attention机制的GRU门</h3><p><img src="http://image.rman.top/20200526215357.png" alt="image-20200526215357841"></p><p>$h_i^t$是$i$-th节点的t时间段的隐藏状态，$w$是窗口的大小，沿着w的纬度做了一个attention，得到每一个时间$t$的权重表达，简单记为</p><script type="math/tex; mode=display">Short^t_i=CAB(h_i^{t-w},\cdots,h_i^{t-1})</script><p>$Current^t$是当前节点在图中的表达，$Short_t$是每个节点历史信息的表达。为了平衡这两个信息，采用了如下的门机制来融合这两个信息。</p><p><img src="http://image.rman.top/20200526220304.png" alt="image-20200526220302071"></p><p>注：这个CAB等于是在传统的门机制基础上，加入了<strong>历史一段时间的记忆</strong>，然后和当前状态一起进入GRU更新。</p><p>预测方程：</p><script type="math/tex; mode=display">f(i,j,w)=w\cdot\sigma(\beta\cdot(||a\odot h_i+b\odot h_j||_2^2-\mu))</script><p>$h_i,h_j$是两个节点在$t$的hidden特征。</p><p>Loss 采用的Margin loss，希望正例的得分小于负例的得分。</p><p><img src="http://image.rman.top/20200527101154.png" alt="image-20200527101145153"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Introduction&quot;&gt;&lt;a href=&quot;#Introduction&quot; class=&quot;headerlink&quot; title=&quot;Introduction:&quot;&gt;&lt;/a&gt;Introduction:&lt;/h2&gt;&lt;p&gt;异常检测常见的领域就是在电商。比如异常的用户会通过对目标
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
      <category term="异常检测" scheme="https://www.rman.top/tags/%E5%BC%82%E5%B8%B8%E6%A3%80%E6%B5%8B/"/>
    
      <category term="动态图" scheme="https://www.rman.top/tags/%E5%8A%A8%E6%80%81%E5%9B%BE/"/>
    
  </entry>
  
  <entry>
    <title>GraphSAINT,一种无偏的图采样方法</title>
    <link href="https://www.rman.top/2020/05/20/GraphSAINT%E4%B8%80%E7%A7%8D%E6%97%A0%E5%81%8F%E7%9A%84%E5%9B%BE%E9%87%87%E6%A0%B7%E6%96%B9%E6%B3%95/"/>
    <id>https://www.rman.top/2020/05/20/GraphSAINT%E4%B8%80%E7%A7%8D%E6%97%A0%E5%81%8F%E7%9A%84%E5%9B%BE%E9%87%87%E6%A0%B7%E6%96%B9%E6%B3%95/</id>
    <published>2020-05-20T09:46:47.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><p>在现在的图卷积中，由于图的大小可能非常大，传统的在全图上进行图卷积的操作往往是不现实的。因此往往采用了图采样的方法。图采样大致会分为：Layer Sampling 和 Graph Sampling两种。但是这两种方法都存在着一些问题。</p><p>Layer Sampling：</p><pre><code>1. 邻居爆炸：在矩阵采样多层时，假设每层采样n个邻居，则会导致$n^2$级别的节点扩充速度。 2. 领接矩阵稀疏：在矩阵采样的过程中，会导致邻接矩阵稀疏化，丢失一些本来存在的边。 3. 时间耗费高：每一层卷积都要采样，这就导致计算的时间耗费。</code></pre><p><img src="http://image.rman.top/20200520175505.png" alt="image-20200520175459686"></p><p>Graph Sampling:</p><p>Graph Sampling是一种相对好的采样方法，可以在preprocess阶段提前采样图，并且可以进行mini batch的加速。但是这样的采样往往会丢失一些信息。</p><p>本文为了解决以上问题，提出了一种在图上进行Graph Sampling的相对较好的方法。</p><h2 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h2><p>在普通的Layer采样过程中，我们希望采样之后产生的偏差最小。这个偏差可以由如下的公式得出。</p><p><img src="http://image.rman.top/20200520175911.png" alt="image-20200520175904265"></p><p>我们希望如下的偏差最小，经过一系列复制的推导，在$P_e$等于如下值的时候，偏差达到最小。</p><p><img src="http://image.rman.top/20200520180025.png" alt="image-20200520180020725"></p><p>但是此种方法计算需要所有子图中边两端的聚合信息来求得计算量十分大，于是作者采用了如下的简化公式</p><p>边的采样概率等于两个节点的倒数之和，来进行Graph的采样</p><p><img src="http://image.rman.top/20200520180226.png" alt="image-20200520180224380"></p><p><img src="http://image.rman.top/20200520180244.png" alt="image-20200520180242533"></p><h2 id="实验"><a href="#实验" class="headerlink" title="实验"></a>实验</h2><p>在许多的大图中进行证明，不仅训练速度得到了优化，其准确率也有了提高。</p><p><img src="http://image.rman.top/20200520180315.png" alt="image-20200520180313379"></p><p>同时对比了Layer Sampling和Graph Sampling，证明了Graph Sampling在多层的时效果有一定的提高</p><p><img src="http://image.rman.top/20200520180348.png" alt="image-20200520180346597"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;背景&quot;&gt;&lt;a href=&quot;#背景&quot; class=&quot;headerlink&quot; title=&quot;背景&quot;&gt;&lt;/a&gt;背景&lt;/h2&gt;&lt;p&gt;在现在的图卷积中，由于图的大小可能非常大，传统的在全图上进行图卷积的操作往往是不现实的。因此往往采用了图采样的方法。图采样大致会分为：Lay
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="论文笔记" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
      <category term="图采样" scheme="https://www.rman.top/tags/%E5%9B%BE%E9%87%87%E6%A0%B7/"/>
    
  </entry>
  
  <entry>
    <title>Neural Graph Collaborative Filtering</title>
    <link href="https://www.rman.top/2020/05/18/Neural-Graph-Collaborative-Filtering/"/>
    <id>https://www.rman.top/2020/05/18/Neural-Graph-Collaborative-Filtering/</id>
    <published>2020-05-18T16:00:00.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="Abstract："><a href="#Abstract：" class="headerlink" title="Abstract："></a>Abstract：</h1><p>传统的深度学习协同过滤，ID的嵌入是直接输入交互层，但是在NGCF中，其能捕获用户和物品之间的高阶关系。</p><p><img src="http://image.rman.top/20200506225252.jpg" alt="计算机生成了可选文字: User-itemInteractionGraph High-orderConnectivityfor榄1 Figure1：Anillustrationoftheuser-iteminteractiongraph andthehigh-orderconnectivity.Thenode屿isthetarget usertoproviderecommendationsfor."></p><h1 id="Method："><a href="#Method：" class="headerlink" title="Method："></a>Method：</h1><h2 id="假设："><a href="#假设：" class="headerlink" title="假设："></a>假设：</h2><p>Intuitively, the interacted items provide direct evidence on a user’s preference [16, 38]; analogously, the users that consume an item can be treated as the item’s features and used to measure the collaborative similarity of two items.</p><h2 id="Message-Construction"><a href="#Message-Construction" class="headerlink" title="Message Construction:"></a>Message Construction:</h2><p>$e_i$,$e_u$ 做哈达玛积，然后通过$W_2$ 转换，然后和$e_1$ 通过$W_1$ 做转换之后相加。然后除以度数乘积进行归一化。</p><p><img src="http://image.rman.top/20200506225439.png" alt=""></p><h2 id="Message-Aggregation"><a href="#Message-Aggregation" class="headerlink" title="Message Aggregation:"></a>Message Aggregation:</h2><p>邻居信息相加聚合在加到用户自身上和用户相加通过激活函数。</p><p><img src="http://image.rman.top/20200506225702.png" alt="clip_image004"></p><h2 id="多层次卷积："><a href="#多层次卷积：" class="headerlink" title="多层次卷积："></a>多层次卷积：</h2><p>很典型的图卷积矩阵定义</p><p><img src="http://image.rman.top/20200506225703.png" alt="clip_image005"></p><h2 id="Model-prediction"><a href="#Model-prediction" class="headerlink" title="Model prediction:"></a>Model prediction:</h2><p>每一层都会得到用户u的表示，将其拼接得到用户最后的表示。</p><p><img src="http://image.rman.top/20200506225704.png" alt="clip_image006"></p><p>同理得到物品的表示，然后点积预测结果。</p><p>Loss采用BPR loss</p><p>Pairwise。对于implicit feedback（如是否购买），BPR对每一个user建立一个偏序关系 </p><p> 。如图所示，user-item矩阵中，+表示用户购买了该商品，?表示没有购买。比如，对user 1来说，他购买了 </p><p>，没有购买 </p><p>，则对于他来说，2和3比1和4好，但2、3之间，1、4之间无法比较</p><p>来自 <a href="[*https://zhuanlan.zhihu.com/p/31841042*](https://zhuanlan.zhihu.com/p/31841042)">[*https://zhuanlan.zhihu.com/p/31841042*](https://zhuanlan.zhihu.com/p/31841042)</a></p><p><img src="http://image.rman.top/20200506225705.png" alt="clip_image007"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;Abstract：&quot;&gt;&lt;a href=&quot;#Abstract：&quot; class=&quot;headerlink&quot; title=&quot;Abstract：&quot;&gt;&lt;/a&gt;Abstract：&lt;/h1&gt;&lt;p&gt;传统的深度学习协同过滤，ID的嵌入是直接输入交互层，但是在NGCF中，其能捕获用户和
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="论文" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87/"/>
    
      <category term="推荐系统" scheme="https://www.rman.top/tags/%E6%8E%A8%E8%8D%90%E7%B3%BB%E7%BB%9F/"/>
    
  </entry>
  
  <entry>
    <title>torch.einsum 实现CIN</title>
    <link href="https://www.rman.top/2020/05/09/torch-einsum-%E5%AE%9E%E7%8E%B0CIN/"/>
    <id>https://www.rman.top/2020/05/09/torch-einsum-%E5%AE%9E%E7%8E%B0CIN/</id>
    <published>2020-05-09T04:24:09.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<p>研究了一下如何用pytorch实现CIN的操作。</p><h2 id="CIN的数学原理"><a href="#CIN的数学原理" class="headerlink" title="CIN的数学原理"></a>CIN的数学原理</h2><p>假设总共有$m$个field，每个field的embedding是一个$D$维向量。</p><p>压缩交互网络（Compressed Interaction Network， 简称CIN）隐向量是一个单元对象，因此我们将输入的原特征和神经网络中的隐层都分别组织成一个矩阵，记为$X_0$和$Xk$，CIN中每一层的神经元都是根据<strong>前一层的隐层</strong>以及<strong>原特征向量</strong>推算而来，其计算公式如下：</p><script type="math/tex; mode=display">X^k_{h,*}=\sum ^{H_{k-1}}_{i=1}\sum ^{m}_{j=1}W^{k,h}_{ij}(X^{k-1}_{i,*}\circ X^{0}_{j,*})</script><p>其中，第k层隐层含有$H_k$条神经元向量。$\circ$是Hadamard product，即element-wise product，即，$ \left \langle a_1,a_2,a_3\right \rangle\circ \left \langle b_1,b_2,b_3\right \rangle=\left \langle a_1b_1,a_2b_2,a_3b_3 \right \rangle $.</p><p>根据前一层隐层的状态$X^k$和原特征矩阵$X^0$，计算出一个中间结果$Z^{k+1}$，它是一个三维的张量。注意图中的$\bigotimes$是outer product，其实就是矩阵乘法咯，也就是一个mx1和一个nx1的向量的外积是一个mxn的矩阵：</p><script type="math/tex; mode=display">u\bigotimes v=uv^T=\begin{bmatrix}u_1\\ u_2\\ u_3\\u_4\end{bmatrix}\begin{bmatrix}v_1 & v_2  & v_3  \end{bmatrix}=\begin{bmatrix}u_1v_1 &  u_1v_2& u_1v_3 \\ u_2v_1 & u_2v_2 & u_2v_3\\ u_3v_1 & u_3v_2 & u_3v_3\\ u_4v_1 & u_4v_2 & u_4v_3\end{bmatrix}</script><p><img src="http://image.rman.top/20200509123153.png" alt="img"></p><p>而图中的$D$维，其实就是左边的一行和右边的一行对应相乘。</p><p><a href="https://daiwk.github.io/posts/dl-dl-ctr-models.html#cin">https://daiwk.github.io/posts/dl-dl-ctr-models.html#cin</a></p><h2 id="pytorch的实现"><a href="#pytorch的实现" class="headerlink" title="pytorch的实现"></a>pytorch的实现</h2><p>在pytorch的实现过程中主要使用的是<code>torch.einsum</code>操作</p><p><a href="https://pytorch.org/docs/stable/torch.html?highlight=einsum#torch.einsum">https://pytorch.org/docs/stable/torch.html?highlight=einsum#torch.einsum</a></p><blockquote><p><code>torch.``einsum</code>(<em>equation</em>, <em>*operands</em>) → Tensor<a href="https://pytorch.org/docs/stable/_modules/torch/functional.html#einsum">[SOURCE]</a></p><p>This function provides a way of computing multilinear expressions (i.e. sums of products) using the Einstein summation convention.</p><ul><li><p>Parameters</p><p><strong>equation</strong> (<em>string</em>) – The equation is given in terms of lower case letters (indices) to be associated with each dimension of the operands and result. The left hand side lists the operands dimensions, separated by commas. There should be one index letter per tensor dimension. The right hand side follows after -&gt; and gives the indices for the output. If the -&gt; and right hand side are omitted, it implicitly defined as the alphabetically sorted list of all indices appearing exactly once in the left hand side. The indices not apprearing in the output are summed over after multiplying the operands entries. If an index appears several times for the same operand, a diagonal is taken. Ellipses … represent a fixed number of dimensions. If the right hand side is inferred, the ellipsis dimensions are at the beginning of the output.<strong>operands</strong> (<a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor"><em>Tensor</em></a>) – The operands to compute the Einstein sum of.</p></li></ul></blockquote><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">print</span>(a_tensor)</span><br><span class="line"> </span><br><span class="line">tensor([[<span class="number">11</span>, <span class="number">12</span>, <span class="number">13</span>, <span class="number">14</span>],</span><br><span class="line">        [<span class="number">21</span>, <span class="number">22</span>, <span class="number">23</span>, <span class="number">24</span>],</span><br><span class="line">        [<span class="number">31</span>, <span class="number">32</span>, <span class="number">33</span>, <span class="number">34</span>],</span><br><span class="line">        [<span class="number">41</span>, <span class="number">42</span>, <span class="number">43</span>, <span class="number">44</span>]])</span><br><span class="line"> </span><br><span class="line"><span class="built_in">print</span>(b_tensor)</span><br><span class="line"> </span><br><span class="line">tensor([[<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>],</span><br><span class="line">        [<span class="number">2</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">2</span>],</span><br><span class="line">        [<span class="number">3</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">3</span>],</span><br><span class="line">        [<span class="number">4</span>, <span class="number">4</span>, <span class="number">4</span>, <span class="number">4</span>]])</span><br><span class="line"> </span><br><span class="line"><span class="comment"># &#x27;ik, kj -&gt; ij&#x27;语义解释如下：</span></span><br><span class="line"><span class="comment"># 输入a_tensor: 2维数组，下标为ik,</span></span><br><span class="line"><span class="comment"># 输入b_tensor: 2维数组，下标为kj,</span></span><br><span class="line"><span class="comment"># 输出output：2维数组，下标为ij。</span></span><br><span class="line"><span class="comment"># 隐含语义：输入a,b下标中相同的k，是求和的下标，对应上面的例子2的公式</span></span><br><span class="line">output = torch.einsum(<span class="string">&#x27;ik, kj -&gt; ij&#x27;</span>, a_tensor, b_tensor)</span><br><span class="line"> </span><br><span class="line"><span class="built_in">print</span>(output)</span><br><span class="line"> </span><br><span class="line">tensor([[<span class="number">130</span>, <span class="number">130</span>, <span class="number">130</span>, <span class="number">130</span>],</span><br><span class="line">        [<span class="number">230</span>, <span class="number">230</span>, <span class="number">230</span>, <span class="number">230</span>],</span><br><span class="line">        [<span class="number">330</span>, <span class="number">330</span>, <span class="number">330</span>, <span class="number">330</span>],</span><br><span class="line">        [<span class="number">430</span>, <span class="number">430</span>, <span class="number">430</span>, <span class="number">430</span>]])</span><br></pre></td></tr></table></figure><p>简而言之，可以用<code>ik, kj</code>来指代输入矩阵的各个维度，然后用<code>-&gt;</code>来定义行列的操作。</p><h3 id="CIN实现"><a href="#CIN实现" class="headerlink" title="CIN实现"></a>CIN实现</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">a=torch.randn(<span class="number">2</span>,<span class="number">30</span>,<span class="number">8</span>) <span class="comment"># (Batch size, feature number, feature dim)</span></span><br><span class="line">b=torch.randn(<span class="number">2</span>,<span class="number">30</span>,<span class="number">8</span>) <span class="comment"># (Batch size, feature number, feature dim)</span></span><br><span class="line">c=torch.einsum(<span class="string">&#x27;bhd,bmd-&gt;bhmd&#x27;</span>,a,b) <span class="comment"># b是batch size， h,m是各自的特征数量，d是特征纬度</span></span><br><span class="line">c.size()</span><br><span class="line"><span class="comment"># torch.Size([2, 31, 31, 8])</span></span><br></pre></td></tr></table></figure>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;研究了一下如何用pytorch实现CIN的操作。&lt;/p&gt;
&lt;h2 id=&quot;CIN的数学原理&quot;&gt;&lt;a href=&quot;#CIN的数学原理&quot; class=&quot;headerlink&quot; title=&quot;CIN的数学原理&quot;&gt;&lt;/a&gt;CIN的数学原理&lt;/h2&gt;&lt;p&gt;假设总共有$m$个field
      
    
    </summary>
    
    
      <category term="python" scheme="https://www.rman.top/categories/python/"/>
    
    
      <category term="pytorch" scheme="https://www.rman.top/tags/pytorch/"/>
    
      <category term="python" scheme="https://www.rman.top/tags/python/"/>
    
  </entry>
  
  <entry>
    <title>neo4j导入和创建多数据库</title>
    <link href="https://www.rman.top/2020/05/07/neo4j-import-and-create-db/"/>
    <id>https://www.rman.top/2020/05/07/neo4j-import-and-create-db/</id>
    <published>2020-05-07T04:49:08.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>最近在玩neo4j，用来存储实验的图数据库，以前都是只用做一个数据库就好了。但是由于一个数据集的paper被review怼的惨不忍睹，只能多搞几个数据集来实验，于是就开始倒腾建立多个数据集的方法。</p><h2 id="Neo4j-admin-import"><a href="#Neo4j-admin-import" class="headerlink" title="Neo4j-admin import"></a>Neo4j-admin import</h2><p>使用Neio4j-admin import导入csv</p><p><code>neo4j-admin --database=xxx.db --nodes=users.csv --relationships=relations.csv</code></p><p>—database：数据库名字，由于创建了多个数据库所以必须改名，如果出现数据库名字重复或者不为空可以执行<code>sudo rm -rf /var/lib/neo4j/data/databases/xx.db</code>清空</p><p>—nodes：节点csv，<code>[name:ID]</code>，ID字段是必须的，是唯一索引，name是feature的名字，<code>:LABEL</code>是节点的标签，貌似可以用[name:ID(label)]替代:LABEL ，但是此时在import 的时候要在<code>--nodes:User=users.csv</code>明确label</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">movies.csv. </span><br><span class="line"></span><br><span class="line">movieId:ID,title,year:int,:LABEL</span><br><span class="line">tt0133093,&quot;The Matrix&quot;,1999,Movie</span><br><span class="line">tt0234215,&quot;The Matrix Reloaded&quot;,2003,Movie;Sequel</span><br><span class="line">tt0242653,&quot;The Matrix Revolutions&quot;,2003,Movie;Sequel</span><br></pre></td></tr></table></figure><p>—relations：关系csv，必须包含<code>START_ID</code>, <code>END_ID</code> 和 <code>:TYPE</code>，分别是开始节点，结束节点，和边的种类</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">roles.csv. </span><br><span class="line"></span><br><span class="line">:START_ID,role,:END_ID,:TYPE</span><br><span class="line">keanu,&quot;Neo&quot;,tt0133093,ACTED_IN</span><br><span class="line">keanu,&quot;Neo&quot;,tt0234215,ACTED_IN</span><br><span class="line">keanu,&quot;Neo&quot;,tt0242653,ACTED_IN</span><br><span class="line">laurence,&quot;Morpheus&quot;,tt0133093,ACTED_IN</span><br><span class="line">laurence,&quot;Morpheus&quot;,tt0234215,ACTED_IN</span><br><span class="line">laurence,&quot;Morpheus&quot;,tt0242653,ACTED_IN</span><br><span class="line">carrieanne,&quot;Trinity&quot;,tt0133093,ACTED_IN</span><br><span class="line">carrieanne,&quot;Trinity&quot;,tt0234215,ACTED_IN</span><br><span class="line">carrieanne,&quot;Trinity&quot;,tt0242653,ACTED_IN</span><br></pre></td></tr></table></figure><h2 id="多个数据库并存"><a href="#多个数据库并存" class="headerlink" title="多个数据库并存"></a>多个数据库并存</h2><p>neo4j默认是导入<code>graph.db</code>，在有多个数据库的时候，可以通过创建符号链接的方式切换数据库</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mv graph.db graph1.db</span><br><span class="line">ln -s graph1.db graph.db</span><br><span class="line">ln -s graph2.db graph.db</span><br></pre></td></tr></table></figure><p><img src="http://image.rman.top/20200507130538.png" alt="image-20200507130527694"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;前言&quot;&gt;&lt;a href=&quot;#前言&quot; class=&quot;headerlink&quot; title=&quot;前言&quot;&gt;&lt;/a&gt;前言&lt;/h2&gt;&lt;p&gt;最近在玩neo4j，用来存储实验的图数据库，以前都是只用做一个数据库就好了。但是由于一个数据集的paper被review怼的惨不忍睹，只能多
      
    
    </summary>
    
    
      <category term="数据库" scheme="https://www.rman.top/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/"/>
    
    
      <category term="neo4j" scheme="https://www.rman.top/tags/neo4j/"/>
    
  </entry>
  
  <entry>
    <title>PyG Graph sage 源码分析</title>
    <link href="https://www.rman.top/2020/05/06/PyG-Graph-sage-souce/"/>
    <id>https://www.rman.top/2020/05/06/PyG-Graph-sage-souce/</id>
    <published>2020-05-06T02:16:07.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="PyG-Graph-sage-源码分析"><a href="#PyG-Graph-sage-源码分析" class="headerlink" title="PyG Graph sage 源码分析"></a>PyG Graph sage 源码分析</h2><ol><li>Neighbor sampler</li></ol><p>NeighborSampler！</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">NeighborSampler(data, size, num_hops, batch_size=1, shuffle=False, drop_last=False, bipartite=True, add_self_loops=False, flow=&#x27;source_to_target&#x27;)</span><br></pre></td></tr></table></figure><p>该方法返回一个生成器，主要需要的参数有data数据、采样邻居数（或比例）、采样跳数、bs等。其中bipartite参数指定返回的数据形式：</p><ul><li>bipartite=True     返回DataFlow 数据形式</li><li>bipartite=False     返回Data 数据形式（实际上是Data形式的subgraph）</li></ul><p>在 <a href="https://link.zhihu.com/?target=https%3A//github.com/rusty1s/pytorch_geometric/blob/a8f32aaff8608e497f112f700d1fd8ca0cb9ae18/test/data/test_sampler.py">https://github.com/rusty1s/pytorch_geometric/blob/a8f32aaff8608e497f112f700d1fd8ca0cb9ae18/test/data/test_sampler.py</a> 中我们可以看到两种方法的使用例子。</p><ol><li>bipartite</li></ol><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Neighborloader = NeighborSampler(Cora[0], size=[25, 10], num_hops=2, batch_size=1,</span><br><span class="line">             shuffle=True, add_self_loops=True,)</span><br><span class="line"> for ner in Neighborloader(Cora[0].train_mask):</span><br><span class="line">   print(ner)</span><br><span class="line"> #输出: DataFlow(1&lt;-4&lt;-9)</span><br></pre></td></tr></table></figure><p>即 layer 0有9个点，layer 1有4个点，layer 2有1个点（目标）</p><p>hoop设置两跳，ner里于是有了两个Block数据：、</p><p>ner[0], ner[1]<br> # 输出: Block(n_id=[9], res_n_id=[4], e_id=None, edge_index=[2, 18], size=[2]),<br> # Block(n_id=[4], res_n_id=[1], e_id=None, edge_index=[2, 4], size=[2]))</p><ul><li>n_id是二分图中节点(从0开始)到原图的id映射</li><li>res_n_id是二分图中向其他层连接的节点id</li><li>edge_index二分图中的边</li></ul><p>具体来看：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ner[0].n_id, ner[0].res_n_id</span><br><span class="line"> \# 输出: (tensor([ 109, 2481, 234, 826, 2287, 114, 2506, 610, 2288]),</span><br><span class="line"> tensor([5, 8, 7, 6]),</span><br></pre></td></tr></table></figure><p>也就是说这一层ner[0] 26个节点编号：[ 109, 2481, 234, 826, 2287, 114, 2506, 610, 2288]</p><p>其中第[5, 8, 7, 6]（即[ 114, 2288, 610, 2506]）是和下一层ner[1] 相连接的：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ner[1].n_id, ner[1].res_n_id</span><br><span class="line"> # 输出:(tensor([ 114, 2288, 610, 2506]),</span><br><span class="line"> tensor([0]),</span><br></pre></td></tr></table></figure><p>batch&gt;1时也就是采样一个包含batch个目标点的二分图。</p><p>因此我们在训练时要先输入layer 0进行训练，然后再此基础上对layer 1进行训练，最终得到layer 1的res_n_id的输出。<br><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">def forward_data_flow(self, x, edge_weight, data_flow):</span><br><span class="line">   block = data_flow[0]</span><br><span class="line">   weight = None if block.e_id is None else edge_weight[block.e_id]</span><br><span class="line">   x = relu(</span><br><span class="line">       self.conv1((x, None), block.edge_index, weight, block.size))</span><br><span class="line">   block = data_flow[1]</span><br><span class="line">   weight = None if block.e_id is None else edge_weight[block.e_id]</span><br><span class="line">   x = relu(</span><br><span class="line">       self.conv2((x, None), block.edge_index, weight, block.size))</span><br><span class="line">   return x</span><br></pre></td></tr></table></figure></p><ol><li>subgraph</li></ol><p>subgraph模型上与不使用NeighborSampler的无异，唯一区别是Data中的变量：<br><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ner[1].n_id, ner[1].res_n_id</span><br><span class="line"> \# 输出:Data(b_id=[1], e_id=[20], edge_index=[2, 20], n_id=[19], sub_b_id=[1])</span><br><span class="line"> ner.b_id, ner.sub_b_id, ner.n_id</span><br><span class="line"> \# 输出:(tensor([100]),</span><br><span class="line"> tensor([18]),</span><br><span class="line"> tensor([ 95, 2073, 2054,  6, 2074, 2072, 315, 2576, 1416, 734, 2311, 1628,</span><br><span class="line">     1841, 1680, 408, 2056, 1602, 1204, 100]))</span><br></pre></td></tr></table></figure></p><ul><li>n_id是子图中节点(从0开始)到原图的id映射</li><li>b_id是目标点</li><li>sub_b_id是子图中目标点的id</li></ul><p>batch&gt;1时也就是采样一个包含batch个目标点的子图。</p><p>我们在训练时放入采样的子图，只取目标点sub_b_id作为模型输出即可，其他不变。<br><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">out = model(data.x[subdata.n_id], subdata.edge_index, weight)</span><br><span class="line">out = out[subdata.sub_b_id]</span><br></pre></td></tr></table></figure></p><p>来自 <a href="https://zhuanlan.zhihu.com/p/113862170">https://zhuanlan.zhihu.com/p/113862170</a> </p><ol><li>在使用过程中，逐层输入block的node和index，通过聚合函数，会自动把输出的层聚合成下一个hop的node数量，</li><li>TODO：neighbor     sampler的分析，到时候motif sampler要用</li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;PyG-Graph-sage-源码分析&quot;&gt;&lt;a href=&quot;#PyG-Graph-sage-源码分析&quot; class=&quot;headerlink&quot; title=&quot;PyG Graph sage 源码分析&quot;&gt;&lt;/a&gt;PyG Graph sage 源码分析&lt;/h2&gt;&lt;ol&gt;

      
    
    </summary>
    
    
      <category term="python" scheme="https://www.rman.top/categories/python/"/>
    
    
      <category term="pytorch" scheme="https://www.rman.top/tags/pytorch/"/>
    
      <category term="pytorch geometric" scheme="https://www.rman.top/tags/pytorch-geometric/"/>
    
      <category term="python" scheme="https://www.rman.top/tags/python/"/>
    
  </entry>
  
  <entry>
    <title>Graph U-Nets</title>
    <link href="https://www.rman.top/2020/05/05/Graph-U-Nets/"/>
    <id>https://www.rman.top/2020/05/05/Graph-U-Nets/</id>
    <published>2020-05-05T07:34:49.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h1 id="简介："><a href="#简介：" class="headerlink" title="简介："></a>简介：</h1><p>在传统图像领域，encoder-decoder结构，比如U-nets已经在许多图像像素领域有着许多成功的应用。然而在图像领域，由于池化和反池化操作在图领域的实现并没有自然的实现，导致这样的结构并没有在图网络中应用。本文提出了一种在图结构上<strong>池化和反池化</strong>的操作，池化层可以根据节点在可训练投影向量上的标量投影值，自适应地选择节点，形成较小的图。反池化层可以把池化层生成的数据恢复成带位置信息的原始结构。</p><h1 id="Graph-Pooling-Layer："><a href="#Graph-Pooling-Layer：" class="headerlink" title="Graph Pooling Layer："></a>Graph Pooling Layer：</h1><p>图池化，首先有节点特征X，邻接矩阵A，通过一个P向量来训练节点之间的位置关系，然后通过SIGMOD(y)+TOP-K来提取top-K特征，提取完之后，保存idex，从X，A提取特征和邻接矩阵。</p><p><img src="http://image.rman.top/clip_image001-1588664337461.png" alt="clip_image001-1588664337461"></p><h1 id="Graph-Unpooling-Layer："><a href="#Graph-Unpooling-Layer：" class="headerlink" title="Graph Unpooling Layer："></a>Graph Unpooling Layer：</h1><p>学习distribution，把pool过之后的K<em>C矩阵，和选定的节点idx，恢复成原始的N</em>C矩阵。</p><p><img src="http://image.rman.top/clip_image002.png" alt="计算机生成了可选文字: X十1=distribute(ONxc,Xc,idx）： （3）"></p><p>只把选定位置的点设为k<em>C的特征，N</em>C的其他位置设为0</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h1 id=&quot;简介：&quot;&gt;&lt;a href=&quot;#简介：&quot; class=&quot;headerlink&quot; title=&quot;简介：&quot;&gt;&lt;/a&gt;简介：&lt;/h1&gt;&lt;p&gt;在传统图像领域，encoder-decoder结构，比如U-nets已经在许多图像像素领域有着许多成功的应用。然而在图像领域，由于池
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="图神经网络" scheme="https://www.rman.top/tags/%E5%9B%BE%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"/>
    
      <category term="论文" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87/"/>
    
  </entry>
  
  <entry>
    <title>Representation Learning for Attributed Multiplex Heterogeneous Network</title>
    <link href="https://www.rman.top/2020/05/05/Representation%20Learning%20for%20Attributed%20Multiplex%20Heterogeneous%20Network/"/>
    <id>https://www.rman.top/2020/05/05/Representation%20Learning%20for%20Attributed%20Multiplex%20Heterogeneous%20Network/</id>
    <published>2020-05-05T06:58:14.000Z</published>
    <updated>2026-03-13T01:50:06.912Z</updated>
    
    <content type="html"><![CDATA[<h2 id="简介："><a href="#简介：" class="headerlink" title="简介："></a>简介：</h2><p>现有的方法主要专注于具有单一类型节点/边缘的网络，并且不能灵活处理大型网络。许多真实世界的网络包括数十亿个节点和多种类型的边，每个节点与不同的属性相关联。本文提出了一种<strong>带属性多通道异构图网络，</strong>本网路结构可以支持transductive和indective的学习。</p><p><img src="http://image.rman.top/20200505150252.png" alt=""></p><h2 id="相关工作："><a href="#相关工作：" class="headerlink" title="相关工作："></a>相关工作：</h2><p><img src="http://image.rman.top/20200505151154.png" alt=""></p><h2 id="Transductive-Model-GATNE-T："><a href="#Transductive-Model-GATNE-T：" class="headerlink" title="Transductive Model: GATNE-T："></a>Transductive Model: GATNE-T：</h2><p>此处，模型通过边的种类，学习节点在不同边聚类下的表达。采用的是graph sage的聚集方法。</p><p><img src="http://image.rman.top/image-20200505151637254.png" alt="image-20200505151637254"></p><p>然后把节点的所有边种类信息拼接起来，然后用self-attention进行聚合。</p><p><img src="http://image.rman.top/image-20200505151656320.png" alt="image-20200505151656320"></p><h2 id="Inductive-Model-GATNE-I："><a href="#Inductive-Model-GATNE-I：" class="headerlink" title="Inductive Model: GATNE-I："></a>Inductive Model: GATNE-I：</h2><p>为了解决一些节点之间边不存在的问题，通过节点的属性和节点的种类来对节点进行嵌入。</p><p><img src="http://image.rman.top/image-20200505151717535.png" alt="image-20200505151717535"></p><h2 id="Meta-Random-walk"><a href="#Meta-Random-walk" class="headerlink" title="Meta-Random-walk:"></a>Meta-Random-walk:</h2><p>对不同种类的边进行不同的游走，然后用负采样进行训练，最后用于节点预测。</p><p><img src="http://image.rman.top/image-20200505151728482.png" alt="image-20200505151728482"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;简介：&quot;&gt;&lt;a href=&quot;#简介：&quot; class=&quot;headerlink&quot; title=&quot;简介：&quot;&gt;&lt;/a&gt;简介：&lt;/h2&gt;&lt;p&gt;现有的方法主要专注于具有单一类型节点/边缘的网络，并且不能灵活处理大型网络。许多真实世界的网络包括数十亿个节点和多种类型的边，每个节
      
    
    </summary>
    
    
      <category term="论文笔记" scheme="https://www.rman.top/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
    
    
      <category term="异构图" scheme="https://www.rman.top/tags/%E5%BC%82%E6%9E%84%E5%9B%BE/"/>
    
      <category term="论文" scheme="https://www.rman.top/tags/%E8%AE%BA%E6%96%87/"/>
    
  </entry>
  
  <entry>
    <title>newstart</title>
    <link href="https://www.rman.top/2020/05/05/newstart/"/>
    <id>https://www.rman.top/2020/05/05/newstart/</id>
    <published>2020-05-05T03:11:54.000Z</published>
    <updated>2026-03-13T01:50:06.921Z</updated>
    
    <content type="html"><![CDATA[ <center>开始一个新的生活吧</center><p><img src="http://image.rman.top/bg-4cbb1d7.jpg" alt=""></p>]]></content>
    
    <summary type="html">
    
      
      
         &lt;center&gt;开始一个新的生活吧&lt;/center&gt;

&lt;p&gt;&lt;img src=&quot;http://image.rman.top/bg-4cbb1d7.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;

      
    
    </summary>
    
    
      <category term="杂记" scheme="https://www.rman.top/categories/%E6%9D%82%E8%AE%B0/"/>
    
    
      <category term="杂记" scheme="https://www.rman.top/tags/%E6%9D%82%E8%AE%B0/"/>
    
  </entry>
  
</feed>
