You’re giving a very high learning rate(50). This would cause divergence in your loss surface and that’s why your parameters are messing up. Change the lr to something very small maybe 1e-2 or 1e-3 and try training again