Merge branch 'develop' into feature/lemmatizer

This commit is contained in:
Matthew Honnibal 2018-09-25 11:09:22 +02:00
commit e4d8f86d7f
3 changed files with 5 additions and 7 deletions

View File

@ -213,8 +213,7 @@ class ParserModel(Model):
self._layers[-1]._layers[-1] = larger self._layers[-1]._layers[-1] = larger
def begin_training(self, X, y=None): def begin_training(self, X, y=None):
for layer in self._layers: self.lower.begin_training(X, y=y)
layer.begin_training(X, y=y)
@property @property
def tok2vec(self): def tok2vec(self):

View File

@ -525,8 +525,7 @@ cdef class Parser:
else: else:
if sgd is None: if sgd is None:
sgd = self.create_optimizer() sgd = self.create_optimizer()
self.model.begin_training( self.model.begin_training([])
self.model.ops.allocate((5, cfg['token_vector_width'])))
self.cfg.update(cfg) self.cfg.update(cfg)
return sgd return sgd

View File

@ -994,12 +994,12 @@ cdef int set_children_from_heads(TokenC* tokens, int length) except -1:
tokens[i].l_edge = i tokens[i].l_edge = i
tokens[i].r_edge = i tokens[i].r_edge = i
# Twice, for non-projectivity # Twice, for non-projectivity
for _ in range(2): for loop_count in range(2):
# Set left edges # Set left edges
for i in range(length): for i in range(length):
child = &tokens[i] child = &tokens[i]
head = &tokens[i + child.head] head = &tokens[i + child.head]
if child < head: if child < head and loop_count == 0:
head.l_kids += 1 head.l_kids += 1
if child.l_edge < head.l_edge: if child.l_edge < head.l_edge:
head.l_edge = child.l_edge head.l_edge = child.l_edge
@ -1009,7 +1009,7 @@ cdef int set_children_from_heads(TokenC* tokens, int length) except -1:
for i in range(length-1, -1, -1): for i in range(length-1, -1, -1):
child = &tokens[i] child = &tokens[i]
head = &tokens[i + child.head] head = &tokens[i + child.head]
if child > head: if child > head and loop_count == 0:
head.r_kids += 1 head.r_kids += 1
if child.r_edge > head.r_edge: if child.r_edge > head.r_edge:
head.r_edge = child.r_edge head.r_edge = child.r_edge