Copied from GradientDescent.scala. Fixed both in next commit.