Closed-Form Last Layer Optimization