beginning of stochastic gradient
Not completly done, see compiler errors osv.