Compare commits

...

2 Commits

Author SHA1 Message Date
Aodhnait Étaín 52d266ef91 Fix tensor.add to diff. matrices properly 2020-11-15 19:45:51 +00:00
Aodhnait Étaín c1c48bb693 Update nn.test 2020-11-15 19:45:05 +00:00
2 changed files with 2 additions and 2 deletions

View File

@ -48,7 +48,7 @@ def single_pass():
# Small test to see if autograd works.
def test():
# Input tensors.
x, y, z = tensor.Tensor(-2), tensor.Tensor(5), tensor.Tensor(-4)
x, y, z = tensor.Tensor(np.array([[1, 2, 3]])), tensor.Tensor(np.array([[2, 3, 4]])), tensor.Tensor(np.array([[1], [2], [3]]))
# Forward pass.
q = x.add(y)

View File

@ -27,7 +27,7 @@ class Tensor:
tensor._save(self, other)
def back(upstream):
return np.dot(np.ones_like(self.value), upstream), np.dot(np.ones_like(self.value), upstream)
return np.dot(np.ones_like(self.value).T, upstream), np.dot(np.ones_like(self.value).T, upstream)
tensor._back = back
return tensor