-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added intro tutorial on neural networks
- Loading branch information
Showing
18 changed files
with
349 additions
and
57 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import math | ||
import numpy as np | ||
|
||
def relu(z): | ||
return max(0, z) | ||
|
||
def relu_prime(z): | ||
if z > 0: | ||
return 1 | ||
return 0 | ||
|
||
def sigmoid(z): | ||
return 1.0 / (1.0 + np.exp(-z)) | ||
|
||
def sigmoid_prime(z): | ||
return sigmoid(z) * (1 - sigmoid(z)) |
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,9 +1,19 @@ | ||
def myfunction(var1): | ||
return var1 + 1 | ||
import math | ||
import numpy as np | ||
|
||
class MyClass(): | ||
def __init__(self, var2): | ||
self.var2 = var2 | ||
def relu(z): | ||
return max(0,z) | ||
|
||
def do_something(self): | ||
return "Hey" | ||
def feed_forward(x, Wh, Wo): | ||
# Hidden layer | ||
Zh = x * Wh | ||
H = relu(Zh) | ||
|
||
# Output layer | ||
Zo = H * Wo | ||
output = relu(Zo) | ||
return output | ||
|
||
# Zh - Hidden layer weighted input | ||
# h = Hidden layer activation | ||
# Zo - Output layer weighted input |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import math | ||
import numpy as np | ||
|
||
def relu(z): | ||
return max(0,z) | ||
|
||
def feed_forward(x, Wh, Wo): | ||
# Hidden layer | ||
Zh = x * Wh | ||
H = relu(Zh) | ||
|
||
# Output layer | ||
Zo = H * Wo | ||
output = relu(Zo) | ||
return output | ||
|
||
def relu_prime(z): | ||
if z > 0: | ||
return z | ||
return 1 | ||
|
||
def cost(yHat, y): | ||
return 0.5 * (yHat - y)**2 | ||
|
||
def cost_prime(yHat, y): | ||
return yHat - y | ||
|
||
def backprop(x, y, Wh, Wo, lr): | ||
yHat = feed_forward(x, Wh, Wo) | ||
|
||
# Layer Error | ||
Eo = (O - y) * relu_prime(Zo) | ||
Eh = Eo * Wo * relu_prime(Zh) | ||
|
||
# Cost derivative for weights | ||
dWo = Eo * H | ||
dWh = Eh * x | ||
|
||
# Update weights | ||
Wh -= lr * dWh | ||
Wo -= lr * dWo |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Oops, something went wrong.