diff --git a/pygrad/tensor.py b/pygrad/tensor.py index c01f1f0..473aa5c 100644 --- a/pygrad/tensor.py +++ b/pygrad/tensor.py @@ -54,7 +54,7 @@ class Tensor: def back(upstream): a, b = tensor._parents - return np.dot(b.value, upstream), np.dot(a.value.T, upstream) + return np.dot(upstream, b.value.T), np.dot(a.value.T, upstream) tensor._back = back return tensor @@ -131,7 +131,7 @@ class Tensor: def back(upstream): # dtanh(x)/dx = 1 - tanh2(x) a, = tensor._parents - return [1 - np.dot(np.tanh(a.value) ** 2, upstream)] + return [np.ones_like(self.value) - np.dot(upstream, (np.tanh(a.value) ** 2).T)] tensor._back = back return tensor