This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from InCogNiTo124/dev
Fix mathsy bugs
- Loading branch information
Showing
3 changed files
with
52 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import numpy as np | ||
|
||
class Linear(): | ||
def __init__(self, in_dimension, out_dimension): | ||
self.W = np.random.randn(out_dimension, in_dimension) | ||
class Sigmoid(): | ||
def __init__(self): | ||
return | ||
|
||
def forward(self, X): | ||
return self.W.dot(X) | ||
return 1/(1+np.exp(-X)) | ||
|
||
def backward(self): | ||
pass | ||
def backward(self, delta): | ||
return delta*(1-delta) | ||
|
||
def __repr__(self): | ||
return "Linear(W=\n{}\nb=\n{})".format(repr(self.W), repr(self.b)) | ||
class Tanh(): | ||
def __init__(self): | ||
return | ||
|
||
def tanh(x): | ||
return np.tanh(x) | ||
|
||
def sigm(x): | ||
return 1/(1+np.exp(-x)) | ||
def forward(self, X): | ||
return np.tanh(X) | ||
|
||
def relu(x): | ||
# pretty f***ing smart :D | ||
return x * (x > 0) | ||
def backward(self, delta): | ||
return (1-delta) * (1+delta) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters