Merge pull request #1617 from harvard-edge/fix/perceptron-seed

fix(tinytorch): perceptron weights deterministic across runs (#1611)
This commit is contained in:
Vijay Janapa Reddi
2026-04-30 19:04:25 -04:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -85,7 +85,9 @@ This milestone shows you WHY training is essential - the model won't work withou
import sys
import os
import numpy as np
rng = np.random.default_rng(7)
# Unseeded RNG: each run draws different cluster points so the demo lives up
# to the on-screen "No random seed - each run will be different!" promise.
rng = np.random.default_rng()
import argparse
# Add project root to path for correct tinytorch imports

View File

@@ -62,7 +62,10 @@ from tinytorch.core.activations import ReLU, Sigmoid # Module 02 - intelligence
#| export
import numpy as np
rng = np.random.default_rng(7)
# Module-level RNG is intentionally UNSEEDED so freshly-constructed layers
# (e.g., Linear) produce different weights on every run. Tests/demos that
# need determinism create their own seeded RNG locally (see below).
rng = np.random.default_rng()
# Import from TinyTorch package (previous modules must be completed and exported)
from tinytorch.core.tensor import Tensor