ACC, BWT, FWT and Forgetting
A continual learner that sees T tasks in order is evaluated with a T×T accuracy matrix R, where Ri,j is the test accuracy on task j measured right after training on task i (0-indexed here). Implement the four standard summaries.
cl_metrics(R, baseline, decimals=4)
R is a (T, T) array-like; baseline is a scalar or a length-T array-like with the accuracy of a randomly initialised model on each task.
- Average accuracy: ACC=T1∑jRT−1,j.
- Backward transfer: BWT=T−11∑j=0T−2(RT−1,j−Rj,j).
- Forward transfer: FWT=T−11∑j=1T−1(Rj−1,j−bj).
- Forgetting: F=T−11∑j=0T−2(maxl≤T−2Rl,j−RT−1,j).
- Return a dict with keys
"ACC", "BWT", "FWT", "forgetting", rounded to decimals, as Python floats. For T=1 return 0.0 for the three transfer quantities.
per_task_forgetting(R, decimals=4)
- Return a list of length T−1 with each task's individual forgetting term maxl≤T−2Rl,j−RT−1,j, rounded.
Hints
- The last row of
R is the final state; the diagonal is each task right after it was learned.
- The maximum in the forgetting measure runs over rows before the last one.
np.broadcast_to or np.full turns a scalar baseline into a per-task vector.