Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bugs in train_itm.py when generating negative samples #11

Closed
ghost opened this issue Mar 30, 2021 · 0 comments
Closed

Potential bugs in train_itm.py when generating negative samples #11

ghost opened this issue Mar 30, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 30, 2021

As the following codes show,

mmnas/train_itm.py

Lines 335 to 353 in 552e29e

for step, (frcn_feat_iter_list, bbox_feat_iter_list, rel_img_iter_list, cap_ix_iter_list, rel_cap_iter_list, neg_idx_list) in enumerate(tqdm.tqdm(neg_imgs_loader)):
frcn_feat_iter_list = all_frcn_feat_iter_list[neg_idx_list, :]
bbox_feat_iter_list = all_bbox_feat_iter_list[neg_idx_list, :]
rel_img_iter_list = all_rel_img_iter_list[neg_idx_list, :]
frcn_feat_iter_list = frcn_feat_iter_list.view(-1, self.__C.FRCNFEAT_LEN, self.__C.FRCNFEAT_SIZE)
bbox_feat_iter_list = bbox_feat_iter_list.view(-1, self.__C.FRCNFEAT_LEN, 5)
rel_img_iter_list = rel_img_iter_list.view(-1, self.__C.FRCNFEAT_LEN, self.__C.FRCNFEAT_LEN, 4)
cap_ix_iter_list = cap_ix_iter_list.view(-1, neg_caps_loader.dataset.max_token)
rel_cap_iter_list = rel_cap_iter_list.view(-1, neg_caps_loader.dataset.max_token, neg_caps_loader.dataset.max_token, 3)
input = (frcn_feat_iter_list, bbox_feat_iter_list, rel_img_iter_list, cap_ix_iter_list, rel_cap_iter_list)
scores = net(input)
scores = scores.view(-1, self.__C.NEG_RANDSIZE)
arg_scores = torch.argsort(scores, dim=-1, descending=True)[:, :self.__C.NEG_HARDSIZE]
arg_scores_bi = torch.arange(arg_scores.size(0)).unsqueeze(1).expand_as(arg_scores)
scores_ind = neg_idx_list[arg_scores_bi, arg_scores].to(scores.device)
neg_imgs_idx_list.append(scores_ind)

And here is what confuses me,

mmnas/train_itm.py

Lines 336 to 338 in 552e29e

frcn_feat_iter_list = all_frcn_feat_iter_list[neg_idx_list, :]
bbox_feat_iter_list = all_bbox_feat_iter_list[neg_idx_list, :]
rel_img_iter_list = all_rel_img_iter_list[neg_idx_list, :]

Why use negative caption indices to get corresponding image features?
I think the three lines of codes should be removed.

@ghost ghost closed this as completed Mar 30, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants