Solved by jpeg729 in post #2 
              
              
                The line output = model(input) overwrites output in so far as it reassigns the name output to point to new data, in this case the return value of model(input). If some other code has kept a reference to the old data then python keeps the old data around. In this case the next line loss += criterio…