From f018f2030ccbc1871732020ff42cb2ebb2277a84 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 18 Oct 2017 21:48:00 +0200 Subject: [PATCH] Try optimized parser forward loop --- spacy/syntax/nn_parser.pxd | 4 ++-- spacy/syntax/nn_parser.pyx | 2 -- spacy/syntax/transition_system.pyx | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spacy/syntax/nn_parser.pxd b/spacy/syntax/nn_parser.pxd index b0b7693b7..fd1d4c9be 100644 --- a/spacy/syntax/nn_parser.pxd +++ b/spacy/syntax/nn_parser.pxd @@ -16,7 +16,7 @@ cdef class Parser: cdef public object _multitasks cdef void _parse_step(self, StateC* state, - const float* feat_weights, - int nr_class, int nr_feat, int nr_piece) nogil + const float* feat_weights, const float* hW, const float* hb, + int nr_class, int nr_hidden, int nr_feat, int nr_piece) nogil #cdef int parseC(self, TokenC* tokens, int length, int nr_feat) nogil diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index f8e1baf35..4846f326e 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -289,8 +289,6 @@ cdef class Parser: zero_init(Affine(nr_class, hidden_width, drop_factor=0.0)) ) upper.is_noop = False - print(upper._layers) - print(upper._layers[0]._layers) # TODO: This is an unfortunate hack atm! # Used to set input dimensions in network. diff --git a/spacy/syntax/transition_system.pyx b/spacy/syntax/transition_system.pyx index 055129c8b..922fdf97c 100644 --- a/spacy/syntax/transition_system.pyx +++ b/spacy/syntax/transition_system.pyx @@ -148,7 +148,8 @@ cdef class TransitionSystem: def add_action(self, int action, label_name): cdef attr_t label_id - if not isinstance(label_name, (int, long)): + if not isinstance(label_name, int) and \ + not isinstance(label_name, long): label_id = self.strings.add(label_name) else: label_id = label_name