From 08bee76790b3b07b7982d1f71ab1ab56945e33e9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 6 May 2017 18:24:38 +0200 Subject: [PATCH] Learns things --- spacy/_ml.py | 3 ++- spacy/syntax/parser.pyx | 2 +- spacy/syntax/stateclass.pyx | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spacy/_ml.py b/spacy/_ml.py index 8ab86488d..d13d014bb 100644 --- a/spacy/_ml.py +++ b/spacy/_ml.py @@ -4,6 +4,7 @@ from thinc.neural._classes.hash_embed import HashEmbed from thinc.neural._classes.convolution import ExtractWindow from thinc.neural._classes.static_vectors import StaticVectors +from thinc.neural._classes.batchnorm import BatchNorm from .attrs import ID, LOWER, PREFIX, SUFFIX, SHAPE, TAG, DEP @@ -160,7 +161,7 @@ def build_tok2vec(lang, width, depth=2, embed_size=1000): >> with_flatten( #(static | prefix | suffix | shape) (lower | prefix | suffix | shape | tag) - >> Maxout(width, width*5) + >> BatchNorm(Maxout(width, width*5), nO=width) #>> (ExtractWindow(nW=1) >> Maxout(width, width*3)) #>> (ExtractWindow(nW=1) >> Maxout(width, width*3)) ) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 5d64048bf..3b8a9f849 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -113,7 +113,7 @@ cdef class Parser: def __reduce__(self): return (Parser, (self.vocab, self.moves, self.model), None, None) - def build_model(self, width=32, nr_vector=1000, nF=1, nB=1, nS=1, nL=1, nR=1, **_): + def build_model(self, width=64, nr_vector=1000, nF=1, nB=1, nS=1, nL=1, nR=1, **_): state2vec = build_debug_state2vec(width, nr_vector, nF, nB, nL, nR) model = build_debug_model(state2vec, width, 2, self.moves.n_moves) return model diff --git a/spacy/syntax/stateclass.pyx b/spacy/syntax/stateclass.pyx index 5c535c899..e6e67eaeb 100644 --- a/spacy/syntax/stateclass.pyx +++ b/spacy/syntax/stateclass.pyx @@ -47,7 +47,7 @@ cdef class StateClass: return ' '.join((third, second, top, '|', n0, n1)) def nr_context_tokens(self, int nF, int nB, int nS, int nL, int nR): - return 8 + return 4 def set_context_tokens(self, int[:] output, nF=1, nB=0, nS=2, nL=2, nR=2): @@ -55,10 +55,10 @@ cdef class StateClass: output[1] = self.B(1) output[2] = self.S(0) output[3] = self.S(1) - output[4] = self.L(self.S(0), 1) - output[5] = self.L(self.S(0), 2) - output[6] = self.R(self.S(0), 1) - output[7] = self.R(self.S(0), 2) + #output[4] = self.L(self.S(0), 1) + #output[5] = self.L(self.S(0), 2) + #output[6] = self.R(self.S(0), 1) + #output[7] = self.R(self.S(0), 2) #output[7] = self.L(self.S(1), 1) #output[8] = self.L(self.S(1), 2) #output[9] = self.R(self.S(1), 1)