fix pytorch teacher bug with labels
@@ -381,7 +381,15 @@ class FixedDialogTeacher(Teacher):
# remember correct answer if available (for padding, None)
for i, ex in enumerate(batch):
- self.lastYs[i] = ex.get('labels', ex.get('eval_labels'))
+ if 'labels' in ex:
+ labels = ex['labels']
+ self.lastYs[i] = labels
+ if not self.datatype.startswith('train') or 'evalmode' in self.datatype:
+ del ex['labels']
+ if not self.opt.get('hide_labels', False):
+ ex['eval_labels'] = labels
+ else:
+ self.lastYs[i] = ex.get('eval_labels', None)
return batch
