diff --git a/spacy/tests/test_misc.py b/spacy/tests/test_misc.py index 5c69dae3e..66ecd8a8e 100644 --- a/spacy/tests/test_misc.py +++ b/spacy/tests/test_misc.py @@ -69,10 +69,20 @@ def test_PrecomputableAffine(nO=4, nI=5, nF=3, nP=2): Y, get_dX = model.begin_update(tensor) assert Y.shape == (tensor.shape[0]+1, nF, nO, nP) assert model.d_pad.shape == (1, nF, nO, nP) - dY = model.ops.allocate((15, nF, nO, nP)) + dY = model.ops.allocate((15, nO, nP)) ids = model.ops.allocate((15, nF)) ids[1,2] = -1 - dY[1,2] = 1 + dY[1] = 1 assert model.d_pad[0, 2, 0, 0] == 0. model._backprop_padding(dY, ids) assert model.d_pad[0, 2, 0, 0] == 1. + model.d_pad.fill(0.) + ids.fill(0.) + dY.fill(0.) + ids[1,2] = -1 + ids[1,1] = -1 + ids[1,0] = -1 + dY[1] = 1 + assert model.d_pad[0, 2, 0, 0] == 0. + model._backprop_padding(dY, ids) + assert model.d_pad[0, 2, 0, 0] == 3.