Fix shape errors in the gradient (but it's still not the right value).