uh… random generation is a sequential process so every time you generate a new random number the seed changes. Thus before every training begins you need to reset the seed, i.e. put set_seed() in the loop.