stochastic gradient descent builds without type errors but its falls in a recursion trap