Copy initialize gradient from old code