mirror of
https://github.com/explosion/spaCy.git
synced 2025-04-25 11:23:40 +03:00
Improve efficiency of backprop of padding variable
This commit is contained in:
parent
a22f96c3f1
commit
260e6ee3fb
|
@ -150,10 +150,8 @@ 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
|
||||||
for i in range(ids.shape[0]):
|
d_pad = dY * (ids.reshape((ids.shape[0], self.nF, 1, 1)) < 0.)
|
||||||
for j in range(ids.shape[1]):
|
self.d_pad += d_pad.sum(axis=0)
|
||||||
if ids[i,j] < 0:
|
|
||||||
self.d_pad[0,j] += dY[i, j]
|
|
||||||
return dY, ids
|
return dY, ids
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user