d1f352a71ba7056a4dc3adb6698e0e792d78b0b2,models/AttModel.py,AttModel,_sample_beam,#AttModel#Any#Any#Any#Any#,116
Before Change
// embed fc and att feats
fc_feats = self.fc_embed(fc_feats)
_att_feats = self.att_embed(att_feats.view(-1, self.att_feat_size))
att_feats = _att_feats.view(*(att_feats.size()[:-1] + (self.rnn_size,)))
// Project the attention feats first to reduce memory and computation comsumptions.
p_att_feats = self.ctx2att(att_feats.view(-1, self.rnn_size))
p_att_feats = p_att_feats.view(*(att_feats.size()[:-1] + (self.att_hid_size,)))
assert beam_size <= self.vocab_size + 1, "lets assume this for now, otherwise this corner case causes a few headaches down the road. can be dealt with in future if needed"
seq = torch.LongTensor(self.seq_length, batch_size).zero_()
seqLogprobs = torch.FloatTensor(self.seq_length, batch_size)
After Change
return logprobs, state
def _sample_beam(self, fc_feats, att_feats, att_masks=None, opt={}):
beam_size = opt.get("beam_size", 10)
batch_size = fc_feats.size(0)
// embed fc and att feats
fc_feats = self.fc_embed(fc_feats)
att_feats = pack_wrapper(self.att_embed, att_feats, att_masks)
// Project the attention feats first to reduce memory and computation comsumptions.
p_att_feats = self.ctx2att(att_feats)
In pattern: SUPERPATTERN
Frequency: 6
Non-data size: 23
Instances
Project Name: ruotianluo/ImageCaptioning.pytorch
Commit Name: d1f352a71ba7056a4dc3adb6698e0e792d78b0b2
Time: 2017-11-13
Author: rluo@ttic.edu
File Name: models/AttModel.py
Class Name: AttModel
Method Name: _sample_beam
Project Name: ruotianluo/self-critical.pytorch
Commit Name: d1f352a71ba7056a4dc3adb6698e0e792d78b0b2
Time: 2017-11-13
Author: rluo@ttic.edu
File Name: models/AttModel.py
Class Name: AttModel
Method Name: _forward
Project Name: ruotianluo/self-critical.pytorch
Commit Name: d1f352a71ba7056a4dc3adb6698e0e792d78b0b2
Time: 2017-11-13
Author: rluo@ttic.edu
File Name: models/AttModel.py
Class Name: AttModel
Method Name: _sample_beam
Project Name: ruotianluo/ImageCaptioning.pytorch
Commit Name: d1f352a71ba7056a4dc3adb6698e0e792d78b0b2
Time: 2017-11-13
Author: rluo@ttic.edu
File Name: models/AttModel.py
Class Name: AttModel
Method Name: _sample