A replay training step takes a batch of new examples, a batch drawn from the memory buffer, and combines their losses with a mixing fraction . Implement it for a linear softmax classifier so every quantity is exact.
softmax_ce(W, X, y)
W is (d, C), X is (n, d), y an (n,) integer array. Logits are X @ W. Return (loss, grad): the mean cross-entropy as a Python float and its (d, C) gradient with respect to W. Compute the softmax stably.replay_step(W, X_new, y_new, X_buf, y_buf, rho, lr)
lr on that objective and return (W_next, info), where info is a dict with keys "loss_new", "loss_buf", "objective" (all evaluated at the incoming W, as Python floats rounded to 6 decimals).rho = 0 the step must equal a plain step on the new batch; X_buf may then be empty (shape (0, d)), and "loss_buf" should be 0.0.forgetting_curve(W0, X_new, y_new, X_buf, y_buf, X_old_test, y_old_test, rhos, steps, lr, decimals=4)
rho in rhos, start from a copy of W0, run steps replay steps, and record the cross-entropy on the old-task test set (X_old_test, y_old_test) at the end. Return the list of recorded losses rounded to decimals, in the order of rhos.(softmax - onehot) / n; chain it through X @ W.W0; copy it for each rho.