if data.get("labels", None) is not None and verbose_loss:
// forward the model to get loss
tmp = [data["fc_feats"], data["att_feats"], data["labels"], data["masks"], data["att_masks"]]
tmp = [Variable(torch.from_numpy(_), volatile=True).cuda() for _ in tmp]
fc_feats, att_feats, labels, masks, att_masks = tmp
loss = crit(model(fc_feats, att_feats, labels, att_masks), labels[:,1:], masks[:,1:]).data[0]
After Change
if data.get("labels", None) is not None and verbose_loss:
// forward the model to get loss
tmp = [data["fc_feats"], data["att_feats"], data["labels"], data["masks"], data["att_masks"]]
tmp = [torch.from_numpy(_).cuda() for _ in tmp]
fc_feats, att_feats, labels, masks, att_masks = tmp
with torch.no_grad():
loss = crit(model(fc_feats, att_feats, labels, att_masks), labels[:,1:], masks[:,1:]).item()
loss_sum = loss_sum + loss
loss_evals = loss_evals + 1
// forward the model to also get generated samples for each image