Skip to content

Instantly share code, notes, and snippets.

@logancyang
Last active June 26, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logancyang/c95ae9249e87c326f408f89a1695130a to your computer and use it in GitHub Desktop.
Save logancyang/c95ae9249e87c326f408f89a1695130a to your computer and use it in GitHub Desktop.
class Tensor:
def __init__(self, data, _parents, _op):
...
def sigmoid(self):
sigm = 1.0/(1 + np.exp(-self.data))
out = Tensor(sigm, _parents=(self,), _op="σ")
def _backward():
self.grad = sigm * (1 - sigm)
out._backward = _backward
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment