2018-summer-DL-training-program / Lab-2-Image-Captioning

Image Captioning
1 stars 1 forks source link

DecoderRNN 的 forward #6

Open bearwbearw opened 6 years ago

bearwbearw commented 6 years ago

`class DecoderRNN(nn.Module):

def forward(self, features, captions, lengths):
    """Decode image feature vectors and generates captions."""
    embeddings = self.embed(captions)
    embeddings = torch.cat((features.unsqueeze(1), embeddings), 1)
    packed = pack_padded_sequence(embeddings, lengths, batch_first=True)`

助教你好, 這個 embeddings 的內容是 cnn 的 feature map + 字串, 所以有意義的資料長度應該是 1 + lengths

但執行了下面這, 帶入的長度是 length. 這樣不是字串的最後一個有意義的資料會被 truncate 掉? 'packed = pack_padded_sequence(embeddings, lengths, batch_first=True)`

hui-po-wang commented 6 years ago

@bearwbearw,

13

同上,caption的最後一個字並沒有變成inputs。

TA