Since you are calculating the global statistics, you could simply use:
data = (data - mean) / (max - min)

Did you play around with some hyperparameters, e.g. the learning rate and checked, if this would change the behavior?
If that doesn’t help, I would recommend to try to overfit your model on a small dataset samples, e.g. just 10 samples, and make sure your model predicts these samples perfectly.
If that doesn’t work, there might be another error in the code I haven’t found yet.