Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makemore Exercises (MLP2) : Activations & Gradients, Batchnorm #8

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion makemore/batch_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def load_txt_to_list(fname):
path = pathlib.Path(fname)
if not path.exists():
raise f"{fname} not found!"
raise Exception(f"{fname} not found!")

list_out = []
with open(path, "r") as file:
Expand Down
2 changes: 1 addition & 1 deletion makemore/bigrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def load_txt_to_list(fname):
path = pathlib.Path(fname)
if not path.exists():
raise f"{fname} not found!"
raise Exception(f"{fname} not found!")

list_out = []
with open(path, "r") as file:
Expand Down
7 changes: 5 additions & 2 deletions makemore/fixing_initialization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
Covers the Activations & Gradients section

Most of the fixes amount to setting up the paremeters properly,
so we setup a function to take in a list of parameters with hard-coded hyperparameters
"""
import matplotlib.pyplot as plt
import pathlib
Expand All @@ -22,7 +25,7 @@
def load_txt_to_list(fname):
path = pathlib.Path(fname)
if not path.exists():
raise f"{fname} not found!"
raise Exception(f"{fname} not found!")

list_out = []
with open(path, "r") as file:
Expand Down Expand Up @@ -374,7 +377,7 @@ def demo_gaussian_spread():

demo_gaussian_spread()

gain = 5/3 # tanh activation
gain = 5/3 # tanh activation (TODO: Still haven't been able to verify this)
C = torch.randn(size=(len(dict_ix_to_token),SIZE_DIMENSION), generator=g)
W1 = torch.randn(size=(SIZE_CONTEXT-1, SIZE_DIMENSION, SIZE_HIDDEN), generator=g) * gain / (((SIZE_CONTEXT-1)*SIZE_DIMENSION)**0.5)
b1 = torch.randn(SIZE_HIDDEN, generator=g) * 0.01
Expand Down
2 changes: 1 addition & 1 deletion makemore/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
def load_txt_to_list(fname):
path = pathlib.Path(fname)
if not path.exists():
raise f"{fname} not found!"
raise Exception(f"{fname} not found!")

list_out = []
with open(path, "r") as file:
Expand Down
Loading