Skip to content

Instantly share code, notes, and snippets.

View wolfecameron's full-sized avatar

Cameron R. Wolfe wolfecameron

View GitHub Profile
import matplotlib.pyplot as plt
def calc_demon_decay(total_iter, curr_iter, min_val, max_val):
z = float(total_iter - curr_iter) / total_iter
return min_val + float(max_val - min_val) * (z / (1 - 0.9 + 0.9*z))
train_iters = 100
max_mom = 0.9
min_mom = 0.0
plt.title('Demon Decay')
import torch
class FFNN(torch.nn.Module):
def __init__(self, input_size, hidden_size, output_size, num_layers):
super().__init__()
self.input_size = input_size
self.hidden_size = hidden_size
self.output_size = output_size
self.num_layers = num_layers
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): BasicBlock(
(conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
@wolfecameron
wolfecameron / llm_preso_links_2.txt
Created August 10, 2023 13:42
LLM Presentation Links (EY Week #2)
@wolfecameron
wolfecameron / cartier_session1_links.txt
Created September 27, 2023 13:58
Links from LLM presentation for Cartier (week 1).
@wolfecameron
wolfecameron / cartier_session2_links
Last active October 12, 2023 04:01
Links from LLM presentation for Cartier (week 2).
@wolfecameron
wolfecameron / causal_self_attention.py
Last active November 7, 2024 16:57
Implementation of causal self-attention in PyTorch
"""
Source: https://github.com/karpathy/nanoGPT/blob/master/model.py
"""
import math
import torch
from torch import nn
import torch.nn.functional as F
class CausalSelfAttention(nn.Module):
@wolfecameron
wolfecameron / exploding_activations.py
Created March 2, 2024 21:23
Exploding activations from repeated matrix multiplications.
import torch
# experiment settings
d = 5
nlayers = 100
normalize = False # set True to use normalization
# create vector with random entries between [-1, 1]
input_vector = (torch.rand(d) - 0.5) * 2.0