Jensen-holm commited on
Commit
4c97910
·
1 Parent(s): 72f6f77

working on setting up the neural_network functionality

Browse files
.gitignore CHANGED
@@ -127,3 +127,7 @@ dmypy.json
127
 
128
  # Pyre type checker
129
  .pyre/
 
 
 
 
 
127
 
128
  # Pyre type checker
129
  .pyre/
130
+
131
+ .idea
132
+
133
+ .DS_Store
main.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+
4
+ def random_dataset():
5
+ """
6
+ initializes a training and
7
+ a testing dataset in the form
8
+ of numpy arrays
9
+ """
10
+ np.random.seed(8675309)
11
+ return (
12
+ np.random.randn(10000, 10),
13
+ np.random.randint(5, size=(10000, 1)),
14
+ )
15
+
16
+
17
+ def main(method: str, X: np.array, y: np.array):
18
+ pass
19
+
20
+
21
+
22
+ if __name__ == "__main__":
23
+ method = input("\nChoose a method to test: ").lower()
24
+
25
+ X, y = random_dataset()
26
+ main(
27
+ method=method,
28
+ X=X,
29
+ y=y,
30
+ )
31
+
neural_network/activation.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+
4
+
5
+ def sigmoid(x: float) -> float:
6
+ return 1.0 / (1.0 + np.exp(-x))
7
+
8
+ def sigmoid_prime(x: float) -> float:
9
+ return sigmoid(x) / (1.0 - sigmoid())
10
+
11
+ def relu(x: float) -> float:
12
+ """
13
+ returns the input if > 0
14
+ """
15
+ return max(0.0, x)
16
+
17
+ def relu_prime(x: float) -> float:
18
+ """
19
+ returns 1 if input is +
20
+ returns 0 if input is -
21
+ """
22
+ return 1 if x > 0 else 0
23
+
neural_network/backprop.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+
4
+
5
+
6
+ # for testing only
7
+ if __name__ == "__main__":
8
+ def test():
9
+ pass
10
+
11
+ test()
neural_network/forwardprop.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+
2
+
3
+ def forward_prop():
4
+ return
5
+
neural_network/main.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from neural_network.forwardprop import fp
4
+
5
+
6
+ def init(X: np.array, y: np.array, hidden_size: int) -> dict:
7
+ """
8
+ returns a dictionary containing randomly initialized
9
+ weights and biases to start off the neural_network
10
+ """
11
+ return {
12
+ "W1": np.random.randn(X.shape[1], hidden_size),
13
+ "b1": np.zeros((1, hidden_size)),
14
+ "W2": np.random.randn(hidden_size, 1),
15
+ "b2": np.zeros((1, 1)),
16
+ }
17
+
18
+
19
+ def main(
20
+ X: np.array,
21
+ y: np.array,
22
+ epochs: int,
23
+ hidden_size: int,
24
+ learning_rate: float,
25
+ activation_func: str,
26
+ ) -> None:
27
+ wb = init(X, y, hidden_size)
28
+
29
+ for e in range(epochs):
30
+
31
+ fp()
32
+ bp()
33
+
34
+ # update weights and biases
35
+
36
+
neural_network/opts.py ADDED
File without changes
opts.py ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ numpy==1.24.2