From b0bb7b523ddd4fb097407c95352caf1b3ebab381 Mon Sep 17 00:00:00 2001 From: aodhneine Date: Mon, 16 Nov 2020 11:42:44 +0000 Subject: [PATCH] Fix dot products --- pygrad/tensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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