diff --git a/norch/autograd/__pycache__/functions.cpython-38.pyc b/norch/autograd/__pycache__/functions.cpython-38.pyc index 2c88c4f..b0f6eab 100644 Binary files a/norch/autograd/__pycache__/functions.cpython-38.pyc and b/norch/autograd/__pycache__/functions.cpython-38.pyc differ diff --git a/norch/autograd/functions.py b/norch/autograd/functions.py index 72cb6a5..e4f91f5 100644 --- a/norch/autograd/functions.py +++ b/norch/autograd/functions.py @@ -83,8 +83,10 @@ class MatmulBackward: def backward(self, gradient): x, y = self.input - if x.shape != y.shape: # broadcasted case - return [gradient @ y.transpose(-1,-2), x.transpose(-1,-2) @ gradient] + if x.ndim != y.ndim: # broadcasted case + print("KKKKKKKKK", x.ndim, y.ndim) + aux = (gradient @ y.transpose(-1,-2)) + return [aux.sum(axis=0), x.transpose(-1,-2) @ gradient] else: return [gradient @ y.transpose(-1,-2), x.transpose(-1,-2) @ gradient]