pan_pp.pytorch
pan_pp.pytorch copied to clipboard
Why rec encoder use EOS? not SOS
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