← Lesson
Train vs Inference
Joeven
Run
Reset
Python loads on first run
# Same tiny net as before. "Train" would change W. Inference does not. W = [[1.0, -0.5]] b = [-0.2] def forward(x, W, b): return W[0][0] * x[0] + W[0][1] * x[1] + b[0] x = [1.0, 0.0] print("infer score", round(forward(x, W, b), 3)) # Training would copy weights and nudge them. Inference leaves W alone. W_trained = [[W[0][0] - 0.1, W[0][1]]] print("after one fake step", round(forward(x, W_trained, b), 3)) print("original W unchanged", W[0], "still", round(forward(x, W, b), 3))
Run to execute this in your browser. Nothing is sent to a server.