Fix dot products

This commit is contained in:
Aodhnait Étaín 2020-11-16 11:42:44 +00:00
parent d31a72374d
commit b0bb7b523d

View file

@ -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