From ab28f911b457fdd3479fa2091bea44ec7d42ddc5 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 19 Aug 2017 09:02:57 -0500 Subject: [PATCH] Fix parser learning rates --- spacy/syntax/nn_parser.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 3e5566705..7412ebeee 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -524,6 +524,7 @@ cdef class Parser: scores, bp_scores = vec2scores.begin_update(vector, drop=drop) d_scores = self.get_batch_loss(states, golds, scores) + d_scores /= len(docs) d_vector = bp_scores(d_scores, sgd=sgd) if drop != 0: d_vector *= mask @@ -582,7 +583,9 @@ cdef class Parser: width, density, sgd=sgd, drop=drop, losses=losses) backprop_lower = [] + cdef float batch_size = len(docs) for i, d_scores in enumerate(states_d_scores): + d_scores /= batch_size if losses is not None: losses[self.name] += (d_scores**2).sum() ids, bp_vectors, bp_scores = backprops[i]