Fixed CPU gradient check