Added ability to supply a nonlinear activation function to SGD.