mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Fix backprop of d_pad
This commit is contained in:
		
							parent
							
								
									759cc79185
								
							
						
					
					
						commit
						e85e31cfbd
					
				|  | @ -150,10 +150,10 @@ class PrecomputableAffine(Model): | |||
| 
 | ||||
|     def _backprop_padding(self, dY, ids): | ||||
|         # (1, nF, nO, nP) += (nN, nF, nO, nP) where IDs (nN, nF) < 0 | ||||
|         d_feats = dY[ids] | ||||
|         ids = ids.reshape((ids.shape[0], ids.shape[1], 1, 1)) | ||||
|         d_feats *= ids < 0 | ||||
|         self.d_pad += d_feats.sum(axis=0, keepdims=True) | ||||
|         for i in range(ids.shape[0]): | ||||
|             for j in range(ids.shape[1]): | ||||
|                 if ids[i,j] < 0: | ||||
|                     self.d_pad[0,j] += dY[i, j] | ||||
|         return dY, ids | ||||
| 
 | ||||
|     @staticmethod | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user