Randomize pipeline order during training

This commit is contained in:
Matthew Honnibal 2017-05-27 18:32:21 -05:00
parent a1d4c97fb7
commit b082f76494
1 changed files with 3 additions and 1 deletions

View File

@ -215,7 +215,9 @@ class Language(object):
grads = {} grads = {}
def get_grads(W, dW, key=None): def get_grads(W, dW, key=None):
grads[key] = (W, dW) grads[key] = (W, dW)
for proc in self.pipeline[1:]: pipes = list(self.pipeline[1:])
random.shuffle(pipes)
for proc in pipes:
if not hasattr(proc, 'update'): if not hasattr(proc, 'update'):
continue continue
tokvecses, bp_tokvecses = tok2vec.model.begin_update(feats, drop=drop) tokvecses, bp_tokvecses = tok2vec.model.begin_update(feats, drop=drop)