Use ftrl optimizer in parser

This commit is contained in:
Matthew Honnibal 2017-03-15 11:56:37 -05:00
parent 4cab8ac136
commit 8543db8a5b
1 changed files with 2 additions and 2 deletions

View File

@ -87,8 +87,8 @@ cdef class ParserModel(AveragedPerceptron):
if guess == best or best == -1:
return 0.0
for feat in eg.c.features[:eg.c.nr_feat]:
self.update_weight(feat.key, guess, feat.value * eg.c.costs[guess])
self.update_weight(feat.key, best, -feat.value * eg.c.costs[guess])
self.update_weight_ftrl(feat.key, guess, feat.value * eg.c.costs[guess])
self.update_weight_ftrl(feat.key, best, -feat.value * eg.c.costs[guess])
#for clas in [guess, best]:
# loss += (-eg.c.costs[clas] - eg.c.scores[clas]) ** 2
# d_loss = eg.c.scores[clas] - -eg.c.costs[clas]