memnn should not sample cands when not training
@@ -129,9 +129,15 @@ class MemnnAgent(Agent):
return observation
def predict(self, xs, cands, ys=None):
- # Subsample to reduce training time
- cands = [list(set(random.sample(c, min(32, len(c))) + self.labels)) for c in cands]
is_training = ys is not None
+ if is_training:
+ # Subsample to reduce training time
+ cands = [list(set(random.sample(c, min(32, len(c))) + self.labels))
+ for c in cands]
+ else:
+ # rank all cands to increase accuracy
+ cands = [list(set(c)) for c in cands]
+
self.model.train(mode=is_training)
# Organize inputs for network (see contents of xs and ys in batchify method)
inputs = [Variable(x, volatile=is_training) for x in xs]
