MSA_emb
类的作用是对多序列对齐(MSA)数据进行嵌入编码,同时添加位置编码和查询编码(调用PositionalEncoding 和 QueryEncoding)以便为序列特征建模类。
源代码:
class MSA_emb(nn.Module):def __init__(self, d_model=64, d_msa=21, p_drop=0.1, max_len=5000):super(MSA_emb, self).__init__()self.emb = nn.Embedding(d_msa, d_model)self.pos = PositionalEncoding(d_model, p_drop=p_drop, max_len=max_len)self.pos_q = QueryEncoding(d_model)def forward(self, msa, idx):B, N, L = msa.shapeout = self.emb(msa) # (B, N, L, K//2)out = self.pos(out, idx) # add positional encodingreturn self.pos_q(out) # add query encoding
代码解读:
类结构
class MSA_emb(nn.Module):def __init__(self, d_model=64, d_msa=21, p_drop=0.1, max_len=5000):super(MSA_emb,