mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-11 00:32:40 +03:00
Fix backprop of padding variable
This commit is contained in:
parent
54a716f2ec
commit
6771780d3f
|
@ -150,7 +150,9 @@ class PrecomputableAffine(Model):
|
||||||
|
|
||||||
def _backprop_padding(self, dY, ids):
|
def _backprop_padding(self, dY, ids):
|
||||||
# (1, nF, nO, nP) += (nN, nF, nO, nP) where IDs (nN, nF) < 0
|
# (1, nF, nO, nP) += (nN, nF, nO, nP) where IDs (nN, nF) < 0
|
||||||
d_pad = dY * (ids.reshape((ids.shape[0], self.nF, 1, 1)) < 0.)
|
mask = ids < 0.
|
||||||
|
mask = mask.sum(axis=1)
|
||||||
|
d_pad = dY * mask.reshape((ids.shape[0], 1, 1))
|
||||||
self.d_pad += d_pad.sum(axis=0)
|
self.d_pad += d_pad.sum(axis=0)
|
||||||
return dY, ids
|
return dY, ids
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user