Quick py3 fix for gradients.