Solved by Ditlev_Jorgensen in post #2 
              
              
                I solved it by also deleting predicted and true. 
Adding the following line after calculating loss: 
#Release predicted and true
predicted, true = [], []