Solved by vmirly1 in post #2 
              
              
                In the following line of code: 

the left hand side of the equation refers to the weights of one layer, but in the right-hand side refers to all model parameters. I think you would want to put the best model and the current model in a for-loop with zip() function. Assuming that you have two models c…