Skip to content

Instantly share code, notes, and snippets.

View prajjwal1's full-sized avatar
💭
another nn really far from covergence

Prajj prajjwal1

💭
another nn really far from covergence
View GitHub Profile
@prajjwal1
prajjwal1 / nn.py
Last active September 4, 2025 02:17
class Neuron:
def __init__(self, dims):
self.w = [he_init(dims[idx], dims[idx+1]) for idx in range(len(dims-1))]
self.b = [np.zeros(dims[idx+1], ) for idx in range(len(dims-1))]
def forward(self, x):
Z, A = [], [x]
a = x
for _ in range(len(self.w)):
z = a @ self.w[idx] + self.b[idx] # [B, D_in] @ [D_in, D_out] + [1, D_out]
@prajjwal1
prajjwal1 / nn.py
Created September 3, 2025 21:52
aa
import math
import numpy as np
class Linear:
def __init__(self, in_features, out_features):
self.w = np.random.randn(in_features, out_features) * (1 / math.sqrt(in_features))
self.b = np.random.randn(1, out_features)
def forward(self, x):
"""