moved averageWeights into the correct training function