Compare commits

...

2 Commits

Author SHA1 Message Date
Aodhnait Étaín a3afa0c797 Add include/ to .gitignore 2020-11-14 20:45:38 +00:00
Aodhnait Étaín 46a7f327ce Add exp function
Adds exp function to the Tensor class.
2020-11-14 20:44:55 +00:00
2 changed files with 12 additions and 2 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@ include/
lib/
lib64
pyvenv.cfg

13
nn.py
View File

@ -102,7 +102,18 @@ class Tensor:
tensor._back = back
return tensor
def exp(self):
tensor = Tensor(np.exp(self.value))
tensor._save(self)
def back(upstream):
a, = tensor._parents
return [ np.exp(a.value) ]
tensor._back = back
return tensor
def _backprop(tensor, upstream):
# Backprop through the tensor iff it has any parents.
if tensor._parents is not None: