taoxugit / AttnGAN

MIT License
1.33k stars 415 forks source link

Question about the Code #49

Open MapleSpirit opened 5 years ago

MapleSpirit commented 5 years ago

In the /code/model.py, the c_code is passed to the class NEXT_STAGE_G as a parameter. However, the c_code is covered by the function c_code, att = self.att(h_code, word_embs) so that the parameter here is redundant. I'm not sure whether the c_code in the definition is necessary or just misused in c_code, att = self.att(h_code, word_embs). Thanks~

def forward(self, h_code, c_code, word_embs, mask):
    """
        h_code1(query):  batch x idf x ih x iw (queryL=ihxiw)
        word_embs(context): batch x cdf x sourceL (sourceL=seq_len)
        c_code1: batch x idf x queryL
        att1: batch x sourceL x queryL
    """
    self.att.applyMask(mask)
    c_code, att = self.att(h_code, word_embs)
    h_c_code = torch.cat((h_code, c_code), 1)
    out_code = self.residual(h_c_code)

    # state size ngf/2 x 2in_size x 2in_size
    out_code = self.upsample(out_code)

    return out_code, att
MapleSpirit commented 5 years ago

Oh, I take a closer look at the network architecture in the paper and think that the c_code in the defination should be unnecessary. The definition should be def forward(self, h_code, word_embs, mask):. Right?