Could you see whether the numbers rapidly increase for each iteration? Because I had a similar problem but I made a dumb mistake of not resetting the printed loss after n number of iterations and it just kept accumulating.