whai362 / pan_pp.pytorch

Official implementations of PSENet, PAN and PAN++.
Apache License 2.0
435 stars 90 forks source link

Why rec encoder use EOS? not SOS #103

Open Patickk opened 2 years ago

Patickk commented 2 years ago

hi: I find there is no 'SOS' in code, I understand SOS should be embedding at the beginning. Please tell me ,thanks! ---------------code----------------------------------------------- class Encoder(nn.Module): def init(self, hidden_dim, voc, char2id, id2char): super(Encoder, self).init() self.hidden_dim = hidden_dim self.vocab_size = len(voc) self.START_TOKEN = char2id['EOS'] self.emb = nn.Embedding(self.vocab_size, self.hidden_dim) self.att = MultiHeadAttentionLayer(self.hidden_dim, 8)

def forward(self, x):
    batch_size, feature_dim, H, W = x.size()
    x_flatten = x.view(batch_size, feature_dim, H * W).permute(0, 2, 1)
    st = x.new_full((batch_size,), self.START_TOKEN, dtype=torch.long)
    emb_st = self.emb(st)
    holistic_feature, _ = self.att(emb_st, x_flatten, x_flatten)
    return