add stochastic training to batch costfunctions